[pacman-dev] _alpm_rmrf is not the same as rm -rf
Hi! _alpm_rmrf deletes only regular files and directories recursively. See line 316: 'if (S_ISREG(st.st_mode))' should be 'if (!S_ISDIR(st.st_mode))' or at least 'if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))' (<- I need this, because I started to implement my speed up ideas .-) Bye, Nagy Gabor
On 3/8/07, Nagy Gabor <ngaba@petra.hos.u-szeged.hu> wrote:
Hi!
_alpm_rmrf deletes only regular files and directories recursively. See line 316: 'if (S_ISREG(st.st_mode))' should be 'if (!S_ISDIR(st.st_mode))' or at least 'if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))' (<- I need this, because I started to implement my speed up ideas .-)
Please read 'submitting-patches' in the CVS root directory.
--- util.c.old 2007-03-14 17:56:40.000000000 +0100 +++ util.c 2007-03-14 18:03:00.000000000 +0100 @@ -310,21 +310,20 @@ struct dirent *dp; DIR *dirp; char name[PATH_MAX]; - struct stat st; + struct stat st; - if(stat(path, &st) == 0) { - if(S_ISREG(st.st_mode)) { + if(lstat(path, &st) == 0) { + if(!S_ISDIR(st.st_mode)) { if(!unlink(path)) { return(0); } else { if(errno == ENOENT) { return(0); } else { - /* not a directory */ return(1); } } - } else if(S_ISDIR(st.st_mode)) { + } else { if((dirp = opendir(path)) == (DIR *)-1) { return(1); } ------------------------------------ A note: some functions can be removed from pacman/util.c because the "same" function exists in alpm/util.c (such as rmrf, makepath). Bye, Nagy Gabor
On 3/14/07, Nagy Gabor <ngaba@petra.hos.u-szeged.hu> wrote:
--- util.c.old 2007-03-14 17:56:40.000000000 +0100 +++ util.c 2007-03-14 18:03:00.000000000 +0100
Which util.c file is this? Can you please diff at the top level (the submitting-patches file suggests submitting -p1 applicable patches)?
Which util.c file is this? Can you please diff at the top level (the submitting-patches file suggests submitting -p1 applicable patches)?
OK. (This is the lib/libalpm/util.c file)
On 3/14/07, Nagy Gabor <ngaba@petra.hos.u-szeged.hu> wrote:
Which util.c file is this? Can you please diff at the top level (the submitting-patches file suggests submitting -p1 applicable patches)?
OK. (This is the lib/libalpm/util.c file)
Thanks! I'll review this a bit more later, and most likely apply it tonight (unless Dan gets to it before I do).
participants (2)
-
Aaron Griffin
-
Nagy Gabor