Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/1810fbfe22a1202ddbd8024dde4ec10882cc3e76
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/1810fbfe22a1202ddbd8024dde4ec10882cc3e76
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/1810fbfe22a1202ddbd8024dde4ec10882cc3e76

The branch, master has been updated
       via  1810fbfe22a1202ddbd8024dde4ec10882cc3e76 (commit)
      from  991f657ecdcb26cd7e40ab44463f189b1e89b014 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=1810fbfe22a1202ddbd8024dde4ec10882cc3e76
commit 1810fbfe22a1202ddbd8024dde4ec10882cc3e76
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Revert "utils: file: Use fstatat and unlinkat"
    
    On may of the platforms we build for (RISC OS, Windows, Amiga OS4,
    Amiga OS3, and Atari), this was causing:
    
    - utils/file.c:329 error: 'O_DIRECTORY' undeclared
    - utils/file.c:357 error: 'AT_SYMLINK_NOFOLLOW' undeclared
    
    This reverts commit ef00567b029ec007ceab342a2ed1addaa5f63be6.

diff --git a/utils/file.c b/utils/file.c
index 3cf12d5..c460e49 100644
--- a/utils/file.c
+++ b/utils/file.c
@@ -26,7 +26,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <errno.h>
 
 #include "desktop/gui_internal.h"
@@ -323,23 +322,12 @@ netsurf_recursive_rm(const char *path)
        int nentries, ent;
        nserror ret = NSERROR_OK;
        struct stat ent_stat; /* stat result of leaf entry */
+       char *leafpath = NULL;
        const char *leafname;
-       int dirfd;
-
-       dirfd = open(path, O_DIRECTORY);
-       if (dirfd == -1) {
-               switch (errno) {
-               case ENOENT:
-                       return NSERROR_NOT_FOUND;
-               default:
-                       return NSERROR_UNKNOWN;
-               }
-       }
 
        nentries = scandir(path, &listing, 0, alphasort);
-       if (nentries < 0) {
-               close(dirfd);
 
+       if (nentries < 0) {
                switch (errno) {
                case ENOENT:
                        return NSERROR_NOT_FOUND;
@@ -353,26 +341,21 @@ netsurf_recursive_rm(const char *path)
                if (strcmp(leafname, ".") == 0 ||
                    strcmp(leafname, "..") == 0)
                        continue;
-               if (fstatat(dirfd, leafname, &ent_stat,
-                               AT_SYMLINK_NOFOLLOW) != 0) {
+               ret = netsurf_mkpath(&leafpath, NULL, 2, path, leafname);
+               if (ret != NSERROR_OK) goto out;
+               if (stat(leafpath, &ent_stat) != 0) {
                        goto out_via_errno;
                }
                if (S_ISDIR(ent_stat.st_mode)) {
-                       char *leafpath = NULL;
-
-                       ret = netsurf_mkpath(&leafpath, NULL, 2, path, 
leafname);
-                       if (ret != NSERROR_OK)
-                               goto out;
-
                        ret = netsurf_recursive_rm(leafpath);
-                       free(leafpath);
-                       if (ret != NSERROR_OK)
-                               goto out;
+                       if (ret != NSERROR_OK) goto out;
                } else {
-                       if (unlinkat(dirfd, leafname, 0) != 0) {
+                       if (unlink(leafpath) != 0) {
                                goto out_via_errno;
                        }
                }
+               free(leafpath);
+               leafpath = NULL;
        }
 
        if (rmdir(path) != 0) {
@@ -397,7 +380,9 @@ out:
                free(listing);
        }
 
-       close(dirfd);
+       if (leafpath != NULL) {
+               free(leafpath);
+       }
 
        return ret;
 }


-----------------------------------------------------------------------

Summary of changes:
 utils/file.c |   39 ++++++++++++---------------------------
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/utils/file.c b/utils/file.c
index 3cf12d5..c460e49 100644
--- a/utils/file.c
+++ b/utils/file.c
@@ -26,7 +26,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <fcntl.h>
 #include <errno.h>
 
 #include "desktop/gui_internal.h"
@@ -323,23 +322,12 @@ netsurf_recursive_rm(const char *path)
        int nentries, ent;
        nserror ret = NSERROR_OK;
        struct stat ent_stat; /* stat result of leaf entry */
+       char *leafpath = NULL;
        const char *leafname;
-       int dirfd;
-
-       dirfd = open(path, O_DIRECTORY);
-       if (dirfd == -1) {
-               switch (errno) {
-               case ENOENT:
-                       return NSERROR_NOT_FOUND;
-               default:
-                       return NSERROR_UNKNOWN;
-               }
-       }
 
        nentries = scandir(path, &listing, 0, alphasort);
-       if (nentries < 0) {
-               close(dirfd);
 
+       if (nentries < 0) {
                switch (errno) {
                case ENOENT:
                        return NSERROR_NOT_FOUND;
@@ -353,26 +341,21 @@ netsurf_recursive_rm(const char *path)
                if (strcmp(leafname, ".") == 0 ||
                    strcmp(leafname, "..") == 0)
                        continue;
-               if (fstatat(dirfd, leafname, &ent_stat,
-                               AT_SYMLINK_NOFOLLOW) != 0) {
+               ret = netsurf_mkpath(&leafpath, NULL, 2, path, leafname);
+               if (ret != NSERROR_OK) goto out;
+               if (stat(leafpath, &ent_stat) != 0) {
                        goto out_via_errno;
                }
                if (S_ISDIR(ent_stat.st_mode)) {
-                       char *leafpath = NULL;
-
-                       ret = netsurf_mkpath(&leafpath, NULL, 2, path, 
leafname);
-                       if (ret != NSERROR_OK)
-                               goto out;
-
                        ret = netsurf_recursive_rm(leafpath);
-                       free(leafpath);
-                       if (ret != NSERROR_OK)
-                               goto out;
+                       if (ret != NSERROR_OK) goto out;
                } else {
-                       if (unlinkat(dirfd, leafname, 0) != 0) {
+                       if (unlink(leafpath) != 0) {
                                goto out_via_errno;
                        }
                }
+               free(leafpath);
+               leafpath = NULL;
        }
 
        if (rmdir(path) != 0) {
@@ -397,7 +380,9 @@ out:
                free(listing);
        }
 
-       close(dirfd);
+       if (leafpath != NULL) {
+               free(leafpath);
+       }
 
        return ret;
 }


-- 
NetSurf Browser
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to