diff options
Diffstat (limited to 'toys')
-rw-r--r-- | toys/pending/diff.c | 2 | ||||
-rw-r--r-- | toys/pending/tar.c | 2 | ||||
-rw-r--r-- | toys/posix/chgrp.c | 4 | ||||
-rw-r--r-- | toys/posix/cp.c | 7 | ||||
-rw-r--r-- | toys/posix/du.c | 2 | ||||
-rw-r--r-- | toys/posix/find.c | 2 | ||||
-rw-r--r-- | toys/posix/ls.c | 11 |
7 files changed, 16 insertions, 14 deletions
diff --git a/toys/pending/diff.c b/toys/pending/diff.c index 80238614..da6c13a0 100644 --- a/toys/pending/diff.c +++ b/toys/pending/diff.c @@ -798,7 +798,7 @@ void diff_main(void) if (S_ISDIR(st[0].st_mode) && S_ISDIR(st[1].st_mode)) { for (j = 0; j < 2; j++) { memset(&dir[j], 0, sizeof(dir)); - dirtree_handle_callback(dirtree_start(files[j], 1), list_dir); + dirtree_flagread(files[j], DIRTREE_SYMFOLLOW, list_dir); dir[j].nr_elm = TT.size; //size updated in list_dir qsort(&(dir[j].list[1]), (TT.size - 1), sizeof(char*), cmp); diff --git a/toys/pending/tar.c b/toys/pending/tar.c index c5043087..384199ea 100644 --- a/toys/pending/tar.c +++ b/toys/pending/tar.c @@ -788,7 +788,7 @@ void tar_main(void) for (tmp = TT.inc; tmp; tmp = tmp->next) { TT.handle = tar_hdl; //recurse thru dir and add files to archive - dirtree_handle_callback(dirtree_start(tmp->arg, toys.optflags & FLAG_h), + dirtree_flagread(tmp->arg, DIRTREE_SYMFOLLOW*!!(toys.optflags&FLAG_h), add_to_tar); } memset(toybuf, 0, 1024); diff --git a/toys/posix/chgrp.c b/toys/posix/chgrp.c index 6b95c6ad..e0690c93 100644 --- a/toys/posix/chgrp.c +++ b/toys/posix/chgrp.c @@ -94,8 +94,8 @@ void chgrp_main(void) TT.group = xgetgrnamid(TT.group_name)->gr_gid; for (s=toys.optargs+1; *s; s++) - dirtree_handle_callback(dirtree_start(*s, toys.optflags&(FLAG_H|FLAG_L)), - do_chgrp);; + dirtree_flagread(*s, DIRTREE_SYMFOLLOW*!!(toys.optflags&(FLAG_H|FLAG_L)), + do_chgrp); if (CFG_TOYBOX_FREE && ischown) free(own); } diff --git a/toys/posix/cp.c b/toys/posix/cp.c index cb7e6e3b..0e6a2efa 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -430,12 +430,11 @@ void cp_main(void) if (rc) rc = rename(src, TT.destname); } - // Skip nonexistent sources + // Copy if we didn't mv, skipping nonexistent sources if (rc) { - if (errno!=EXDEV || - !(new = dirtree_start(src, toys.optflags&(FLAG_H|FLAG_L)))) + if (errno!=EXDEV || dirtree_flagread(src, DIRTREE_SHUTUP+ + DIRTREE_SYMFOLLOW*!!(toys.optflags&(FLAG_H|FLAG_L)), TT.callback)) perror_msg("bad '%s'", src); - else dirtree_handle_callback(new, TT.callback); } if (destdir) free(TT.destname); } diff --git a/toys/posix/du.c b/toys/posix/du.c index 77c7b6e2..2797b3f4 100644 --- a/toys/posix/du.c +++ b/toys/posix/du.c @@ -153,7 +153,7 @@ void du_main(void) // Loop over command line arguments, recursing through children for (args = toys.optc ? toys.optargs : noargs; *args; args++) - dirtree_handle_callback(dirtree_start(*args, toys.optflags&(FLAG_H|FLAG_L)), + dirtree_flagread(*args, DIRTREE_SYMFOLLOW*!!(toys.optflags&(FLAG_H|FLAG_L)), do_du); if (toys.optflags & FLAG_c) print(TT.total*512, 0); diff --git a/toys/posix/find.c b/toys/posix/find.c index a9c35f41..303aada2 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -556,7 +556,7 @@ void find_main(void) // Loop through paths for (i = 0; i < len; i++) - dirtree_handle_callback(dirtree_start(ss[i], toys.optflags&(FLAG_H|FLAG_L)), + dirtree_flagread(ss[i], DIRTREE_SYMFOLLOW*!!(toys.optflags&(FLAG_H|FLAG_L)), do_find); execdir(0, 1); diff --git a/toys/posix/ls.c b/toys/posix/ls.c index 4dcbe888..799631b1 100644 --- a/toys/posix/ls.c +++ b/toys/posix/ls.c @@ -540,12 +540,15 @@ void ls_main(void) if (toys.optflags & FLAG_d) toys.optflags &= ~FLAG_R; // Iterate through command line arguments, collecting directories and files. - // Non-absolute paths are relative to current directory. - TT.files = dirtree_start(0, 0); + // Non-absolute paths are relative to current directory. Top of tree is + // a dummy node to collect command line arguments into pseudo-directory. + TT.files = dirtree_add_node(0, 0, 0); TT.files->dirfd = AT_FDCWD; for (s = *toys.optargs ? toys.optargs : noargs; *s; s++) { - dt = dirtree_start(*s, !(toys.optflags&(FLAG_l|FLAG_d|FLAG_F)) || - (toys.optflags&(FLAG_L|FLAG_H))); + int sym = !(toys.optflags&(FLAG_l|FLAG_d|FLAG_F)) + || (toys.optflags&(FLAG_L|FLAG_H)); + + dt = dirtree_add_node(0, *s, DIRTREE_SYMFOLLOW*sym); // note: double_list->prev temporarirly goes in dirtree->parent if (dt) dlist_add_nomalloc((void *)&TT.files->child, (void *)dt); |