tags 410569 +pending
thanks
Thanks for reporting this bug. I've checked in the following fix
which should address your reported problem; it will be in the next
release of e2fsprogs.
- Ted
Fix e2fsck's get_size logic so it will work with the Linux floppy driver
The Linux floppy driver is a bit different from the other block device
drivers, in that if the device has been opened with O_EXCL, it disallows
another open(), even if the second open() does not have the O_EXCL flag.
So this patch moves the call to ext2fs_get_device_size() so that if it
returns EBUSY, e2fsck can close the filesystem, retry the device size,
and then reopen it. This rather complicated approach is required since
we need to know the blocksize of the filesystem before we can call
ext2fs_get_device_size().
Addresses Debian Bug: #410569
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
diff -r 11b6e3e021f0 -r fad17bc88e5b e2fsck/ChangeLog
--- a/e2fsck/ChangeLog Thu May 31 12:39:02 2007 -0400
+++ b/e2fsck/ChangeLog Mon Jun 04 01:14:52 2007 -0400
@@ -1,3 +1,13 @@ 2007-05-31 Theodore Tso [EMAIL PROTECTED]
+2007-06-04 Theodore Tso [EMAIL PROTECTED]
+
+ * super.c (check_super_block, e2fsck_get_device_size),
+ unix.c (main): Move device size logic into the main(), to
+ support the Linux floppy driver, which disallows another
+ (non-O_EXCL) open() if it has been opened with O_EXCL.
+ (Addresses Debian Bug: #410569)
+
+ * e2fsck.h (E2F_FLAG_GOT_DEVSIZE): New flag used in get_device logic
+
2007-05-31 Theodore Tso [EMAIL PROTECTED]
* util.c (get_backup_sb): Do basic sanity checking to make sure
diff -r 11b6e3e021f0 -r fad17bc88e5b e2fsck/e2fsck.h
--- a/e2fsck/e2fsck.h Thu May 31 12:39:02 2007 -0400
+++ b/e2fsck/e2fsck.h Mon Jun 04 01:14:52 2007 -0400
@@ -170,6 +170,7 @@ struct resource_track {
* specified by the user */
#define E2F_FLAG_RESTARTED 0x0200 /* E2fsck has been restarted */
#define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */
+#define E2F_FLAG_GOT_DEVSIZE 0x0800 /* Device size has been fetched */
/*
* Defines for indicating the e2fsck pass number
@@ -452,7 +453,6 @@ void e2fsck_rehash_directories(e2fsck_t
/* super.c */
void check_super_block(e2fsck_t ctx);
-errcode_t e2fsck_get_device_size(e2fsck_t ctx);
/* swapfs.c */
void swap_filesys(e2fsck_t ctx);
diff -r 11b6e3e021f0 -r fad17bc88e5b e2fsck/super.c
--- a/e2fsck/super.cThu May 31 12:39:02 2007 -0400
+++ b/e2fsck/super.cMon Jun 04 01:14:52 2007 -0400
@@ -37,19 +37,6 @@ static void check_super_value(e2fsck_t c
ctx-flags |= E2F_FLAG_ABORT; /* never get here! */
}
}
-
-/*
- * This routine may get stubbed out in special compilations of the
- * e2fsck code..
- */
-#ifndef EXT2_SPECIAL_DEVICE_SIZE
-errcode_t e2fsck_get_device_size(e2fsck_t ctx)
-{
- return (ext2fs_get_device_size(ctx-filesystem_name,
- EXT2_BLOCK_SIZE(ctx-fs-super),
- ctx-num_blocks));
-}
-#endif
/*
* helper function to release an inode
@@ -536,21 +523,13 @@ void check_super_block(e2fsck_t ctx)
return;
}
- if (!ctx-num_blocks) {
- pctx.errcode = e2fsck_get_device_size(ctx);
- if (pctx.errcode pctx.errcode != EXT2_ET_UNIMPLEMENTED) {
- fix_problem(ctx, PR_0_GETSIZE_ERROR, pctx);
+ if ((ctx-flags E2F_FLAG_GOT_DEVSIZE)
+ (ctx-num_blocks sb-s_blocks_count)) {
+ pctx.blk = sb-s_blocks_count;
+ pctx.blk2 = ctx-num_blocks;
+ if (fix_problem(ctx, PR_0_FS_SIZE_WRONG, pctx)) {
ctx-flags |= E2F_FLAG_ABORT;
return;
- }
- if ((pctx.errcode != EXT2_ET_UNIMPLEMENTED)
- (ctx-num_blocks sb-s_blocks_count)) {
- pctx.blk = sb-s_blocks_count;
- pctx.blk2 = ctx-num_blocks;
- if (fix_problem(ctx, PR_0_FS_SIZE_WRONG, pctx)) {
- ctx-flags |= E2F_FLAG_ABORT;
- return;
- }
}
}
diff -r 11b6e3e021f0 -r fad17bc88e5b e2fsck/unix.c
--- a/e2fsck/unix.c Thu May 31 12:39:02 2007 -0400
+++ b/e2fsck/unix.c Mon Jun 04 01:14:52 2007 -0400
@@ -981,6 +981,42 @@ restart:
fix_problem(ctx, PR_0_SB_CORRUPT, pctx);
fatal_error(ctx, 0);
}
+
+ if (!(ctx-flags E2F_FLAG_GOT_DEVSIZE)) {
+ __u32 blocksize = EXT2_BLOCK_SIZE(fs-super);
+ int need_restart = 0;
+
+ pctx.errcode = ext2fs_get_device_size(ctx-filesystem_name,
+ blocksize,
+