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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/fs.d/ufs/fsck/main.c
          +++ new/usr/src/cmd/fs.d/ufs/fsck/main.c
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19   * in the documentation or other materials provided with the distribution
  20   20   * and in all advertising materials mentioning features or use of this
  21   21   * software. Neither the name of the University nor the names of its
  22   22   * contributors may be used to endorse or promote products derived
  23   23   * from this software without specific prior written permission.
  24   24   * THIS SOFTWARE IS PROVIDED '`AS IS'' AND WITHOUT ANY EXPRESS OR
  25   25   * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  26   26   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27   27   */
  28   28  
  29      -#pragma ident   "@(#)main.c     1.54    08/02/06 SMI"
       29 +#pragma ident   "@(#)main.c     1.55    08/05/07 SMI"
  30   30  
  31   31  /*
  32   32   * In-core structures:
  33   33   * blockmap[]
  34   34   *      A bitmap of block usage very similar to what's on disk, but
  35   35   *      for the entire filesystem rather than just a cylinder group.
  36   36   *      Zero indicates free, one indicates allocated.  Note that this
  37   37   *      is opposite the interpretation of a cylinder group's free block
  38   38   *      bitmap.
  39   39   *
↓ open down ↓ 649 lines elided ↑ open up ↑
 689  689          struct stat64 stbd, stbr;
 690  690          char *devname;
 691  691          struct ustat usb;
 692  692          char vfsfilename[MAXPATHLEN];
 693  693          struct vfstab vfsbuf;
 694  694          FILE *vfstab;
 695  695          struct statvfs vfs_stat;
 696  696          int found_magic[MAGIC_LIMIT];
 697  697          int magic_cnt;
 698  698          int is_magic = 0;
 699      -        int is_block;
      699 +        int is_block = 0;
      700 +        int is_file = 0;
 700  701  
 701  702          (void) memset((void *)found_magic, 0, sizeof (found_magic));
 702  703  
 703  704          if (stat64(filename, &stbd) < 0) {
 704  705                  (void) fprintf(stderr,
 705  706                  "ufs fsck: sanity check failed : cannot stat %s\n", filename);
 706  707                  exit(EXNOSTAT);
 707  708          }
 708  709  
 709      -        if ((stbd.st_mode & S_IFMT) == S_IFBLK) {
      710 +        if (S_ISBLK(stbd.st_mode)) {
 710  711                  is_block = 1;
 711      -        } else if ((stbd.st_mode & S_IFMT) == S_IFCHR) {
      712 +        } else if (S_ISCHR(stbd.st_mode)) {
 712  713                  is_block = 0;
 713      -        } else {
 714      -                /*
 715      -                 * In !mflag mode, we allow checking the contents
 716      -                 * of a file.  Since this is intended primarily for
 717      -                 * speeding up boot-time checks and allowing for a
 718      -                 * file complicates the ok-input tests, we'll disallow
 719      -                 * that option.
 720      -                 */
 721      -                (void) fprintf(stderr,
 722      -                    "ufs fsck: sanity check failed: "
 723      -                    "%s not block or character device\n", filename);
 724      -                exit(EXNOSTAT);
      714 +        } else if (S_ISREG(stbd.st_mode)) {
      715 +                is_file = 1;
 725  716          }
 726  717  
 727  718          /*
 728  719           * Determine if this is the root file system via vfstab. Give up
 729  720           * silently on failures. The whole point of this is to be tolerant
 730  721           * of the magic file systems being already mounted.
 731  722           */
 732      -        if ((vfstab = fopen(VFSTAB, "r")) != 0) {
      723 +        if (!is_file && (vfstab = fopen(VFSTAB, "r")) != NULL) {
 733  724                  for (magic_cnt = 0; magic_cnt < MAGIC_LIMIT; magic_cnt++) {
 734  725                          if (magic_cnt == MAGIC_NONE)
 735  726                                  continue;
 736  727                          if (getvfsfile(vfstab, &vfsbuf,
 737  728                              magic_fs[magic_cnt]) == 0) {
 738  729                                  if (is_block)
 739  730                                          devname = vfsbuf.vfs_special;
 740  731                                  else
 741  732                                          devname = vfsbuf.vfs_fsckdev;
 742  733                                  if (stat64(devname, &stbr) == 0) {
↓ open down ↓ 99 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX