Date: Mon, 16 Jul 2007 00:53:30 GMT From: Brian Chu <chub@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 123564 for review Message-ID: <200707160053.l6G0rUmU087053@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123564 Change 123564 by chub@chub-msdosfs on 2007/07/16 00:52:56 Fixes the spaced indentations to tabs, carrier lines are 4 spaces deeper than previous line. Affected files ... .. //depot/projects/soc2007/chub-msdosfs2/sbin/fsck_msdosfs/boot.c#3 edit .. //depot/projects/soc2007/chub-msdosfs2/sys/fs/msdosfs/bootsect.h#4 edit .. //depot/projects/soc2007/chub-msdosfs2/sys/fs/msdosfs/bpb.h#3 edit .. //depot/projects/soc2007/chub-msdosfs2/sys/fs/msdosfs/direntry.h#3 edit .. //depot/projects/soc2007/chub-msdosfs2/sys/geom/label/g_label_msdosfs.c#5 edit Differences ... ==== //depot/projects/soc2007/chub-msdosfs2/sbin/fsck_msdosfs/boot.c#3 (text+ko) ==== @@ -35,7 +35,7 @@ #ifndef lint __RCSID("$NetBSD: boot.c,v 1.9 2003/07/24 19:25:46 ws Exp $"); static const char rcsid[] = - "$FreeBSD: src/sbin/fsck_msdosfs/boot.c,v 1.4 2004/04/20 11:41:57 tjr Exp $"; +"$FreeBSD: src/sbin/fsck_msdosfs/boot.c,v 1.4 2004/04/20 11:41:57 tjr Exp $"; #endif /* not lint */ #include <stdlib.h> @@ -52,38 +52,38 @@ int readboot(int dosfs, struct bootblock *boot) { - union bootsector buffer; - union bootsector backup; - struct byte_bpb50 *pfat50; - struct byte_bpb710 *pfat710; - struct byte_Extboot *pfatext; - struct fsinfo fsstruct; + union bootsector buffer; + union bootsector backup; + struct byte_bpb50 *pfat50; + struct byte_bpb710 *pfat710; + struct byte_Extboot *pfatext; + struct fsinfo fsstruct; int ret = FSOK; if (read(dosfs, &buffer, sizeof(union bootsector)) - < sizeof(union bootsector)) { + < sizeof(union bootsector)) { perror("could not read boot block"); return FSFATAL; } if (buffer.bs50.bsBootSectSig0 != BOOTSIG0 || - buffer.bs50.bsBootSectSig1 != BOOTSIG1) { + buffer.bs50.bsBootSectSig1 != BOOTSIG1) { pfatal("Invalid signature in boot block: %02x%02x", - buffer.bs50.bsBootSectSig1, - buffer.bs50.bsBootSectSig0); + buffer.bs50.bsBootSectSig1, + buffer.bs50.bsBootSectSig0); return FSFATAL; } - /* set the bpb structs to the boot sector's bpb */ - pfat50 = (struct byte_bpb50 *)&buffer.bs50.bsBPB; - pfat710 = (struct byte_bpb710 *)&buffer.bs710.bsBPB; + /* set the bpb structs to the boot sector's bpb */ + pfat50 = (struct byte_bpb50 *)&buffer.bs50.bsBPB; + pfat710 = (struct byte_bpb710 *)&buffer.bs710.bsBPB; memset(boot, 0, sizeof(struct bootblock)); boot->ValidFat = -1; /* decode bios parameter block and store in a compacted - * architecture independent data structure for future use - */ + * architecture independent data structure for future use + */ boot->BytesPerSec = getushort(pfat50->bpbBytesPerSec); boot->SecPerClust = pfat50->bpbSecPerClust; boot->ResSectors = getushort(pfat50->bpbResSectors); @@ -96,23 +96,23 @@ boot->HiddenSecs = getulong(pfat50->bpbHiddenSecs); boot->HugeSectors = getulong(pfat50->bpbHugeSectors); - /* first defaulting to FAT12/FAT16 for number of FAT sectors */ + /* first defaulting to FAT12/FAT16 for number of FAT sectors */ boot->FATsecs = getushort(pfat50->bpbFATsecs); if (boot->RootDirEnts == 0) { - /* FAT32 parsing */ + /* FAT32 parsing */ boot->flags |= FAT32; boot->FATsecs = getulong(pfat710->bpbBigFATsecs); if (pfat710->bpbExtFlags[0] & 0x80) { boot->ValidFat = pfat710->bpbExtFlags[0] & 0x0f; - } + } /* check version number: */ - if (pfat710->bpbFSVers[0] != 0 || - pfat710->bpbFSVers[1] != 0) { + if (pfat710->bpbFSVers[0] != 0 || + pfat710->bpbFSVers[1] != 0) { pfatal("Unknown file system version: %x.%x", - pfat710->bpbFSVers[1], - pfat710->bpbFSVers[0]); + pfat710->bpbFSVers[1], + pfat710->bpbFSVers[0]); return FSFATAL; } @@ -122,27 +122,27 @@ if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) != boot->FSInfo * boot->BytesPerSec) { - perror("could not seek to fsinfo block to read"); - return FSFATAL; - } + perror("could not seek to fsinfo block to read"); + return FSFATAL; + } - if (read(dosfs, &fsstruct, sizeof(struct fsinfo)) - != sizeof(struct fsinfo)) { + if (read(dosfs, &fsstruct, sizeof(struct fsinfo)) + != sizeof(struct fsinfo)) { perror("could not read fsinfo block"); return FSFATAL; } if (memcmp(fsstruct.fsisig1, "RRaA", 4) || memcmp(fsstruct.fsisig2, "rrAa", 4) || - memcmp(fsstruct.fsisig3, "\0\0\125\252", 4) || - memcmp(fsstruct.fsisig4, "\0\0\125\252", 4)) { + memcmp(fsstruct.fsisig3, "\0\0\125\252", 4) || + memcmp(fsstruct.fsisig4, "\0\0\125\252", 4)) { pwarn("Invalid signature in fsinfo block"); if (ask(0, "fix")) { - memcpy(fsstruct.fsisig1, "RRaA", 4); - memcpy(fsstruct.fsisig2, "rrAa", 4); - memcpy(fsstruct.fsisig3, "\0\0\125\252", 4); - memcpy(fsstruct.fsisig4, "\0\0\125\252", 4); + memcpy(fsstruct.fsisig1, "RRaA", 4); + memcpy(fsstruct.fsisig2, "rrAa", 4); + memcpy(fsstruct.fsisig3, "\0\0\125\252", 4); + memcpy(fsstruct.fsisig4, "\0\0\125\252", 4); if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) != boot->FSInfo * boot->BytesPerSec) { @@ -150,7 +150,7 @@ return FSFATAL; } - if (write(dosfs, &fsstruct, sizeof(struct fsinfo)) + if (write(dosfs, &fsstruct, sizeof(struct fsinfo)) != sizeof(struct fsinfo)) { perror("could not write fixed fsinfo"); return FSFATAL; @@ -158,10 +158,10 @@ ret = FSBOOTMOD; } - else { - /* we didn't fix the corrupted FSInfo block */ + else { + /* we didn't fix the corrupted FSInfo block */ boot->FSInfo = 0; - } + } } if (boot->FSInfo != 0) { @@ -175,21 +175,21 @@ return FSFATAL; } - if (read(dosfs, &backup, sizeof(union bootsector)) - != sizeof(union bootsector)) { + if (read(dosfs, &backup, sizeof(union bootsector)) + != sizeof(union bootsector)) { perror("could not read backup bootblock"); return FSFATAL; } - // never written back to disk - //backup.bs710.bsExt.exReserved1 = buffer.bs710.bsExt.exReserved1; + // never written back to disk + //backup.bs710.bsExt.exReserved1 = buffer.bs710.bsExt.exReserved1; if (memcmp(buffer.bs710.bsBPB, - backup.bs710.bsBPB, - sizeof(struct bpb710)) || - memcmp(buffer.bs710.bsExt, - backup.bs710.bsExt, - sizeof(struct extboot))) { + backup.bs710.bsBPB, + sizeof(struct bpb710)) || + memcmp(buffer.bs710.bsExt, + backup.bs710.bsExt, + sizeof(struct extboot))) { pfatal("backup doesn't compare to primary bootblock"); if (alwaysno) @@ -198,10 +198,10 @@ return FSFATAL; } - /* Unnecessary to check the backup FSInfo because there isn't - * an physical backup copy of the FSInfo block. There's only a - * backup of the FSInfo block number, which was checked (bsBPB) above. - */ + /* Unnecessary to check the backup FSInfo because there isn't + * an physical backup copy of the FSInfo block. There's only a + * backup of the FSInfo block number, which was checked (bsBPB) above. + */ } boot->ClusterOffset = (boot->RootDirEnts * 32 + boot->BytesPerSec - 1) @@ -224,7 +224,7 @@ } else boot->NumSectors = boot->HugeSectors; boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) - / boot->SecPerClust; + / boot->SecPerClust; if (boot->flags & FAT32) boot->ClustMask = CLUST32_MASK; @@ -234,7 +234,7 @@ boot->ClustMask = CLUST16_MASK; else { pfatal("Filesystem too big (%u clusters) for non-FAT32 partition", - boot->NumClusters); + boot->NumClusters); return FSFATAL; } @@ -252,7 +252,7 @@ if (boot->NumFatEntries < boot->NumClusters) { pfatal("FAT size too small, %u entries won't fit into %u sectors\n", - boot->NumClusters, boot->FATsecs); + boot->NumClusters, boot->FATsecs); return FSFATAL; } boot->ClusterSize = boot->BytesPerSec * boot->SecPerClust; @@ -266,33 +266,33 @@ int writefsinfo(int dosfs, struct bootblock *boot) { - struct fsinfo fsstruct; + struct fsinfo fsstruct; u_char fsinfo[2 * DOSBOOTBLOCKSIZE]; - if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) - != boot->FSInfo * boot->BytesPerSec) { - perror("could not seek to fsinfo block to read"); - return FSFATAL; - } + if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) + != boot->FSInfo * boot->BytesPerSec) { + perror("could not seek to fsinfo block to read"); + return FSFATAL; + } - if (read(dosfs, &fsstruct, sizeof(struct fsinfo)) - != sizeof(struct fsinfo)) { - perror("could not read fsinfo block"); - return FSFATAL; - } + if (read(dosfs, &fsstruct, sizeof(struct fsinfo)) + != sizeof(struct fsinfo)) { + perror("could not read fsinfo block"); + return FSFATAL; + } - putulong(&fsstruct.fsinfree, boot->FSFree); - putulong(&fsstruct.fsinxtfree, boot->FSNext); + putulong(&fsstruct.fsinfree, boot->FSFree); + putulong(&fsstruct.fsinxtfree, boot->FSNext); - if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) - != boot->FSInfo * boot->BytesPerSec) { - perror("could not seek to fsinfo block to write new block"); - return FSFATAL; - } + if (lseek(dosfs, boot->FSInfo * boot->BytesPerSec, SEEK_SET) + != boot->FSInfo * boot->BytesPerSec) { + perror("could not seek to fsinfo block to write new block"); + return FSFATAL; + } if (write(dosfs, &fsstruct, sizeof(struct fsinfo)) != sizeof(struct fsinfo)) { - perror("could not write fixed fsinfo"); + perror("could not write fixed fsinfo"); return FSFATAL; } ==== //depot/projects/soc2007/chub-msdosfs2/sys/fs/msdosfs/bootsect.h#4 (text+ko) ==== @@ -30,8 +30,7 @@ struct bootsector33 { u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ int8_t bsOemName[8]; /* OEM name and version */ - // int8_t bsBPB[19]; /* BIOS parameter block */ - struct bpb33 bsBPB; /* BIOS parameter block */ + struct bpb33 bsBPB; /* BIOS parameter block */ int8_t bsDriveNumber; /* drive number (0x80) */ int8_t bsBootCode[479]; /* pad so struct is 512b */ u_int8_t bsBootSectSig0; @@ -63,8 +62,8 @@ struct bootsector50 { u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ int8_t bsOemName[8]; /* OEM name and version */ - struct bpb50 bsBPB; /* BIOS parameter block */ - struct extboot bsExt; /* Bootsector Extension */ + struct bpb50 bsBPB; /* BIOS parameter block */ + struct extboot bsExt; /* Bootsector Extension */ int8_t bsBootCode[448]; /* pad so structure is 512b */ u_int8_t bsBootSectSig0; u_int8_t bsBootSectSig1; @@ -75,8 +74,8 @@ struct bootsector710 { u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */ int8_t bsOEMName[8]; /* OEM name and version */ - struct bpb710 bsBPB; /* BIOS parameter block */ - struct extboot bsExt; /* Bootsector Extension */ + struct bpb710 bsBPB; /* BIOS parameter block */ + struct extboot bsExt; /* Bootsector Extension */ int8_t bsBootCode[420]; /* pad so structure is 512b */ u_int8_t bsBootSectSig0; u_int8_t bsBootSectSig1; ==== //depot/projects/soc2007/chub-msdosfs2/sys/fs/msdosfs/bpb.h#3 (text+ko) ==== @@ -81,7 +81,7 @@ u_int32_t bpbRootClust; /* start cluster for root directory */ u_int16_t bpbFSInfo; /* filesystem info structure sector */ u_int16_t bpbBackup; /* backup boot sector */ - u_int8_t bpbReserved[12]; /* 12 byte filler here */ + u_int8_t bpbReserved[12];/* 12 byte filler here */ }; /* @@ -156,7 +156,7 @@ u_int8_t bpbRootClust[4]; /* start cluster for root directory */ u_int8_t bpbFSInfo[2]; /* filesystem info structure sector */ u_int8_t bpbBackup[2]; /* backup boot sector */ - u_int8_t bpbReserved[12]; /* 12 byte filler here */ + u_int8_t bpbReserved[12]; /* 12 byte filler here */ }; /* ==== //depot/projects/soc2007/chub-msdosfs2/sys/fs/msdosfs/direntry.h#3 (text+ko) ==== @@ -88,7 +88,7 @@ #define WIN_CNT 0x3f u_int8_t wePart1[10]; u_int8_t weAttributes; -#define ATTR_WIN95 0x0f /* Long directory entryies */ +#define ATTR_WIN95 0x0f /* Long directory entryies */ u_int8_t weReserved1; u_int8_t weChksum; u_int8_t wePart2[12]; ==== //depot/projects/soc2007/chub-msdosfs2/sys/geom/label/g_label_msdosfs.c#5 (text+ko) ==== @@ -50,11 +50,11 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size) { struct g_provider *pp; - union bootsector *bsp; - struct byte_bpb50 *pfat_bpb50; - struct byte_bpb710 *pfat_bpb710; - struct extboot *pfat_extboot; - struct direntry* pfat_entry; + union bootsector *bsp; + struct byte_bpb50 *pfat_bpb50; + struct byte_bpb710 *pfat_bpb710; + struct extboot *pfat_extboot; + struct direntry* pfat_entry; uint8_t *sector0, *sector; uint32_t i; @@ -82,17 +82,15 @@ if (sector0 == NULL) return; - /* Set the bootsector/boot parameter block to a struct. */ - bsp = (union bootsector *)sector0; - pfat_bpb50 = (struct byte_bpb50 *) &bsp->bs50.bsBPB; - pfat_bpb710 = (struct byte_bpb710 *) &bsp->bs710.bsBPB; + /* Set the bootsector/boot parameter block to a struct. */ + bsp = (union bootsector *)sector0; + pfat_bpb50 = (struct byte_bpb50 *) &bsp->bs50.bsBPB; + pfat_bpb710 = (struct byte_bpb710 *) &bsp->bs710.bsBPB; /* Check for the FAT boot sector signature. */ if (bsp->bs50.bsBootSectSig0 != BOOTSIG0 || - bsp->bs50.bsBootSectSig1 != BOOTSIG1) { - G_LABEL_DEBUG(1, - "MSDOSFS: %s: no FAT signature found.", - pp->name); + bsp->bs50.bsBootSectSig1 != BOOTSIG1) { + G_LABEL_DEBUG(1, "MSDOSFS: %s: no FAT signature found.", pp->name); goto error; } @@ -101,52 +99,51 @@ * Test if this is really a FAT volume and determine the FAT type. */ if (getushort(pfat_bpb50->bpbFATsecs) != 0) { - /* The extended boot record is one place for FAT12/FAT16 - * and another for FAT32. - */ + /* + * The extended boot record is one place for FAT12/FAT16 + * and another for FAT32. + */ - pfat_extboot = (struct extboot *) &bsp->bs50.bsExt; - + pfat_extboot = (struct extboot *) &bsp->bs50.bsExt; + /* * If the BPB_FATSz16/bpbFATsecs field is not zero and - * the string "FAT" is at the right place, this should - * be a FAT12 or FAT16 volume. + * the string "FAT" is at the right place, this should + * be a FAT12 or FAT16 volume. */ if (strncmp(pfat_extboot->exFileSysType, "FAT", 3) != 0) { - G_LABEL_DEBUG(1, - "MSDOSFS: %s: FAT12/16 volume not valid.", + G_LABEL_DEBUG(1, "MSDOSFS: %s: FAT12/16 volume not valid.", pp->name); goto error; } - G_LABEL_DEBUG(1, - "MSDOSFS: %s: FAT12/FAT16 volume detected.", - pp->name); + G_LABEL_DEBUG(1, "MSDOSFS: %s: FAT12/FAT16 volume detected.", + pp->name); /* A volume with no name should have "NO NAME " as label. */ if (strncmp(pfat_extboot->exVolumeLabel, LABEL_NO_NAME, - sizeof(pfat_extboot->exVolumeLabel)) == 0) { - G_LABEL_DEBUG(1, - "MSDOSFS: %s: FAT12/16 volume has no name.", + sizeof(pfat_extboot->exVolumeLabel)) == 0) { + G_LABEL_DEBUG(1, "MSDOSFS: %s: FAT12/16 volume has no name.", pp->name); goto error; } strlcpy(label, pfat_extboot->exVolumeLabel, MIN(size, sizeof(pfat_extboot->exVolumeLabel) + 1)); } - else if (getulong(pfat_bpb710->bpbBigFATsecs) != 0) { + else if (getulong(pfat_bpb710->bpbBigFATsecs) != 0) { uint32_t fat_FirstDataSector, fat_BytesPerSector, offset; - /* The extended boot record is one place for FAT12/FAT16 - * and another for FAT32. - */ + /* + * The extended boot record is one place for FAT12/FAT16 + * and another for FAT32. + */ - pfat_extboot = (struct extboot *) &bsp->bs710.bsExt; + pfat_extboot = (struct extboot *) &bsp->bs710.bsExt; /* * If the BPB_FATSz32/bpbBigFATsecs field is not zero - * and the string "FAT" is at the right place, this - * should be a FAT32 volume. + * and the string "FAT" is at the right place, this + * should be a FAT32 volume. */ if (strncmp(pfat_extboot->exFileSysType, "FAT", 3) != 0) { @@ -154,14 +151,13 @@ pp->name); goto error; } - G_LABEL_DEBUG(1, "MSDOSFS: %s: FAT32 volume detected.", - pp->name); + G_LABEL_DEBUG(1, "MSDOSFS: %s: FAT32 volume detected.", pp->name); /* * If the volume label is not "NO NAME " we're done. */ if (strncmp(pfat_extboot->exVolumeLabel, LABEL_NO_NAME, - sizeof(pfat_extboot->exVolumeLabel)) == 0) { + sizeof(pfat_extboot->exVolumeLabel)) == 0) { strlcpy(label, pfat_extboot->exVolumeLabel, MIN(size, sizeof(pfat_extboot->exVolumeLabel) + 1)); goto endofchecks; @@ -175,7 +171,7 @@ fat_FirstDataSector = getushort(pfat_bpb710->bpbResSectors) + (pfat_bpb710->bpbFATs * - getulong(pfat_bpb710->bpbBigFATsecs)); + getulong(pfat_bpb710->bpbBigFATsecs)); fat_BytesPerSector = getushort(pfat_bpb710->bpbBytesPerSec); G_LABEL_DEBUG(2, @@ -183,7 +179,7 @@ fat_FirstDataSector, fat_BytesPerSector); for (offset = fat_BytesPerSector * fat_FirstDataSector;; - offset += fat_BytesPerSector) { + offset += fat_BytesPerSector) { sector = (uint8_t *)g_read_data(cp, offset, fat_BytesPerSector, NULL); if (sector == NULL) @@ -214,7 +210,7 @@ ATTR_DIRECTORY) { strlcpy(label, pfat_entry->deName, MIN(size, - sizeof(pfat_extboot->exVolumeLabel) + 1)); + sizeof(pfat_extboot->exVolumeLabel) + 1)); goto endofchecks; } } while((uint8_t *)(++pfat_entry) <
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707160053.l6G0rUmU087053>