]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mke2fs.c: Check for the BSD disklabel on all architectures, and
authorTheodore Ts'o <tytso@mit.edu>
Fri, 8 Mar 2002 08:01:53 +0000 (03:01 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 8 Mar 2002 08:01:53 +0000 (03:01 -0500)
also check the byte-swapped magic number as well.

misc/ChangeLog
misc/mke2fs.c

index df1a3cb81f0b517228f824764a749327759c52ce..2216a1b0d434adf454887bad8579168c47b063e4 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-08  Theodore Tso  <tytso@mit.edu>
+
+       * mke2fs.c: Check for the BSD disklabel on all architectures, and
+               also check the byte-swapped magic number as well.
+
 2002-03-07  Theodore Tso  <tytso@mit.edu>
 
        * mke2fs.c: Output warnings to stderr 
index 3165dfc3133caff689fdd5509cfb846d87e83b6c..cbaffac55dba6c58dddd9b994e8c4c32862e9ef8 100644 (file)
@@ -550,10 +550,9 @@ static void reserve_inodes(ext2_filsys fs)
        ext2fs_mark_ib_dirty(fs);
 }
 
-#ifdef __alpha__
 #define BSD_DISKMAGIC   (0x82564557UL)  /* The disk magic number */
+#define BSD_MAGICDISK   (0x57455682UL)  /* The disk magic number reversed */
 #define BSD_LABEL_OFFSET        64
-#endif
 
 static void zap_sector(ext2_filsys fs, int sect, int nsect)
 {
@@ -569,18 +568,20 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect)
        }
        memset(buf, 0, 512*nsect);
 
-#ifdef __alpha__
-       /* Check for a BSD disklabel, and don't erase it if so */
-       retval = io_channel_read_blk(fs->io, 0, -512, buf);
-       if (retval)
-               fprintf(stderr, _("Warning: could not read block 0: %s\n"),
-                       error_message(retval));
-       else {
-               magic = (unsigned int *) (buf + BSD_LABEL_OFFSET);
-               if (*magic == BSD_DISKMAGIC)
-                       return;
+       if (sect == 0) {
+               /* Check for a BSD disklabel, and don't erase it if so */
+               retval = io_channel_read_blk(fs->io, 0, -512, buf);
+               if (retval)
+                       fprintf(stderr,
+                               _("Warning: could not read block 0: %s\n"),
+                               error_message(retval));
+               else {
+                       magic = (unsigned int *) (buf + BSD_LABEL_OFFSET);
+                       if ((*magic == BSD_DISKMAGIC) ||
+                           (*magic == BSD_MAGICDISK))
+                               return;
+               }
        }
-#endif
 
        io_channel_set_blksize(fs->io, 512);
        retval = io_channel_write_blk(fs->io, sect, -512*nsect, buf);