Whamcloud - gitweb
ChangeLog, chattr.1.in, chattr.c, lsattr.1.in, lsattr.c:
authorTheodore Ts'o <tytso@mit.edu>
Tue, 5 Jan 1999 07:02:39 +0000 (07:02 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 5 Jan 1999 07:02:39 +0000 (07:02 +0000)
  chattr.c, lsattr.c: Only print the version information for the program
   if the -V option is given.
  chattr.c: Ignore symbolic links when doing a recursive descent through
   a directory.

misc/ChangeLog
misc/chattr.1.in
misc/chattr.c
misc/lsattr.1.in
misc/lsattr.c

index b8701d3..b8becd7 100644 (file)
@@ -1,3 +1,11 @@
+1999-01-05  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * chattr.c, lsattr.c: Only print the version information for the
+               program if the -V option is given.
+
+       * chattr.c: Ignore symbolic links when doing a recursive descent
+               through a directory.
+
 1999-01-01  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * fsck.c (load_fs_info, parse_fstab_line): Ignore fstab lines
index 32b4bf5..5200cda 100644 (file)
@@ -33,9 +33,11 @@ secure deletion (s), and undeletable (u).
 .TP
 .I -R
 Recursively change attributes of directories and their contents.
+Symbolic links encountered during recursive directory traversals are
+ignored.
 .TP
 .I -V
-Verbosely describe changed attributes.
+Be verbose with chattr's output and print the program version.
 .TP
 .I -v version
 Set the files version.
index c8c9245..848c1d5 100644 (file)
@@ -14,6 +14,8 @@
  * 93/10/30    - Creation
  * 93/11/13    - Replace stat() calls by lstat() to avoid loops
  * 94/02/27    - Integrated in Ted's distribution
+ * 98/12/29    - Ignore symlinks when working recursively (G M Sipe)
+ * 98/12/29    - Display version info only when -V specified (G M Sipe)
  */
 
 #include <sys/types.h>
@@ -237,6 +239,8 @@ static void change_attributes (const char * name)
                com_err (program_name, errno, "while stating %s", name);
                return;
        }
+       if (S_ISLNK(st.st_mode) && recursive)
+               return;
        if (set)
        {
                if (verbose)
@@ -304,9 +308,6 @@ int main (int argc, char ** argv)
        int i, j;
        int end_arg = 0;
 
-       fprintf (stderr, "chattr %s, %s for EXT2 FS %s, %s\n",
-                E2FSPROGS_VERSION, E2FSPROGS_DATE,
-                EXT2FS_VERSION, EXT2FS_DATE);
        if (argc && *argv)
                program_name = *argv;
        i = 1;
@@ -329,6 +330,10 @@ int main (int argc, char ** argv)
                fprintf (stderr, "Must use '-v', =, - or +\n");
                exit (1);
        }
+       if (verbose)
+               fprintf (stderr, "chattr %s, %s for EXT2 FS %s, %s\n",
+                        E2FSPROGS_VERSION, E2FSPROGS_DATE,
+                        EXT2FS_VERSION, EXT2FS_DATE);
        for (j = i; j < argc; j++)
                change_attributes (argv[j]);
        exit(0);
index 03c159d..f5b683a 100644 (file)
@@ -5,7 +5,7 @@ lsattr \- list file attributes on a Linux second extended file system
 .SH SYNOPSIS
 .B lsattr
 [
-.B \-Radv
+.B \-RVadv
 ]
 [
 files...
@@ -18,6 +18,9 @@ lists the file attributes on a second extended file system.
 .I -R
 Recursively list attributes of directories and their contents.
 .TP
+.I -V
+Display the program version.
+.TP
 .I -a
 List all files in directories, including files that start with `.'.
 .TP
index 73823cc..afc882c 100644 (file)
@@ -14,6 +14,7 @@
  * 93/10/30    - Creation
  * 93/11/13    - Replace stat() calls by lstat() to avoid loops
  * 94/02/27    - Integrated in Ted's distribution
+ * 98/12/29    - Display version info only when -V specified (G M Sipe)
  */
 
 #include <sys/types.h>
@@ -47,11 +48,12 @@ int all = 0;
 int d_opt = 0;
 int l_opt = 0;
 int recursive = 0;
+int verbose = 0;
 int v_opt = 0;
 
 static void usage(void)
 {
-       fprintf(stderr, "Usage: %s [-Radlv] [files...]\n", program_name);
+       fprintf(stderr, "Usage: %s [-RVadlv] [files...]\n", program_name);
        exit(1);
 }
 
@@ -124,17 +126,17 @@ int main (int argc, char ** argv)
        int c;
        int i;
 
-       fprintf (stderr, "lsattr %s, %s for EXT2 FS %s, %s\n",
-                E2FSPROGS_VERSION, E2FSPROGS_DATE,
-                EXT2FS_VERSION, EXT2FS_DATE);
        if (argc && *argv)
                program_name = *argv;
-       while ((c = getopt (argc, argv, "Radlv")) != EOF)
+       while ((c = getopt (argc, argv, "RVadlv")) != EOF)
                switch (c)
                {
                        case 'R':
                                recursive = 1;
                                break;
+                       case 'V':
+                               verbose = 1;
+                               break;
                        case 'a':
                                all = 1;
                                break;
@@ -151,6 +153,10 @@ int main (int argc, char ** argv)
                                usage();
                }
 
+       if (verbose)
+               fprintf (stderr, "lsattr %s, %s for EXT2 FS %s, %s\n",
+                        E2FSPROGS_VERSION, E2FSPROGS_DATE,
+                        EXT2FS_VERSION, EXT2FS_DATE);
        if (optind > argc - 1)
                lsattr_args (".");
        else