mkfs with -t option on btrfs fails on wily

Bug #1474473 reported by Colin Ian King
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
util-linux (Debian)
Fix Released
Unknown
util-linux (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

How to reproduce:

As root:

# dd if=/dev/zero of=test.img bs=1M count=1024
# mkfs -t btrfs -f test.img
mkfs: failed to execute mkfs.btrfs: No such file or directory

Does it exist?

# which mkfs.btrfs
/bin/mkfs.btrfs

Yes!

stracing mkfs shows why it fails:

# strace -f mkfs -t btrfs -f test.img
execve("/sbin/mkfs", ["mkfs", "-t", "btrfs", "-f", "test.img"], [/* 41 vars */]) = 0
brk(0) = 0xba3000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8b0e914000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=155913, ...}) = 0
mmap(NULL, 155913, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8b0e8ed000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\v\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1869392, ...}) = 0
mmap(NULL, 3972864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f8b0e329000
mprotect(0x7f8b0e4e9000, 2097152, PROT_NONE) = 0
mmap(0x7f8b0e6e9000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f8b0e6e9000
mmap(0x7f8b0e6ef000, 16128, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f8b0e6ef000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8b0e8ec000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8b0e8eb000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8b0e8ea000
arch_prctl(ARCH_SET_FS, 0x7f8b0e8eb700) = 0
mprotect(0x7f8b0e6e9000, 16384, PROT_READ) = 0
mprotect(0x601000, 4096, PROT_READ) = 0
mprotect(0x7f8b0e916000, 4096, PROT_READ) = 0
munmap(0x7f8b0e8ed000, 155913) = 0
brk(0) = 0xba3000
brk(0xbc4000) = 0xbc4000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2919792, ...}) = 0
mmap(NULL, 2919792, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f8b0e060000
close(3) = 0
execve("/sbin/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/sbin/fs.d/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/sbin/fs/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/home/king/android/android-ndk-r10e/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/home/king/bin/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/home/king/coverity/cov-analysis-linux64-7.6.0/bin/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/local/sbin/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/local/bin/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/sbin/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/bin/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/sbin/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)
execve("/bin\n/mkfs.btrfs", ["mkfs.btrfs", "-f", "test.img"], [/* 41 vars */]) = -1 ENOENT (No such file or directory)

What? the path is /bin\n/mkfs.btrfs? That is clearly why it is wrong. Hypothesis is that it is picking up the "\n" from the end of the $PATH env string. Add a dummy path at the end and it works!

PATH=$PATH:/bin/dummy
root@lenovo:~# mkfs -t btrfs -f test.img
btrfs-progs v4.0
See http://btrfs.wiki.kernel.org for more information.

Turning ON incompat feature 'extref': increased hardlink limit per file to 65536
Turning ON incompat feature 'skinny-metadata': reduced-size metadata extent refs
ERROR: device scan failed 'test.img' - Block device required
fs created label (null) on test.img
 nodesize 16384 leafsize 16384 sectorsize 4096 size 1.00GiB

Can this be fixed as it's screwing up a lot of regression tests we're doing with btrfs

affects: fwts → util-linux-ng
Steve Langasek (vorlon)
affects: util-linux-ng → util-linux (Ubuntu)
Revision history for this message
Steve Langasek (vorlon) wrote :

this bug has been present upstream in util-linux for a decade, but has been exposed by btrfs-tools in wily moving mkfs.btrfs from /sbin to /bin.

Changed in util-linux (Debian):
status: Unknown → New
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package util-linux - 2.26.2-6ubuntu2

---------------
util-linux (2.26.2-6ubuntu2) wily; urgency=medium

  * debian/patches/no-newline-in-path.patch: mkfs: Don't append newline
    to $PATH variable. Closes LP: #1474473.

 -- Steve Langasek <email address hidden> Tue, 21 Jul 2015 15:07:53 -0700

Changed in util-linux (Ubuntu):
status: New → Fix Released
Changed in util-linux (Debian):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.