aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-11-21 16:47:23 -0600
committerRob Landley <rob@landley.net>2016-11-21 16:47:23 -0600
commit382057f588fbf2c2f7950b85dd317721b8d04c07 (patch)
treeba6b074d5c956f2f5747e27ce0f8ab948a0a602c /toys/other
parent9b4a67545e11975068d6e16c6872d54e0473e715 (diff)
downloadtoybox-382057f588fbf2c2f7950b85dd317721b8d04c07.tar.gz
Have dirtree_notdotdot() pass through !node->parent so . and .. on the command
line aren't filtered out. Audited all the callers and removed redundant calls, adjusted call sequence, etc. (And let rm _not_ do this, because posix.)
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/hwclock.c6
-rw-r--r--toys/other/lsusb.c2
-rw-r--r--toys/other/modinfo.c6
3 files changed, 8 insertions, 6 deletions
diff --git a/toys/other/hwclock.c b/toys/other/hwclock.c
index 75e06416..1d313e3b 100644
--- a/toys/other/hwclock.c
+++ b/toys/other/hwclock.c
@@ -37,14 +37,14 @@ static int rtc_find(struct dirtree* node)
if (!node->parent) return DIRTREE_RECURSE;
- snprintf(toybuf, sizeof(toybuf), "/sys/class/rtc/%s/hctosys", node->name);
+ sprintf(toybuf, "/sys/class/rtc/%s/hctosys", node->name);
fp = fopen(toybuf, "r");
if (fp) {
int hctosys = 0, items = fscanf(fp, "%d", &hctosys);
fclose(fp);
if (items == 1 && hctosys == 1) {
- snprintf(toybuf, sizeof(toybuf), "/dev/%s", node->name);
+ sprintf(toybuf, "/dev/%s", node->name);
TT.fname = toybuf;
return DIRTREE_ABORT;
@@ -105,7 +105,7 @@ void hwclock_main()
}
if (toys.optflags & FLAG_w) {
- /* The value of tm_isdst will positive if daylight saving time is in effect,
+ /* The value of tm_isdst is positive if daylight saving time is in effect,
* zero if it is not and negative if the information is not available.
* todo: so why isn't this negative...? */
tm.tm_isdst = 0;
diff --git a/toys/other/lsusb.c b/toys/other/lsusb.c
index 07886e8c..031dbd93 100644
--- a/toys/other/lsusb.c
+++ b/toys/other/lsusb.c
@@ -24,7 +24,7 @@ static int list_device(struct dirtree *new)
if (!new->parent) return DIRTREE_RECURSE;
if (new->name[0] == '.') return 0;
name = dirtree_path(new, 0);
- snprintf(toybuf, sizeof(toybuf), "%s/%s", name, "/uevent");
+ sprintf(toybuf, "%s/uevent", name);
file = fopen(toybuf, "r");
if (file) {
int count = 0;
diff --git a/toys/other/modinfo.c b/toys/other/modinfo.c
index 61155b46..69cdf27e 100644
--- a/toys/other/modinfo.c
+++ b/toys/other/modinfo.c
@@ -74,6 +74,8 @@ static void modinfo_file(char *full_name)
static int check_module(struct dirtree *new)
{
+ if (!dirtree_notdotdot(new)) return 0;
+
if (S_ISREG(new->st.st_mode)) {
char *s;
@@ -88,14 +90,14 @@ static int check_module(struct dirtree *new)
}
if (s[len] || strcmp(new->name+len, ".ko")) break;
- modinfo_file(s = dirtree_path(new, NULL));
+ modinfo_file(s = dirtree_path(new, 0));
free(s);
return DIRTREE_ABORT;
}
}
- return dirtree_notdotdot(new);
+ return DIRTREE_RECURSE;
}
void modinfo_main(void)