From f10748d88cb9b79e1f1a41a12a3e4f411f2494c7 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 31 Dec 2000 13:55:14 +0000 Subject: [PATCH] ChangeLog, lsattr.c: lsattr.c (list_attributes): Minor cleanup to smooth out logic flow. Also removed static initialized variables to zero. ChangeLog, lsattr.1.in: lsattr.1.in: Add pointer to chattr man page for definition of the file attributes. --- misc/ChangeLog | 6 ++++++ misc/lsattr.1.in | 4 +++- misc/lsattr.c | 45 ++++++++++++++++++++++++--------------------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/misc/ChangeLog b/misc/ChangeLog index 5d5e0c25..d11fd8cd 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,5 +1,11 @@ 2000-12-31 + * lsattr.1.in: Add pointer to chattr man page for definition of + the file attributes. + + * lsattr.c (list_attributes): Minor cleanup to smooth out logic + flow. Also removed static initialized variables to zero. + * chattr.c (decode_arg, get_flag): Use a table-driven method for decoding the ext2 file flags character options. Add support for the journaled data flag. diff --git a/misc/lsattr.1.in b/misc/lsattr.1.in index 4b6877c2..4de54c9e 100644 --- a/misc/lsattr.1.in +++ b/misc/lsattr.1.in @@ -12,7 +12,9 @@ lsattr \- list file attributes on a Linux second extended file system ] .SH DESCRIPTION .B lsattr -lists the file attributes on a second extended file system. +lists the file attributes on a second extended file system. See +.BR chattr (1) +for a description of the attributes and what they mean. .SH OPTIONS .TP .B \-R diff --git a/misc/lsattr.c b/misc/lsattr.c index 9b9dc54a..857c4818 100644 --- a/misc/lsattr.c +++ b/misc/lsattr.c @@ -45,12 +45,12 @@ extern char *optarg; static const char * program_name = "lsattr"; -static int all = 0; -static int dirs_opt = 0; -static unsigned pf_options = 0; -static int recursive = 0; -static int verbose = 0; -static int generation_opt = 0; +static int all; +static int dirs_opt; +static unsigned pf_options; +static int recursive; +static int verbose; +static int generation_opt; static void usage(void) { @@ -63,24 +63,27 @@ static void list_attributes (const char * name) unsigned long flags; unsigned long generation; - if (fgetflags (name, &flags) == -1) + if (fgetflags (name, &flags) == -1) { com_err (program_name, errno, _("While reading flags on %s"), name); - else if (fgetversion (name, &generation) == -1) - com_err (program_name, errno, _("While reading version on %s"), - name); - else - { - if (generation_opt) - printf ("%5lu ", generation); - if (pf_options & PFOPT_LONG) { - printf("%-28s ", name); - print_flags(stdout, flags, pf_options); - fputc('\n', stdout); - } else { - print_flags(stdout, flags, pf_options); - printf(" %s\n", name); + return; + } + if (generation_opt) { + if (fgetversion (name, &generation) == -1) { + com_err (program_name, errno, + _("While reading version on %s"), + name); + return; } + printf ("%5lu ", generation); + } + if (pf_options & PFOPT_LONG) { + printf("%-28s ", name); + print_flags(stdout, flags, pf_options); + fputc('\n', stdout); + } else { + print_flags(stdout, flags, pf_options); + printf(" %s\n", name); } }