[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#635173: ufsutils: mkfs.ufs and libufs not functional under standard Linux: "could not find special device"



Package: ufsutils
Version: 8.2-1
Severity: important

ufsutils version 7.1-2 exposed a similar bug which was reported/fixed in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=526586  and the problem I am
experiencing is very closely related (if not exactly the same).

Let's create a blockdevice to get started with:


edb@lapedb:~$ sudo modprobe rd
edb@lapedb:~$ ls -hal /dev/ram0
brw-rw---- 1 root disk 1, 0 Jul 23 13:35 /dev/ram0

This gives us the following behavior:



edb@lapedb:~$ sudo mkfs.ufs  -O 2 -J -N  /dev/sdb5
mkfs.ufs: /dev/sdb5: could not find special device
edb@lapedb:~$ sudo ffsinfo /dev/ram0
ffsinfo: ufs_disk_fillout(/dev/ram0) failed: could not find special device:
Success
edb@lapedb:~$ sudo dumpfs.ufs /dev/ram0
dumpfs.ufs: /dev/ram0: could not find special device


A clear pattern is emerging.

When looking at an strace, we can clearly see it fails after a stat (and after
reading /etc/fstab):

stat64("/dev/sdb5", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 21), ...}) = 0
brk(0)                                  = 0x920d000
brk(0x922f000)                          = 0x922f000
open("/etc/fstab", O_RDONLY)            = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=665, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0xb776b000
read(3, "# /etc/fstab: static file system"..., 4096) = 665
read(3, "", 4096)                       = 0
write(2, "mkfs.ufs: ", 10mkfs.ufs: )              = 10
write(2, "/dev/sdb5: could not find specia"..., 40/dev/sdb5: could not find
special device) = 40
write(2, "\n", 1
)                       = 1
exit_group(1)                           = ?


After apt-get source ufsutils and running a make (btw I need to specify
CC=gcc-4.4 since gcc-4.6.1 is complaining a lot and even then I need to comment
some things out to build and link properly). Then a gdb shows the following
(after a breakpoint in stat):

(gdb)
0x0804f0ec in stat ()
(gdb) n
Single stepping until exit from function stat,
which has no line number information.
ufs_disk_fillout_blank (disk=0x8054ce0, name=0xbffffe15 "/dev/sdb5") at
type.c:111
111             if (ret >= 0 && S_ISREG(st.st_mode)) {
(gdb) print name
$1 = 0xbffffe15 "/dev/sdb5"
(gdb) print st
$2 = {st_dev = 5, __pad1 = 0, st_ino = 218104, st_mode = 25008, st_nlink = 1,
st_uid = 0, st_gid = 25, st_rdev = 2069, __pad2 = 0,
  st_size = 0, st_blksize = 4096, st_blocks = 0, st_atim = {tv_sec =
1311416552, tv_nsec = 146218743}, st_mtim = {
    tv_sec = 1311416552, tv_nsec = 146218743}, st_ctim = {tv_sec = 1311416552,
tv_nsec = 146218743}, __unused4 = 0, __unused5 = 0}
(gdb) s
117             } else if ((fs = getfsfile(name)) != NULL) {
(gdb) n
128             } else if (ret >= 0 && S_ISDIR(st.st_mode)) {
(gdb) quit


But this again points to type.c and near line 114 this shows:

 } else if (ret >= 0 && (S_ISCHR(st.st_mode) && S_ISBLK(st.st_mode))

(which is already a debian specific patch (ref
ufsutils-8.2/debian/patches/01_libufs.patch) which contains the following:

-       } else if (ret >= 0 && S_ISCHR(st.st_mode)) {
+       } else if (ret >= 0 && (S_ISCHR(st.st_mode) && S_ISBLK(st.st_mode))) {
                /* This is what we need, do nothing. */
                ;

However, as far as my humble knowledge goes, I don't see how a /dev entry can
be both a character _and_ a block device (hence a logical || instead of a &&
might be more suitable in that patch).

For my local testing I just hacked the following in there (which works for me,
but probably fails on *BSD, judging form the previous bugreport).

        } else if (ret >= 0 && (S_ISBLK(st.st_mode))) {
                /* This is what we need, do nothing. */
                ;

And when I rebuild this and test this locally, then everybody is happy:

lapedb:/tmp/ufsutils-8.2# ./sbin/newfs/mkfs.ufs /dev/ram0
/dev/ram0: 8.0MB (16384 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 2.02MB, 129 blks, 320 inodes.
super-block backups (for fsck -b #) at:
 160, 4288, 8416, 12544


my 2 cents
E.




-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.39-2-686-pae (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages ufsutils depends on:
ii  libbsd0                  0.3.0-1         utility functions from BSD systems
ii  libc6                    2.13-10         Embedded GNU C Library: Shared lib
ii  libedit2                 2.11-20080614-2 BSD editline and history libraries

ufsutils recommends no packages.

ufsutils suggests no packages.

-- no debconf information



Reply to: