Whamcloud - gitweb
Many files:
authorTheodore Ts'o <tytso@mit.edu>
Fri, 11 Feb 2000 05:00:19 +0000 (05:00 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 11 Feb 2000 05:00:19 +0000 (05:00 +0000)
  chattr.1.in:
  lsattr.1.in: Change "version" to "version/generation number".
  chattr.1.in: Fix stupid file vs filesystem typo.
  tune2fs.c Fix spelling error (spare vs sparse).
  mke2fs.c (PRS): Add safety check to make sure the number of blocks
   doesn't exceed 32 bits on a 64 bit machine.
  chattr.c: Random cleanup; file-only variables are now static.  Options
   for setting/clearings flags put into order, and #ifdef's removed
   (since we now use a built-in header file).  Add error message if user
   tries to set and reset the same flag.
  lsattr.c: Random cleanup; file-only variables are now static.  The -l
   "long" listing has been changed to look nicer.  Options names have
   been renamed to be more descriptive.

misc/ChangeLog
misc/chattr.1.in
misc/chattr.c
misc/lsattr.1.in
misc/lsattr.c
misc/mke2fs.c
misc/tune2fs.8.in
misc/tune2fs.c

index 4a21277..5bcc601 100644 (file)
@@ -1,3 +1,25 @@
+2000-02-09  Theodore Ts'o  <tytso@valinux.com>
+
+       * chattr.1.in: 
+       * lsattr.1.in: Change "version" to "version/generation number".
+
+       * chattr.1.in: Fix stupid file vs filesystem typo.
+
+       * tune2fs.c Fix spelling error (spare vs sparse).
+
+       * mke2fs.c (PRS): Add safety check to make sure the number of
+               blocks doesn't exceed 32 bits on a 64 bit machine.
+
+       * chattr.c: Random cleanup; file-only variables are now static.
+               Options for setting/clearings flags put into order, and
+               #ifdef's removed (since we now use a built-in header
+               file).  Add error message if user tries to set and reset
+               the same flag.
+
+       * lsattr.c: Random cleanup; file-only variables are now static.
+               The -l "long" listing has been changed to look nicer.
+               Options names have been renamed to be more descriptive.
+       
 2000-02-06  Theodore Ts'o  <tytso@valinux.com>
 
        * badblocks.c, chattr.c, dumpe2fs.c, e2label.c, findsuper.c,
index 90e58ab..376cf81 100644 (file)
@@ -40,7 +40,7 @@ ignored.
 Be verbose with chattr's output and print the program version.
 .TP
 .BI \-v " version"
-Set the filesystem version.
+Set the file's version/generation number.
 .SH ATTRIBUTES
 When a file with the 'A' attribute set is modified, its atime record is
 not modified.  This avoids a certain amount of disk I/O for laptop
index fd5210a..80b2d36 100644 (file)
 #include "../version.h"
 #include "nls-enable.h"
 
-const char * program_name = "chattr";
+static const char * program_name = "chattr";
 
-int add = 0;
-int rem = 0;
-int set = 0;
-int set_version = 0;
+static int add = 0;
+static int rem = 0;
+static int set = 0;
+static int set_version = 0;
 
-unsigned long version;
+static unsigned long version;
 
-int recursive = 0;
-int verbose = 0;
+static int recursive = 0;
+static int verbose = 0;
 
