changeset 13:46ad66a231af

fc-fsio: finally one can type ls -l and not just the ll abbreviation
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 03 Oct 2016 06:15:04 +0000
parents 869ce9f61a67
children 3d148edb87c2
files rvinterf/etmsync/fsbasics.c rvinterf/etmsync/fscmdtab.c rvinterf/etmsync/fsread.c
diffstat 3 files changed, 29 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/fsbasics.c	Mon Oct 03 05:54:21 2016 +0000
+++ b/rvinterf/etmsync/fsbasics.c	Mon Oct 03 06:15:04 2016 +0000
@@ -41,14 +41,14 @@
 	return(0);
 }
 
-cmd_ls(argc, argv)
-	char **argv;
+do_ls_short(lsarg)
+	char *lsarg;
 {
 	u_char state[4];
 	char namebuf[256];
 	int nument, i, rc;
 
-	rc = do_opendir(argv[1], state, &nument);
+	rc = do_opendir(lsarg, state, &nument);
 	if (rc)
 		return(rc);
 	if (!nument) {
@@ -64,6 +64,18 @@
 	return(0);
 }
 
+cmd_ls(argc, argv)
+	char **argv;
+{
+	if (argc == 2)
+		return do_ls_short(argv[1]);
+	if (strcmp(argv[1], "-l")) {
+		fprintf(stderr, "usage: ls [-l] ffs_pathname\n");
+		return(ERROR_USAGE);
+	}
+	return do_ls_long(argv[2]);
+}
+
 cmd_stat(argc, argv)
 	char **argv;
 {
--- a/rvinterf/etmsync/fscmdtab.c	Mon Oct 03 05:54:21 2016 +0000
+++ b/rvinterf/etmsync/fscmdtab.c	Mon Oct 03 06:15:04 2016 +0000
@@ -47,7 +47,7 @@
 	{"fwrite", 3, 3, cmd_fwrite},
 	{"hd", 1, 1, cmd_hd},
 	{"ll", 1, 1, cmd_ll},
-	{"ls", 1, 1, cmd_ls},
+	{"ls", 1, 2, cmd_ls},
 	{"memdump", 2, 2, cmd_memdump},
 	{"mkdir", 1, 1, cmd_mkdir},
 	{"mk-std-dirs", 0, 0, create_std_dirs},
--- a/rvinterf/etmsync/fsread.c	Mon Oct 03 05:54:21 2016 +0000
+++ b/rvinterf/etmsync/fsread.c	Mon Oct 03 06:15:04 2016 +0000
@@ -50,31 +50,31 @@
 	}
 }
 
-cmd_ll(argc, argv)
-	char **argv;
+do_ls_long(lsarg)
+	char *lsarg;
 {
 	struct stat_info stat;
 	u_char rdstate[4];
 	char rdbuf[MAX_FN_COMPONENT+1], childpath[MAX_FULL_PATHNAME+1], *childp;
 	int nument, i, rc;
 
-	if (validate_ffs_pathname(argv[1]) < 0)
+	if (validate_ffs_pathname(lsarg) < 0)
 		return(ERROR_USAGE);	/* err msg already printed */
-	rc = do_xlstat(argv[1], &stat);
+	rc = do_xlstat(lsarg, &stat);
 	if (rc)
 		return(rc);
 	if (stat.type != OT_DIR) {
-		ll_print_line(argv[1], &stat);
+		ll_print_line(lsarg, &stat);
 		return(0);
 	}
-	rc = do_opendir(argv[1], rdstate, &nument);
+	rc = do_opendir(lsarg, rdstate, &nument);
 	if (rc)
 		return(rc);
 	if (!nument) {
 		printf("<empty dir>\n");
 		return(0);
 	}
-	childp = pathname_for_ffs_child(argv[1], childpath);
+	childp = pathname_for_ffs_child(lsarg, childpath);
 	if (!childp) {
 		printf("error: non-empty dir at the limit of pathname depth\n");
 		return(ERROR_TARGET);
@@ -98,6 +98,12 @@
 	return(0);
 }
 
+cmd_ll(argc, argv)
+	char **argv;
+{
+	return do_ls_long(argv[1]);
+}
+
 void
 hexdump_line(offset, buf, len)
 	u_char *buf;