diff options
author | bde <bde@FreeBSD.org> | 2003-12-29 11:59:05 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2003-12-29 11:59:05 +0000 |
commit | a3659bc228f903f61a7922ccc99be85845497fe7 (patch) | |
tree | 37c019d53fc930a704e98755e08305138fbe6f83 /sys/fs/msdosfs | |
parent | 3631fbf9f2a96dac2e25079ae12139dcaf85100c (diff) | |
download | FreeBSD-src-a3659bc228f903f61a7922ccc99be85845497fe7.zip FreeBSD-src-a3659bc228f903f61a7922ccc99be85845497fe7.tar.gz |
Fixed some (most) style bugs in rev.1.33. Mainly 4-char indentation
(msdosfs uses normal 8-char indentation almost everywhere else),
too-long lines, and minor English usage errors. The verbose formal
comment before the new function is still abnormal.
Diffstat (limited to 'sys/fs/msdosfs')
-rw-r--r-- | sys/fs/msdosfs/msdosfs_fat.c | 126 |
1 files changed, 68 insertions, 58 deletions
diff --git a/sys/fs/msdosfs/msdosfs_fat.c b/sys/fs/msdosfs/msdosfs_fat.c index 1f75d7a..394c9ec 100644 --- a/sys/fs/msdosfs/msdosfs_fat.c +++ b/sys/fs/msdosfs/msdosfs_fat.c @@ -1107,69 +1107,79 @@ extendfile(dep, count, bpp, ncp, flags) return (0); } -/* [2753891] - * Routine to mark a FAT16 or FAT32 volume as "clean" or "dirty" by manipulating the upper bit - * of the FAT entry for cluster 1. Note that this bit is not defined for FAT12 volumes, which - * are always assumed to be dirty. +/*- + * Routine to mark a FAT16 or FAT32 volume as "clean" or "dirty" by + * manipulating the upper bit of the FAT entry for cluster 1. Note that + * this bit is not defined for FAT12 volumes, which are always assumed to + * be dirty. * - * The fatentry() routine only works on cluster numbers that a file could occupy, so it won't - * manipulate the entry for cluster 1. So we have to do it here. The code is ripped from - * fatentry(), and tailored for cluster 1. + * The fatentry() routine only works on cluster numbers that a file could + * occupy, so it won't manipulate the entry for cluster 1. So we have to do + * it here. The code was stolen from fatentry() and tailored for cluster 1. * * Inputs: - * pmp The MS-DOS volume to mark - * dirty Non-zero if the volume should be marked dirty; zero if it should be marked clean. + * pmp The MS-DOS volume to mark + * dirty Non-zero if the volume should be marked dirty; zero if it + * should be marked clean * * Result: - * 0 Success - * EROFS Volume is read-only - * ? (other errors from called routines) + * 0 Success + * EROFS Volume is read-only + * ? (other errors from called routines) */ -int markvoldirty(struct msdosfsmount *pmp, int dirty) +int +markvoldirty(struct msdosfsmount *pmp, int dirty) { - int error; - u_long bn, bo, bsize, byteoffset; - u_long fatval; - struct buf *bp; - - /* FAT12 does not support a "clean" bit, so don't do anything */ - if (FAT12(pmp)) - return 0; - - /* Can't change the bit on a read-only filesystem */ - if (pmp->pm_flags & MSDOSFSMNT_RONLY) - return EROFS; - - /* Fetch the block containing the FAT entry */ - byteoffset = FATOFS(pmp, 1); /* Find the location of cluster 1 */ - fatblock(pmp, byteoffset, &bn, &bsize, &bo); - - error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); - if (error) { - brelse(bp); - return (error); - } - - /* Get the current value of the FAT entry and set/clear the high bit */ - if (FAT32(pmp)) { - /* FAT32 uses bit 27 */ - fatval = getulong(&bp->b_data[bo]); - if (dirty) - fatval &= 0xF7FFFFFF; /* dirty means clear the "clean" bit */ - else - fatval |= 0x08000000; /* clean means set the "clean" bit */ - putulong(&bp->b_data[bo], fatval); - } - else { - /* Must be FAT16; use bit 15 */ - fatval = getushort(&bp->b_data[bo]); - if (dirty) - fatval &= 0x7FFF; /* dirty means clear the "clean" bit */ - else - fatval |= 0x8000; /* clean means set the "clean" bit */ - putushort(&bp->b_data[bo], fatval); - } - - /* Write out the modified FAT block immediately */ - return bwrite(bp); + struct buf *bp; + u_long bn, bo, bsize, byteoffset, fatval; + int error; + + /* + * FAT12 does not support a "clean" bit, so don't do anything for + * FAT12. + */ + if (FAT12(pmp)) + return (0); + + /* Can't change the bit on a read-only filesystem. */ + if (pmp->pm_flags & MSDOSFSMNT_RONLY) + return (EROFS); + + /* + * Fetch the block containing the FAT entry. It is given by the + * pseudo-cluster 1. + */ + byteoffset = FATOFS(pmp, 1); + fatblock(pmp, byteoffset, &bn, &bsize, &bo); + error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp); + if (error) { + brelse(bp); + return (error); + } + + /* + * Get the current value of the FAT entry and set/clear the relevant + * bit. Dirty means clear the "clean" bit; clean means set the + * "clean" bit. + */ + if (FAT32(pmp)) { + /* FAT32 uses bit 27. */ + fatval = getulong(&bp->b_data[bo]); + if (dirty) + fatval &= 0xF7FFFFFF; + else + fatval |= 0x08000000; + putulong(&bp->b_data[bo], fatval); + } else { + /* Must be FAT16; use bit 15. */ + fatval = getushort(&bp->b_data[bo]); + if (dirty) + fatval &= 0x7FFF; + else + fatval |= 0x8000; + putushort(&bp->b_data[bo], fatval); + } + + /* Write out the modified FAT block synchronously. */ + return (bwrite(bp)); } |