-unsigned long af;
-unsigned long rf;
-unsigned long sf;
+static unsigned long af;
+static unsigned long rf;
+static unsigned long sf;
 
 static void fatal_error(const char * fmt_string, int errcode)
 {
@@ -82,6 +82,10 @@ static int decode_arg (int * i, int argc, char ** argv)
                for (p = &argv[*i][1]; *p; p++)
                        switch (*p)
                        {
+                       case 'A':
+                               rf |= EXT2_NOATIME_FL;
+                               rem = 1;
+                               break;
                        case 'R':
                                recursive = 1;
                                break;
@@ -92,34 +96,22 @@ static int decode_arg (int * i, int argc, char ** argv)
                        case 'V':
                                verbose = 1;
                                break;
-#ifdef EXT2_APPEND_FL
                        case 'a':
                                rf |= EXT2_APPEND_FL;
                                rem = 1;
                                break;
-#endif
-#ifdef EXT2_NOATIME_FL
-                       case 'A':
-                               rf |= EXT2_NOATIME_FL;
-                               rem = 1;
-                               break;
-#endif
                        case 'c':
                                rf |= EXT2_COMPR_FL;
                                rem = 1;
                                break;
-#ifdef EXT2_NODUMP_FL
                        case 'd':
                                rf |= EXT2_NODUMP_FL;
                                rem = 1;
                                break;
-#endif
-#ifdef EXT2_IMMUTABLE_FL
                        case 'i':
                                rf |= EXT2_IMMUTABLE_FL;
                                rem = 1;
                                break;
-#endif
                        case 's':
                                rf |= EXT2_SECRM_FL;
                                rem = 1;
@@ -152,32 +144,24 @@ static int decode_arg (int * i, int argc, char ** argv)
                for (p = &argv[*i][1]; *p; p++)
                        switch (*p)
                        {
+                       case 'A':
+                               af |= EXT2_NOATIME_FL;
+                               break;
                        case 'S':
                                af |= EXT2_SYNC_FL;
                                break;
-#ifdef EXT2_APPEND_FL
                        case 'a':
                                af |= EXT2_APPEND_FL;
                                break;
-#endif
-#ifdef EXT2_NOATIME_FL
-                       case 'A':
-                               af |= EXT2_NOATIME_FL;
-                               break;
-#endif
                        case 'c':
                                af |= EXT2_COMPR_FL;
                                break;
-#ifdef EXT2_NODUMP_FL
                        case 'd':
                                af |= EXT2_NODUMP_FL;
                                break;
-#endif
-#ifdef EXT2_IMMUTABLE_FL
                        case 'i':
                                af |= EXT2_IMMUTABLE_FL;
                                break;
-#endif
                        case 's':
                                af |= EXT2_SECRM_FL;
                                break;
@@ -193,32 +177,24 @@ static int decode_arg (int * i, int argc, char ** argv)
                for (p = &argv[*i][1]; *p; p++)
                        switch (*p)
                        {
+                       case 'A':
+                               sf |= EXT2_NOATIME_FL;
+                               break;
                        case 'S':
                                sf |= EXT2_SYNC_FL;
                                break;
-#ifdef EXT2_APPEND_FL
                        case 'a':
                                sf |= EXT2_APPEND_FL;
                                break;
-#endif
-#ifdef EXT2_NOATIME_FL
-                       case 'A':
-                               sf |= EXT2_NOATIME_FL;
-                               break;
-#endif
                        case 'c':
                                sf |= EXT2_COMPR_FL;
                                break;
-#ifdef EXT2_NODUMP_FL
                        case 'd':
                                sf |= EXT2_NODUMP_FL;
                                break;
-#endif
-#ifdef EXT2_IMMUTABLE_FL
                        case 'i':
                                sf |= EXT2_IMMUTABLE_FL;
                                break;
-#endif
                        case 's':
                                sf |= EXT2_SECRM_FL;
                                break;
@@ -243,37 +219,40 @@ static void change_attributes (const char * name)
        unsigned long flags;
        struct stat st;
 
-       if (lstat (name, &st) == -1)
-       {
-               com_err (program_name, errno, _("while stating %s"), name);
+       if (lstat (name, &st) == -1) {
+               com_err (program_name, errno, _("while trying to stat %s"), 
+                        name);
                return;
        }
        if (S_ISLNK(st.st_mode) && recursive)
                return;
-       if (set)
-       {
-               if (verbose)
-               {
+
+       /* Don't try to open device files, fifos etc.  We probably
+           ought to display an error if the file was explicitly given
+           on the command line (whether or not recursive was
+           requested).  */
+       if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode) &&
+           !S_ISDIR(st.st_mode))
+               return;
+
+       if (set) {
+               if (verbose) {
                        printf (_("Flags of %s set as "), name);
                        print_flags (stdout, sf, 0);
                        printf ("\n");
                }
                if (fsetflags (name, sf) == -1)
                        perror (name);
-       }
-       else
-       {
+       } else {
                if (fgetflags (name, &flags) == -1)
                        com_err (program_name, errno,
                                 _("while reading flags on %s"), name);
-               else
-               {
+               else {
                        if (rem)
                                flags &= ~rf;
                        if (add)
                                flags |= af;
-                       if (verbose)
-                       {
+                       if (verbose) {
                                printf (_("Flags of %s set as "), name);
                                print_flags (stdout, flags, 0);
                                printf ("\n");
@@ -283,8 +262,7 @@ static void change_attributes (const char * name)
                                         _("while setting flags on %s"), name);
                }
        }
-       if (set_version)
-       {
+       if (set_version) {
                if (verbose)
                        printf (_("Version of %s set as %lu\n"), name, version);
                if (fsetversion (name, version) == -1)
@@ -292,13 +270,13 @@ static void change_attributes (const char * name)
                                 _("while setting version on %s"), name);
        }
        if (S_ISDIR(st.st_mode) && recursive)
-               iterate_on_dir (name, chattr_dir_proc, (void *) NULL);
+               iterate_on_dir (name, chattr_dir_proc, NULL);
 }
 
-static int chattr_dir_proc (const char * dir_name, struct dirent * de, void * private)
+static int chattr_dir_proc (const char * dir_name, struct dirent * de,
+                           void * unused_private)
 {
-       if (strcmp (de->d_name, ".") && strcmp (de->d_name, ".."))
-       {
+       if (strcmp (de->d_name, ".") && strcmp (de->d_name, "..")) {
                char *path;
 
                path = malloc(strlen (dir_name) + 1 + strlen (de->d_name) + 1);
@@ -325,8 +303,7 @@ int main (int argc, char ** argv)
        if (argc && *argv)
                program_name = *argv;
        i = 1;
-       while (i < argc && !end_arg)
-       {
+       while (i < argc && !end_arg) {
                if (decode_arg (&i, argc, argv) == EOF)
                        end_arg = 1;
                else
@@ -334,13 +311,15 @@ int main (int argc, char ** argv)
        }
        if (i >= argc)
                usage ();
-       if (set && (add || rem))
-       {
+       if (set && (add || rem)) {
                fprintf (stderr, _("= is incompatible with - and +\n"));
                exit (1);
        }
-       if (!(add || rem || set || set_version))
-       {
+       if ((rf & af) != 0) {
+               fprintf (stderr, "Can't both set and unset same flag.\n");
+               exit (1);
+       }
+       if (!(add || rem || set || set_version)) {
                fprintf (stderr, _("Must use '-v', =, - or +\n"));
                exit (1);
        }
index 97f0ab9..ef710bd 100644 (file)
@@ -28,7 +28,7 @@ List all files in directories, including files that start with `.'.
 List directories like other files, rather than listing their contents.
 .TP
 .B \-v
-List the files version.
+List the file's version/generation number.
 .SH AUTHOR
 .B lsattr
 has been written by Remy Card <card@masi.ibp.fr>, the developer and maintainer
index 4011d62..9b9dc54 100644 (file)
@@ -43,14 +43,14 @@ extern char *optarg;
 #include "../version.h"
 #include "nls-enable.h"
 
-const char * program_name = "lsattr";
+static const char * program_name = "lsattr";
 
-int all = 0;
-int d_opt = 0;
-int l_opt = 0;
-int recursive = 0;
-int verbose = 0;
-int v_opt = 0;
+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 void usage(void)
 {
@@ -61,20 +61,26 @@ static void usage(void)
 static void list_attributes (const char * name)
 {
        unsigned long flags;
-       unsigned long version;
+       unsigned long generation;
 
        if (fgetflags (name, &flags) == -1)
                com_err (program_name, errno, _("While reading flags on %s"),
                         name);
-       else if (fgetversion (name, &version) == -1)
+       else if (fgetversion (name, &generation) == -1)
                com_err (program_name, errno, _("While reading version on %s"),
                         name);
        else
        {
-               if (v_opt)
-                       printf ("%5lu ", version);
-               print_flags (stdout, flags, l_opt);
-               printf (" %s\n", name);
+               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);
+               }
        }
 }
 
@@ -85,11 +91,11 @@ static void lsattr_args (const char * name)
        struct stat st;
 
        if (lstat (name, &st) == -1)
-               com_err (program_name, errno, _("while stating %s"), name);
-       else
-       {
-               if (S_ISDIR(st.st_mode) && !d_opt)
-                       iterate_on_dir (name, lsattr_dir_proc, (void *) NULL);
+               com_err (program_name, errno, _("while trying to stat %s"),
+                        name);
+       else {
+               if (S_ISDIR(st.st_mode) && !dirs_opt)
+                       iterate_on_dir (name, lsattr_dir_proc, NULL);
                else
                        list_attributes (name);
        }
@@ -112,8 +118,7 @@ static int lsattr_dir_proc (const char * dir_name, struct dirent * de, void * pr
                            strcmp(de->d_name, ".") &&
                            strcmp(de->d_name, "..")) {
                                printf ("\n%s:\n", path);
-                               iterate_on_dir (path, lsattr_dir_proc,
-                                               (void *) NULL);
+                               iterate_on_dir (path, lsattr_dir_proc, NULL);
                                printf ("\n");
                        }
                }
@@ -147,13 +152,13 @@ int main (int argc, char ** argv)
                                all = 1;
                                break;
                        case 'd':
-                               d_opt = 1;
+                               dirs_opt = 1;
                                break;
                        case 'l':
-                               l_opt = 1;
+                               pf_options = PFOPT_LONG;
                                break;
                        case 'v':
-                               v_opt = 1;
+                               generation_opt = 1;
                                break;
                        default:
                                usage();
index 4464da5..820b9d2 100644 (file)
@@ -905,12 +905,14 @@ static void PRS(int argc, char *argv[])
        device_name = argv[optind];
        optind++;
        if (optind < argc) {
-               param.s_blocks_count = strtoul(argv[optind++], &tmp, 0);
-               if (*tmp) {
+               unsigned long tmp2  = strtoul(argv[optind++], &tmp, 0);
+
+               if ((*tmp) || (tmp2 > 0xfffffffful)) {
                        com_err(program_name, 0, _("bad blocks count - %s"),
                                argv[optind - 1]);
                        exit(1);
                }
+               param.s_blocks_count = tmp2;
        }
        if (optind < argc)
                usage();
index f28fcd0..d19cc49 100644 (file)
@@ -139,7 +139,7 @@ set or clear the indicated filesystem features (options) in the filesystem.
 .I Feature
 can be one of the following supported filesystem options: 
 .IR sparse_super ,
-which cause the filesystem to use sparse superblocks, and
+which will cause the filesystem to use sparse superblocks, and
 .IR filetype ,
 which will cause the filesystem to store file type information in 
 directory entries.  After setting or clearing either filesystem feature,
index 78b779a..6903dc1 100644 (file)
@@ -370,7 +370,7 @@ int main (int argc, char ** argv)
                if (sb->s_feature_ro_compat &
                    EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)
                        fprintf(stderr, _("\nThe filesystem already"
-                               " has spare superblocks.\n"));
+                               " has sparse superblocks.\n"));
                else {
                        sb->s_feature_ro_compat |=
                                EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
@@ -390,7 +390,7 @@ int main (int argc, char ** argv)
                if (!(sb->s_feature_ro_compat &
                      EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))
                        fprintf(stderr, _("\nThe filesystem already"
-                               " does not support spare superblocks.\n"));
+                               " has sparse superblocks disabled.\n"));
                else {
                        sb->s_feature_ro_compat &=
                                ~EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;