Bug#410569: fsck.ext2: fails on /dev/fd0

2007-06-04 Thread Theodore Tso
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,
+  

Bug#410569: fsck.ext2: fails on /dev/fd0

2007-05-07 Thread Theodore Tso
On Sun, Feb 11, 2007 at 02:58:35PM -0500, Jeffrey Sheinberg wrote:
 I have been running fsck.ext2 immediately after running mkfs.ext2
 on /dev/fd0 for many years now.  After the last upgrade, the
 fsck.ext2 step now fails.
 
 Here is a typescript,
 
 # mkfs.ext2 -q -m 0 -b 1024 -N 40 -L 'flop_bkup' /dev/fd0 ; echo $?
 0
 
 # fsck.ext2 -f -p -C 0 /dev/fd0 ; echo $?
 flop_bkup: Error determining size of the physical device: Device or 
 resource busy
 8

Hmmm.  Can you check to see if maybe udev automatically mounted the
/dev/fd0 filesystem after it was created?  That's the only reason why
I could imagine ext2fs_get_device_size() failing.

If that wasn't it, could you try running the fsck.ext2 command line
under strace.  i.e., run the command: 

strace fsck.ext2 -f -p -C 0 /dev/fd0 ; echo $?

And send me the output?  

Thanks!  (and my apologies for not getting back to you right away.)

- Ted



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#410569: fsck.ext2: fails on /dev/fd0

2007-02-11 Thread Jeffrey Sheinberg
Package: e2fsprogs
Version: 1.39+1.40-WIP-2006.11.14+dfsg-1
Severity: normal

Hi,

I have been running fsck.ext2 immediately after running mkfs.ext2
on /dev/fd0 for many years now.  After the last upgrade, the
fsck.ext2 step now fails.

Here is a typescript,

# mkfs.ext2 -q -m 0 -b 1024 -N 40 -L 'flop_bkup' /dev/fd0 ; echo $?
0

# fsck.ext2 -f -p -C 0 /dev/fd0 ; echo $?
flop_bkup: Error determining size of the physical device: Device or 
resource busy
8

# id
uid=0(root) gid=0(root) groups=0(root)


Thanks,
-- 
Jeffrey Sheinberg


-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (990, 'testing')
Architecture: i386 (i586)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.16-2-486
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages e2fsprogs depends on:
ii  e2fslibs 1.39+1.40-WIP-2006.11.14+dfsg-1 ext2 filesystem libraries
ii  libblkid 1.39+1.40-WIP-2006.11.14+dfsg-1 block device id library
ii  libc62.3.6.ds1-10GNU C Library: Shared libraries
ii  libcomer 1.39+1.40-WIP-2006.11.14+dfsg-1 common error description library
ii  libss2   1.39+1.40-WIP-2006.11.14+dfsg-1 command-line interface parsing lib
ii  libuuid1 1.39+1.40-WIP-2006.11.14+dfsg-1 universally unique id library

e2fsprogs recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]