Print this page
PSARC 2008/290 lofi mount
6384817 Need persistent lofi based mounts and direct mount(1m) support for lofi

@@ -24,11 +24,11 @@
  * THIS SOFTWARE IS PROVIDED '`AS IS'' AND WITHOUT ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#pragma ident   "@(#)main.c     1.54    08/02/06 SMI"
+#pragma ident   "@(#)main.c     1.55    08/05/07 SMI"
 
 /*
  * In-core structures:
  * blockmap[]
  *      A bitmap of block usage very similar to what's on disk, but

@@ -694,44 +694,35 @@
         FILE *vfstab;
         struct statvfs vfs_stat;
         int found_magic[MAGIC_LIMIT];
         int magic_cnt;
         int is_magic = 0;
-        int is_block;
+        int is_block = 0;
+        int is_file = 0;
 
         (void) memset((void *)found_magic, 0, sizeof (found_magic));
 
         if (stat64(filename, &stbd) < 0) {
                 (void) fprintf(stderr,
                 "ufs fsck: sanity check failed : cannot stat %s\n", filename);
                 exit(EXNOSTAT);
         }
 
-        if ((stbd.st_mode & S_IFMT) == S_IFBLK) {
+        if (S_ISBLK(stbd.st_mode)) {
                 is_block = 1;
-        } else if ((stbd.st_mode & S_IFMT) == S_IFCHR) {
+        } else if (S_ISCHR(stbd.st_mode)) {
                 is_block = 0;
-        } else {
-                /*
-                 * In !mflag mode, we allow checking the contents
-                 * of a file.  Since this is intended primarily for
-                 * speeding up boot-time checks and allowing for a
-                 * file complicates the ok-input tests, we'll disallow
-                 * that option.
-                 */
-                (void) fprintf(stderr,
-                    "ufs fsck: sanity check failed: "
-                    "%s not block or character device\n", filename);
-                exit(EXNOSTAT);
+        } else if (S_ISREG(stbd.st_mode)) {
+                is_file = 1;
         }
 
         /*
          * Determine if this is the root file system via vfstab. Give up
          * silently on failures. The whole point of this is to be tolerant
          * of the magic file systems being already mounted.
          */
-        if ((vfstab = fopen(VFSTAB, "r")) != 0) {
+        if (!is_file && (vfstab = fopen(VFSTAB, "r")) != NULL) {
                 for (magic_cnt = 0; magic_cnt < MAGIC_LIMIT; magic_cnt++) {
                         if (magic_cnt == MAGIC_NONE)
                                 continue;
                         if (getvfsfile(vfstab, &vfsbuf,
                             magic_fs[magic_cnt]) == 0) {