aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-07-26 13:30:40 -0500
committerRob Landley <rob@landley.net>2014-07-26 13:30:40 -0500
commitfec3fd1f8ac1db9ed87b79bd3eb5e38aa835e881 (patch)
treea7e149cf0fefef5d252706797fff8c831ebb0460 /toys
parentccb73f8bf9191c01c90975958a210c47175bd98c (diff)
downloadtoybox-fec3fd1f8ac1db9ed87b79bd3eb5e38aa835e881.tar.gz
Move DIRTREE_COMEAGAIN second callback up to when the filehandle is still open, and add dir->again variable to distinguish second call instead of checking for -1 filehandle.
Diffstat (limited to 'toys')
-rw-r--r--toys/other/lsattr.c2
-rw-r--r--toys/other/switch_root.c2
-rw-r--r--toys/posix/chgrp.c2
-rw-r--r--toys/posix/cp.c2
-rw-r--r--toys/posix/du.c4
-rw-r--r--toys/posix/rm.c4
6 files changed, 8 insertions, 8 deletions
diff --git a/toys/other/lsattr.c b/toys/other/lsattr.c
index 937ea608..39945ef0 100644
--- a/toys/other/lsattr.c
+++ b/toys/other/lsattr.c
@@ -140,7 +140,7 @@ static int retell_dir(struct dirtree *root)
{
char *fpath = NULL;
- if (root->data == -1) {
+ if (root->again) {
xputc('\n');
return 0;
}
diff --git a/toys/other/switch_root.c b/toys/other/switch_root.c
index 1dfa20de..0861c70e 100644
--- a/toys/other/switch_root.c
+++ b/toys/other/switch_root.c
@@ -32,7 +32,7 @@ static int del_node(struct dirtree *node)
if (node->st.st_dev == TT.rootdev && dirtree_notdotdot(node)) {
int flag = 0;
if (S_ISDIR(node->st.st_mode)) {
- if (node->data != -1) return DIRTREE_COMEAGAIN;
+ if (!node->again) return DIRTREE_COMEAGAIN;
flag = AT_REMOVEDIR;
}
unlinkat(dirtree_parentfd(node), node->name, flag);
diff --git a/toys/posix/chgrp.c b/toys/posix/chgrp.c
index c53ea21d..24af46ac 100644
--- a/toys/posix/chgrp.c
+++ b/toys/posix/chgrp.c
@@ -44,7 +44,7 @@ static int do_chgrp(struct dirtree *node)
// Depth first search
if (!dirtree_notdotdot(node)) return 0;
- if ((flags & FLAG_R) && node->data != -1 && S_ISDIR(node->st.st_mode))
+ if ((flags & FLAG_R) && !node->again && S_ISDIR(node->st.st_mode))
return DIRTREE_COMEAGAIN|((flags&FLAG_L) ? DIRTREE_SYMFOLLOW : 0);
fd = dirtree_parentfd(node);
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index 283ee978..aecd1870 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -84,7 +84,7 @@ int cp_node(struct dirtree *try)
if (!dirtree_notdotdot(try)) return 0;
// If returning from COMEAGAIN, jump straight to -p logic at end.
- if (S_ISDIR(try->st.st_mode) && try->data == -1) {
+ if (S_ISDIR(try->st.st_mode) && try->again) {
fdout = try->extra;
err = 0;
} else {
diff --git a/toys/posix/du.c b/toys/posix/du.c
index 2bfa7e41..22a26d3a 100644
--- a/toys/posix/du.c
+++ b/toys/posix/du.c
@@ -111,12 +111,12 @@ static int do_du(struct dirtree *node)
return 0;
// Don't count hard links twice
- if (!(toys.optflags & FLAG_l) && node->data != -1)
+ if (!(toys.optflags & FLAG_l) && !node->again)
if (seen_inode(&TT.inodes, &node->st)) return 0;
// Collect child info before printing directory size
if (S_ISDIR(node->st.st_mode)) {
- if (node->data != -1) {
+ if (!node->again) {
TT.depth++;
return DIRTREE_COMEAGAIN | (DIRTREE_SYMFOLLOW*!!(toys.optflags & FLAG_L));
} else TT.depth--;
diff --git a/toys/posix/rm.c b/toys/posix/rm.c
index 15359cb1..2f40106f 100644
--- a/toys/posix/rm.c
+++ b/toys/posix/rm.c
@@ -37,7 +37,7 @@ static int do_rm(struct dirtree *try)
// This is either the posix section 2(b) prompt or the section 3 prompt.
if (!(flags & FLAG_f)
&& (!S_ISLNK(try->st.st_mode) && faccessat(fd, try->name, W_OK, 0))) or++;
- if (!(dir && try->data == -1) && ((or && isatty(0)) || (flags & FLAG_i))) {
+ if (!(dir && try->again) && ((or && isatty(0)) || (flags & FLAG_i))) {
char *s = dirtree_path(try, 0);
fprintf(stderr, "rm %s%s", or ? "ro " : "", dir ? "dir " : "");
or = yesno(s, 0);
@@ -52,7 +52,7 @@ static int do_rm(struct dirtree *try)
if (toys.optflags & FLAG_f) wfchmodat(fd, try->name, 0600);
else goto skip;
}
- if (try->data != -1) return DIRTREE_COMEAGAIN;
+ if (!try->again) return DIRTREE_COMEAGAIN;
using = AT_REMOVEDIR;
if (try->symlink) goto skip;
if (flags & FLAG_i) {