Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-projects commit in portage-utils/libq: xmkdir.c
Date: Wed, 02 Mar 2011 09:14:22
Message-Id: 20110302091412.E0E9E20054@flycatcher.gentoo.org
1 vapier 11/03/02 09:14:12
2
3 Modified: xmkdir.c
4 Log:
5 expose the recursive deleters with *at style funcs
6
7 Revision Changes Path
8 1.4 portage-utils/libq/xmkdir.c
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xmkdir.c?rev=1.4&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xmkdir.c?rev=1.4&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xmkdir.c?r1=1.3&r2=1.4
13
14 Index: xmkdir.c
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/xmkdir.c,v
17 retrieving revision 1.3
18 retrieving revision 1.4
19 diff -u -r1.3 -r1.4
20 --- xmkdir.c 2 Mar 2011 08:13:20 -0000 1.3
21 +++ xmkdir.c 2 Mar 2011 09:14:12 -0000 1.4
22 @@ -37,7 +37,7 @@
23 }
24
25 /* Emulate `rm -rf PATH` */
26 -static int _rm_rf_subdir(int dfd, const char *path)
27 +_q_static int rm_rf_at(int dfd, const char *path)
28 {
29 int subdfd;
30 DIR *dir;
31 @@ -59,7 +59,7 @@
32 if (unlinkat(subdfd, de->d_name, 0) == -1) {
33 if (errno != EISDIR)
34 errp("could not unlink %s", de->d_name);
35 - _rm_rf_subdir(subdfd, de->d_name);
36 + rm_rf_at(subdfd, de->d_name);
37 unlinkat(subdfd, de->d_name, AT_REMOVEDIR);
38 }
39 }
40 @@ -70,9 +70,9 @@
41 return 0;
42 }
43
44 -static int rm_rf(const char *path)
45 +_q_static int rm_rf(const char *path)
46 {
47 - _rm_rf_subdir(AT_FDCWD, path);
48 + rm_rf_at(AT_FDCWD, path);
49
50 if (rmdir(path) == 0)
51 return 0;
52 @@ -86,7 +86,7 @@
53 return -1;
54 }
55
56 -static int rmdir_r(const char *path)
57 +_q_static int rmdir_r_at(int dfd, const char *path)
58 {
59 size_t len;
60 char *p, *e;
61 @@ -95,7 +95,7 @@
62 e = p + len;
63
64 while (e != p) {
65 - if (rmdir(p) && errno == ENOTEMPTY)
66 + if (unlinkat(dfd, p, AT_REMOVEDIR) && errno == ENOTEMPTY)
67 break;
68 while (*e != '/' && e > p)
69 --e;
70 @@ -106,3 +106,8 @@
71
72 return 0;
73 }
74 +
75 +_q_static int rmdir_r(const char *path)
76 +{
77 + return rmdir_r_at(AT_FDCWD, path);
78 +}