Whamcloud - gitweb
Many files:
authorTheodore Ts'o <tytso@mit.edu>
Mon, 30 Mar 1998 01:20:55 +0000 (01:20 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 30 Mar 1998 01:20:55 +0000 (01:20 +0000)
  e2label.c: Fix -Wall warning by making functions static.
  chattr.1.in: Document that the append-only attribute may only be set
   or cleared by the superuser.
  Update all manual pages to that the availability section is
   up-to-date.
  e2label.8.in, tune2fs.8.in: Update manual page to state that labels
   must be no longer than 16 characters, or they will be truncated.
  e2label.c (change_label), tune2fs.c (main): If the label is longer
   than 16 characters, print a warning message stating that the label
   will be truncated.
  mke2fs.c (PRS): If the user specifies a filesystem size, and it's
   larger than the apparent size of the device, print a warning message
   and ask if the user wants to proceed.

13 files changed:
misc/ChangeLog
misc/Makefile.in
misc/badblocks.8.in
misc/chattr.1.in
misc/dumpe2fs.8.in
misc/e2label.8.in [new file with mode: 0644]
misc/e2label.c
misc/lsattr.1.in
misc/mke2fs.8.in
misc/mke2fs.c
misc/mklost+found.8.in
misc/tune2fs.8.in
misc/tune2fs.c

index 2b55314..cdcb86c 100644 (file)
@@ -1,3 +1,27 @@
+1998-03-29  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * e2label.c: Fix -Wall warning by making functions static.
+
+1998-03-28  Theodore Ts'o  <tytso@rsts-11.mit.edu>
+
+       * chattr.1.in: Document that the append-only attribute may
+               only be set or cleared by the superuser.
+
+       * Update all manual pages to that the availability section is
+               up-to-date. 
+
+       * e2label.8.in, tune2fs.8.in: Update manual page to state that
+               labels must be no longer than 16 characters, or they will
+               be truncated.
+
+       * e2label.c (change_label), tune2fs.c (main): If the label is
+               longer than 16 characters, print a warning message stating
+               that the label will be truncated.
+
+       * mke2fs.c (PRS): If the user specifies a filesystem size, and
+               it's larger than the apparent size of the device, print a
+               warning message and ask if the user wants to proceed.
+
 1998-03-21  Theodore Ts'o  <tytso@rsts-11.mit.edu>
 
        * mke2fs.c (check_plausibility): Fixed spelling typo in warning
index a2789a3..a80a5c0 100644 (file)
@@ -14,7 +14,7 @@ INSTALL = @INSTALL@
 SPROGS=                mke2fs badblocks tune2fs dumpe2fs e2label @FSCK_PROG@
 USPROGS=       mklost+found
 SMANPAGES=     tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \
-                       @FSCK_MAN@
+                       e2label.8 @FSCK_MAN@
 
 UPROGS=                chattr lsattr
 UMANPAGES=     chattr.1 lsattr.1
@@ -90,6 +90,9 @@ mklost+found.8: $(DEP_SUBSTITUTE) $(srcdir)/mklost+found.8.in
 mke2fs.8: $(DEP_SUBSTITUTE) $(srcdir)/mke2fs.8.in
        $(SUBSTITUTE) $(srcdir)/mke2fs.8.in mke2fs.8
 
+e2label.8: $(DEP_SUBSTITUTE) $(srcdir)/e2label.8.in
+       $(SUBSTITUTE) $(srcdir)/e2label.8.in e2label.8
+
 dumpe2fs.8: $(DEP_SUBSTITUTE) $(srcdir)/dumpe2fs.8.in 
        $(SUBSTITUTE) $(srcdir)/dumpe2fs.8.in dumpe2fs.8
 
index ca42e99..3692ed8 100644 (file)
@@ -70,8 +70,8 @@ I had no chance to make real tests of this program since I use IDE drives,
 which remap bad blocks. I only made some tests on floppies.
 .SH AVAILABILITY
 .B badblocks
-is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
-/pub/linux/packages/ext2fs.
+is part of the e2fsprogs package and is available for anonymous 
+ftp from tsx-11.mit.edu in /pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR e2fsck (8),
 .BR mke2fs (8)
index aece86d..32b4bf5 100644 (file)
@@ -43,31 +43,32 @@ Set the files version.
 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
 systems.
-
+.PP
 A file with the `a' attribute set can only be open in append mode for writing.
-
+Only the superuser can set or clear this attribute.
+.PP
 A file with the `c' attribute set is automatically compressed on the disk
 by the kernel. A read from this file returns uncompressed data. A write to
 this file compresses data before storing them on the disk.
-
+.PP
 A file with the `d' attribute set is not candidate for backup when the
 .BR dump (8)
 program is run.
-
+.PP
 A file with the `i' attribute cannot be modified: it cannot be deleted or
 renamed, no link can be created to this file and no data can be written
 to the file. Only the superuser can set or clear this attribute.
-
+.PP
 When a file with the `s' attribute set is deleted, its blocks are zeroed and
 written back to the disk.
-
+.PP
 When a file with the `S' attribute set is modified,
 the changes are written synchronously on the disk; this is equivalent to
 the `sync' mount option applied to a subset of the files.
-
+.PP
 When a file with the `u' attribute set is deleted, its contents are saved.
 This allows the user to ask for its undeletion.
-
+.PP
 .SH AUTHOR
 .B chattr
 was written by Remy Card <card@masi.ibp.fr>, the developer and maintainer
@@ -80,7 +81,7 @@ the kernel code.  (The noatime code is still in testing.)
 These attributes will be implemented in a future ext2 fs version.
 .SH AVAILABILITY
 .B chattr
-is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
-/pub/linux/packages/ext2fs.
+is part of the e2fsprogs package and is available for anonymous 
+ftp from tsx-11.mit.edu in /pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR lsattr (1)
index b9da72a..8db2d8f 100644 (file)
@@ -42,8 +42,8 @@ was written by Remy Card <card@masi.ibp.fr>, the developer and maintainer
 of the ext2 fs.
 .SH AVAILABILITY
 .B dumpe2fs
-is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
-/pub/linux/packages/ext2fs.
+is part of the e2fsprogs package and is available for anonymous 
+ftp from tsx-11.mit.edu in /pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR e2fsck (8),
 .BR mke2fs (8),
diff --git a/misc/e2label.8.in b/misc/e2label.8.in
new file mode 100644 (file)
index 0000000..fecb888
--- /dev/null
@@ -0,0 +1,52 @@
+.\" -*- nroff -*-
+.\" Copyright 1993, 1994, 1995 by Theodore Ts'o.  All Rights Reserved.
+.\" This file may be copied under the terms of the GNU Public License.
+.\" 
+.TH E2LABEL 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
+.SH NAME
+e2label \- Change the label on an ext2 filesystem
+.SH SYNOPSIS
+.B e2label
+device
+[
+new-label
+]
+.SH DESCRIPTION
+.BI e2label
+will display or change the filesystem label on the ext2 filesystem located on
+.I device.  
+.PP
+If the optional argument 
+.I new-label
+is not present, 
+.B e2label
+will simply display the current filesystem label.
+.PP
+If the optional argument
+.I new-label
+is present, then 
+.B e2label
+will set the filesystem label to be
+.IR new-label .
+Ext2 filesystem labels can be at most 16 characters long; if
+.I new-label 
+is longer than 16 characters, 
+.B e2label
+will truncate it and print a warning message.  
+.PP
+It is also possible to set the filesystem label using the
+.I -L
+option of 
+.BR tune2fs (8).
+.PP
+.SH AUTHOR
+.B e2label 
+was written by Andries Brouwer (aeb@cwi.nl).
+.SH AVAILABILITY
+.B e2label
+is part of the e2fsprogs package and is available for anonymous 
+ftp from tsx-11.mit.edu in /pub/linux/packages/ext2fs.
+.SH SEE ALSO
+.BR mke2fs (8),
+.BR tune2fs (8)
+
index 928a896..8c0df8b 100644 (file)
@@ -1,8 +1,14 @@
 /*
  * e2label.c           - Print or change the volume label on an ext2 fs
  *
- * aeb, 970714
+ * Written by Andries Brouwer (aeb@cwi.nl), 970714
+ * 
+ * Copyright 1997, 1998 by Theodore Ts'o.
  *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
  */
 
 #include <stdio.h>
@@ -37,8 +43,8 @@ struct ext2_super_block {
        char  s_dummy2[824];
 } sb;
 
-int
-open_e2fs (char *dev, int mode) {
+static int open_e2fs (char *dev, int mode)
+{
        int fd;
 
        fd = open(dev, mode);
@@ -65,23 +71,25 @@ open_e2fs (char *dev, int mode) {
        return fd;
 }
 
-void
-print_label (char *dev) {
+static void print_label (char *dev)
+{
        char label[VOLNAMSZ+1];
 
        open_e2fs (dev, O_RDONLY);
-       label[VOLNAMSZ] = 0;
        strncpy(label, sb.s_volume_name, VOLNAMSZ);
+       label[VOLNAMSZ] = 0;
        printf("%s\n", label);
 }
 
-void
-change_label (char *dev, char *label) {
+static void change_label (char *dev, char *label)
+{
        int fd;
 
        fd = open_e2fs(dev, O_RDWR);
        memset(sb.s_volume_name, 0, VOLNAMSZ);
        strncpy(sb.s_volume_name, label, VOLNAMSZ);
+       if (strlen(label) > VOLNAMSZ)
+               fprintf(stderr, "Warning: label too long, truncating.\n");
        if (lseek(fd, 1024, SEEK_SET) != 1024) {
             perror(dev);
             fprintf (stderr, "e2label: cannot seek to superblock again\n");
@@ -94,8 +102,8 @@ change_label (char *dev, char *label) {
        }
 }
 
-int
-main (int argc, char ** argv) {
+int main (int argc, char ** argv)
+{
        if (argc == 2)
             print_label(argv[1]);
        else if (argc == 3)
index 1a3bdff..03c159d 100644 (file)
@@ -34,7 +34,7 @@ of the ext2 fs.
 There are none :-).
 .SH AVAILABILITY
 .B lsattr
-is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
-/pub/linux/packages/ext2fs.
+is part of the e2fsprogs package and is available for anonymous 
+ftp from tsx-11.mit.edu in /pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR chattr (1)
index 9384c0a..6bb5877 100644 (file)
@@ -187,8 +187,8 @@ extended file system does not support fragments yet.
 There may be some other ones.  Please, report them to the author.
 .SH AVAILABILITY
 .B mke2fs
-is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
-/pub/linux/packages/ext2fs.
+is part of the e2fsprogs package and is available for anonymous 
+ftp from tsx-11.mit.edu in /pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BT badblocks (8),
 .BR dumpe2fs (8),
index 2a2f428..0ec17ba 100644 (file)
@@ -108,6 +108,15 @@ static int log2(int arg)
        return l;
 }
 
+static void proceed_question(NOARGS)
+{
+       fflush(stdout);
+       fflush(stderr);
+       printf("Proceed anyway? (y,n) ");
+       if (getchar() != 'y')
+               exit(1);
+}
+
 static void check_plausibility(NOARGS)
 {
 #ifdef HAVE_LINUX_MAJOR_H
@@ -117,29 +126,24 @@ static void check_plausibility(NOARGS)
        val = stat(device_name, &s);
        
        if(val == -1) {
-               printf("Could not stat %s --- %s\n", device_name,
-                      error_message(errno));
+               fprintf(stderr, "Could not stat %s --- %s\n",
+                       device_name, error_message(errno));
                if (errno == ENOENT)
-                       printf("\nThe device apparently does not exist; "
-                              "did you specify it correctly?\n");
+                       fprintf(stderr, "\nThe device apparently does "
+                              "not exist; did you specify it correctly?\n");
                exit(1);
        }
        if(!S_ISBLK(s.st_mode)) {
                printf("%s is not a block special device.\n", device_name);
-               printf("Proceed anyway? (y,n) ");
-               if (getchar() != 'y')
-                       exit(1);
+               proceed_question();
                return;
-       }
-       if ((MAJOR(s.st_rdev) == HD_MAJOR && MINOR(s.st_rdev)%64 == 0) ||
-           (MAJOR(s.st_rdev) == SCSI_DISK_MAJOR &&
-            MINOR(s.st_rdev)%16 == 0)) {
+       } else if ((MAJOR(s.st_rdev) == HD_MAJOR &&
+                   MINOR(s.st_rdev)%64 == 0) ||
+                  (MAJOR(s.st_rdev) == SCSI_DISK_MAJOR &&
+                   MINOR(s.st_rdev)%16 == 0)) {
                printf("%s is entire device, not just one partition!\n", 
                       device_name);
-               printf("Proceed anyway? (y,n) ");
-               if (getchar() != 'y')
-                       exit(1);
-               return;
+               proceed_question();
        }
 #endif
 }
@@ -607,6 +611,7 @@ static void PRS(int argc, char *argv[])
        char    *oldpath = getenv("PATH");
        struct ext2fs_sb *param_ext2 = (struct ext2fs_sb *) &param;
        char    *raid_opts = 0;
+       blk_t   dev_size;
        
        /* Update our PATH to include /sbin  */
        if (oldpath) {
@@ -762,15 +767,27 @@ static void PRS(int argc, char *argv[])
 
        param.s_log_frag_size = param.s_log_block_size;
 
+       retval = ext2fs_get_device_size(device_name,
+                                       EXT2_BLOCK_SIZE(&param),
+                                       &dev_size);
+       if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) {
+               com_err(program_name, retval,
+                       "while trying to determine filesystem size");
+               exit(1);
+       }
        if (!param.s_blocks_count) {
-               retval = ext2fs_get_device_size(device_name,
-                                               EXT2_BLOCK_SIZE(&param),
-                                               &param.s_blocks_count);
-               if (retval) {
-                       com_err(program_name, retval,
-                               "while trying to determine filesystem size");
+               if (retval == EXT2_ET_UNIMPLEMENTED) {
+                       com_err(program_name, 0,
+                               "Couldn't determine device size; you "
+                               "must specify\nthe size of the "
+                               "filesystem\n");
                        exit(1);
-               }
+               } else
+                       param.s_blocks_count = dev_size;
+       } else if (!force && (param.s_blocks_count > dev_size)) {
+               com_err(program_name, 0,
+                       "Filesystem larger than apparent filesystem size.");
+               proceed_question();
        }
 
        if (param.s_blocks_per_group) {
index bb192ec..3c6b3b4 100644 (file)
@@ -26,8 +26,8 @@ of the ext2 fs.
 There are none :-)
 .SH AVAILABILITY
 .B mklost+found
-is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
-/pub/linux/packages/ext2fs.
+is part of the e2fsprogs package and is available for anonymous 
+ftp from tsx-11.mit.edu in /pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR e2fsck (8),
 .BR mke2fs (8)
index 96139e0..7afba25 100644 (file)
@@ -117,7 +117,12 @@ can be a numerical uid or a user name.
 set the number of times the filesystem has been mounted.
 .TP
 .I -L volume-label
-set the volume label of the filesystem.
+set the volume label of the filesystem.  
+Ext2 filesystem labels can be at most 16 characters long; if
+.I volume-label 
+is longer than 16 characters, 
+.B tune2fs
+will truncate it and print a warning message.  
 .TP
 .I -M last-mounted-directory
 set the last-mounted directory for the filesystem.
@@ -146,8 +151,8 @@ This manual page was written by Christian Kuhtz <chk@data-hh.Hanse.DE>.
 Timedependent checking was added by Uwe Ohse <uwe@tirka.gun.de>.
 .SH AVAILABILITY
 .B tune2fs
-is available for anonymous ftp from ftp.ibp.fr and tsx-11.mit.edu in
-/pub/linux/packages/ext2fs.
+is part of the e2fsprogs package and is available for anonymous 
+ftp from tsx-11.mit.edu in /pub/linux/packages/ext2fs.
 .SH SEE ALSO
 .BR dumpe2fs (8),
 .BR e2fsck (8),
index 4ecaa61..a82ed5c 100644 (file)
@@ -415,6 +415,9 @@ int main (int argc, char ** argv)
                         "Recompile with a newer kernel");
 #endif
        if (L_flag) {
+               if (strlen(new_label) > sizeof(sb->s_volume_name))
+                       fprintf(stderr, "Warning: label too "
+                               "long, truncating.\n");
                memset(sb->s_volume_name, 0, sizeof(sb->s_volume_name));
                strncpy(sb->s_volume_name, new_label,
                        sizeof(sb->s_volume_name));