.I \-b
options.
.TP
-.I ls [-l] [-d] filespec
+.I ls [-l] [-d] [-p] filespec
Print a listing of the files in the directory
.IR filespec .
The
The
.I \-d
flag will list deleted entries in the directory.
+The
+.I \-p
+flag will list the files in a format which is more easily parsable by
+scripts, as well as making it more clear when there are spaces or other
+non-prinitng characters at the end of filenames.
.TP
.I modify_inode filespec
Modify the contents of the inode structure in the inode
#define LONG_OPT 0x0001
#define DELETED_OPT 0x0002
+#define PARSE_OPT 0x0004
struct list_dir_struct {
FILE *f;
} else {
lbr = rbr = ' ';
}
- if (ls->options & LONG_OPT) {
+ if (ls->options & PARSE_OPT) {
+ if (ino && debugfs_read_inode(ino, &inode, name)) return 0;
+ fprintf(ls->f,"/%u/%06o/%d/%d/%s/",ino,inode.i_mode,inode.i_uid, inode.i_gid,name);
+ if (LINUX_S_ISDIR(inode.i_mode))
+ fprintf(ls->f, "/");
+ else
+ fprintf(ls->f, "%lld/", inode.i_size | ((__u64)inode.i_size_high << 32));
+ fprintf(ls->f, "\n");
+ }
+ else if (ls->options & LONG_OPT) {
if (ino) {
if (debugfs_read_inode(ino, &inode, name))
return 0;
return;
reset_getopt();
- while ((c = getopt (argc, argv, "dl")) != EOF) {
+ while ((c = getopt (argc, argv, "dlp")) != EOF) {
switch (c) {
case 'l':
ls.options |= LONG_OPT;
case 'd':
ls.options |= DELETED_OPT;
break;
+ case 'p':
+ ls.options |= PARSE_OPT;
+ break;
default:
goto print_usage;
}
if (argc > optind+1) {
print_usage:
- com_err(0, 0, "Usage: ls [-l] [-d] file");
+ com_err(0, 0, "Usage: ls [-l] [-d] [-p] file");
return;
}