summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-04 17:27:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-07-04 17:27:06 +0200
commitefa4d684d8927428d333f841e37adeedcfe61cfb (patch)
tree5c780a94fdfa9557da018a485d7fe884244aaf48 /commands
parent45d593bc5ec78e26e3a967517ed7a51f27c8b91f (diff)
parent10d63913999fbd5c02a2a8daecf877c24663bdca (diff)
downloadbarebox-efa4d684d8927428d333f841e37adeedcfe61cfb.tar.gz
barebox-efa4d684d8927428d333f841e37adeedcfe61cfb.tar.xz
Merge branch 'for-next/misc'
Conflicts: arch/arm/boards/chumby_falconwing/falconwing.c arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c arch/x86/mach-x86.dox scripts/setupmbr/setupmbr.c
Diffstat (limited to 'commands')
-rw-r--r--commands/boot.c2
-rw-r--r--commands/ls.c65
-rw-r--r--commands/miitool.c6
3 files changed, 43 insertions, 30 deletions
diff --git a/commands/boot.c b/commands/boot.c
index ba26cac986..3341a05ebd 100644
--- a/commands/boot.c
+++ b/commands/boot.c
@@ -151,7 +151,7 @@ static int bootscript_scan_path(struct blspec *blspec, const char *path)
glob(files, 0, NULL, &globb);
for (i = 0; i < globb.gl_pathc; i++) {
- char *bootscript_path = globb.gl_pathv[i];;
+ char *bootscript_path = globb.gl_pathv[i];
if (*basename(bootscript_path) == '.')
continue;
diff --git a/commands/ls.c b/commands/ls.c
index 344079030a..1a5925d427 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -53,6 +53,8 @@ int ls(const char *path, ulong flags)
char tmp[PATH_MAX];
struct stat s;
struct string_list sl;
+ struct string_list *entry;
+ int ret;
string_list_init(&sl);
@@ -71,51 +73,51 @@ int ls(const char *path, ulong flags)
if (!dir)
return -errno;
- while ((d = readdir(dir))) {
- sprintf(tmp, "%s/%s", path, d->d_name);
- if (flags & LS_COLUMN) {
- string_list_add_sorted(&sl, d->d_name);
- } else {
- if (lstat(tmp, &s))
- goto out;
- ls_one(d->d_name, tmp, &s);
- }
- }
+ while ((d = readdir(dir)))
+ string_list_add_sorted(&sl, d->d_name);
closedir(dir);
if (flags & LS_COLUMN) {
string_list_print_by_column(&sl);
- string_list_free(&sl);
- }
-
- if (!(flags & LS_RECURSIVE))
- return 0;
+ } else {
+ string_list_for_each_entry(entry, &sl) {
+ sprintf(tmp, "%s/%s", path, entry->str);
+ ret = lstat(tmp, &s);
+ if (ret) {
+ printf("%s: %s\n", tmp, strerror(-ret));
+ continue;
+ }
- dir = opendir(path);
- if (!dir) {
- errno = ENOENT;
- return -ENOENT;
+ ls_one(entry->str, tmp, &s);
+ }
}
- while ((d = readdir(dir))) {
+ if (!(flags & LS_RECURSIVE))
+ goto out;
- if (!strcmp(d->d_name, "."))
+ string_list_for_each_entry(entry, &sl) {
+ if (!strcmp(entry->str, "."))
+ continue;
+ if (!strcmp(entry->str, ".."))
continue;
- if (!strcmp(d->d_name, ".."))
+ sprintf(tmp, "%s/%s", path, entry->str);
+
+ ret = lstat(tmp, &s);
+ if (ret) {
+ printf("%s: %s\n", tmp, strerror(-ret));
continue;
- sprintf(tmp, "%s/%s", path, d->d_name);
+ }
- if (lstat(tmp, &s))
- goto out;
if (s.st_mode & S_IFDIR) {
char *norm = normalise_path(tmp);
ls(norm, flags);
free(norm);
}
}
+
out:
- closedir(dir);
+ string_list_free(&sl);
return 0;
}
@@ -127,6 +129,9 @@ static int do_ls(int argc, char *argv[])
ulong flags = LS_COLUMN;
struct string_list sl;
+ if (!strcmp(argv[0], "ll"))
+ flags &= ~LS_COLUMN;
+
while((opt = getopt(argc, argv, "RCl")) > 0) {
switch(opt) {
case 'R':
@@ -219,3 +224,11 @@ BAREBOX_CMD_START(ls)
BAREBOX_CMD_GROUP(CMD_GRP_FILE)
BAREBOX_CMD_HELP(cmd_ls_help)
BAREBOX_CMD_END
+
+BAREBOX_CMD_START(ll)
+ .cmd = do_ls,
+ BAREBOX_CMD_DESC("list a file or directory with details")
+ BAREBOX_CMD_OPTS("[-lCR] [FILEDIR...]")
+ BAREBOX_CMD_GROUP(CMD_GRP_FILE)
+ BAREBOX_CMD_HELP(cmd_ls_help)
+BAREBOX_CMD_END
diff --git a/commands/miitool.c b/commands/miitool.c
index 40e34e93cc..c62e7588a8 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -115,14 +115,14 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev,
for (i = 0; i < 32; i++)
mii_val[i] = mii->read(mii, phydev->addr, i);
+ printf("%s: %s%d: ", phydev->cdev.name,
+ mii->parent->name, mii->parent->id);
+
if (mii_val[MII_BMCR] == 0xffff || mii_val[MII_BMSR] == 0x0000) {
fprintf(stderr, " No MII transceiver present!.\n");
return -1;
}
- printf("%s: %s%d: ", phydev->cdev.name,
- mii->parent->name, mii->parent->id);
-
/* Descriptive rename. */
bmcr = mii_val[MII_BMCR];
bmsr = mii_val[MII_BMSR];