Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107284362
D24581.id71027.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D24581.id71027.diff
View Options
Index: sbin/fsck_msdosfs/check.c
===================================================================
--- sbin/fsck_msdosfs/check.c
+++ sbin/fsck_msdosfs/check.c
@@ -169,7 +169,7 @@
if (mod & FSDIRTY) {
pwarn("MARKING FILE SYSTEM CLEAN\n");
- mod |= writefat(fat);
+ mod |= cleardirty(fat);
} else {
pwarn("\n***** FILE SYSTEM IS LEFT MARKED AS DIRTY *****\n");
mod |= FSERROR; /* file system not clean */
Index: sbin/fsck_msdosfs/ext.h
===================================================================
--- sbin/fsck_msdosfs/ext.h
+++ sbin/fsck_msdosfs/ext.h
@@ -90,6 +90,8 @@
/* Opaque type */
struct fat_descriptor;
+int cleardirty(struct fat_descriptor *);
+
void fat_clear_cl_head(struct fat_descriptor *, cl_t);
bool fat_is_cl_head(struct fat_descriptor *, cl_t);
Index: sbin/fsck_msdosfs/fat.c
===================================================================
--- sbin/fsck_msdosfs/fat.c
+++ sbin/fsck_msdosfs/fat.c
@@ -578,7 +578,6 @@
* h = hard error flag (1 = ok; 0 = I/O error)
* x = any value ok
*/
-
int
checkdirty(int fs, struct bootblock *boot)
{
@@ -642,6 +641,53 @@
return ret;
}
+int
+cleardirty(struct fat_descriptor *fat)
+{
+ int fd, ret = FSERROR;
+ struct bootblock *boot;
+ u_char *buffer;
+ size_t len;
+ off_t off;
+
+ boot = boot_of_(fat);
+ fd = fd_of_(fat);
+
+ if (boot->ClustMask != CLUST16_MASK && boot->ClustMask != CLUST32_MASK)
+ return 0;
+
+ off = boot->bpbResSectors;
+ off *= boot->bpbBytesPerSec;
+
+ buffer = malloc(len = boot->bpbBytesPerSec);
+ if (buffer == NULL) {
+ perr("No memory for FAT sectors (%zu)", len);
+ return 1;
+ }
+
+ if ((size_t)pread(fd, buffer, len, off) != len) {
+ perr("Unable to read FAT");
+ goto err;
+ }
+
+ if (boot->ClustMask == CLUST16_MASK) {
+ buffer[3] |= 0x80;
+ } else {
+ buffer[7] |= 0x08;
+ }
+
+ if ((size_t)pwrite(fd, buffer, len, off) != len) {
+ perr("Unable to write FAT");
+ goto err;
+ }
+
+ ret = FSOK;
+
+err:
+ free(buffer);
+ return ret;
+}
+
/*
* Read a FAT from disk. Returns 1 if successful, 0 otherwise.
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 12, 11:30 PM (18 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15773804
Default Alt Text
D24581.id71027.diff (2 KB)
Attached To
Mode
D24581: Fix a bug with dirty file system handling.
Attached
Detach File
Event Timeline
Log In to Comment