Bug #1253

mount -p reports bogus errors in chroot

Added by corecode almost 6 years ago. Updated almost 6 years ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

% mount -p
/dev/vinum/root / ufs rw 1 1
/dev/vinum/tmp /tmp ufs rw 2 2
/dev/vinum/var /var ufs rw 2 2
/dev/vinum/home /home ufs rw 2 2
/dev/vinum/usr /usr ufs rw 2 2
/dev/vinum/usrobj /usr/obj ufs rw 2 2
procfs /proc procfs rw 0 0
/dev/vinum/jail_serve /jail/serve ufs rw 2 2
/dev/vinum/jail_serve_repos /jail/serve/home/repos ufs rw,noatime 2 2
/dev/vinum/jail_serve_ftp /jail/serve/home/ftp ufs rw,noatime 2 2
/dev/vinum/jail_isobuild /jail/isobuild ufs rw,noatime 2 2
/dev/vinum/jail_isobuild_data /jail/isobuild/home/chroot ufs rw,noatime 2 2
/jail/serve/home/repos /jail/isobuild/home/repos null ro,noatime 0 0
/usr/pkgsrc /jail/isobuild/home/chroot/chroot/usr/release/root/usr/pkgsrc
null rw 0 0

% sudo chroot /jail/isobuild /bin/tcsh
# mount -p
fstab: /etc/fstab:0: No such file or directory
fstab: /etc/fstab:0: No such file or directory
/dev/vinum/jail_isobuild / ufs rw,noatime 1 1
fstab: /etc/fstab:0: No such file or directory
fstab: /etc/fstab:0: No such file or directory
/dev/vinum/jail_isobuild_data /home/chroot ufs rw,noatime 2 2
fstab: /etc/fstab:0: No such file or directory
fstab: /etc/fstab:0: No such file or directory
/jail/serve/home/repos /home/repos null ro,noatime 0 0
fstab: /etc/fstab:0: No such file or directory
fstab: /etc/fstab:0: No such file or directory
/usr/pkgsrc /home/chroot/chroot/usr/release/root/usr/pkgsrc null rw 0 0

# mount
/dev/vinum/jail_isobuild on / (ufs, local, noatime, soft-updates)
/dev/vinum/jail_isobuild_data on /home/chroot (ufs, local, noatime, soft-updates)
/jail/serve/home/repos on /home/repos (null, local, noatime, read-only)
/usr/pkgsrc on /home/chroot/chroot/usr/release/root/usr/pkgsrc (null, local)

History

#1 Updated by Anonymous almost 6 years ago

jail(8) says that you must create an empty /etc/fstab to suppress the warnings:

"Create an empty /etc/fstab to quell startup warnings about missing fstab"

Indeed:
# mount -p
fstab: /etc/fstab:0: No such file or directory
fstab: /etc/fstab:0: No such file or directory
/dev/ad0s3f / ufs rw 1 1
# touch /etc/fstab
# mount -p
/dev/ad0s3f / ufs rw 1 1
#

sjg at #drafonflybsd suggested that a "fix" (if agree there is a need for one)
woule be to only check for fstab once; if it doesn't exist, print an error, and
fall back to the non- "p" case.

What do you think ?

#2 Updated by corecode almost 6 years ago

I don't think it should print a warning at all. This is not the time and
place to print a totally unrelated warning.

cheers
simon

#3 Updated by Anonymous almost 6 years ago

One could ask why mount -p needs /etc/fstab to list the *already* mounted
filesystems. This happens because device block name, mount point and mount flags
are stored inside the statfs structure (which is returned by getfsstat syscall),
but dump frequency and pass number of fsck are not. This means that mount -p
must open /etc/fstab, parse the lines and get the desired values for every
mounted filesystem.

Thats why simon you get 2 warnings for every mounted filesystem. One while
looking for freq and another one for passno.

The code path that interests us is I think the following:

for every mounted filesystem
---> putfsent
--------> getfsspec
--------------> setfsent [ opens etc/fstab, prints warning ]
--------> getfsfile
--------------> setfsent [ opens etc/fstab, prints warning ]

The reason that freq and passno values are printed, is that there are some
fallback values in the code.

Honestly I don't know how to fix this. The code is messy enough as it is and
adding more cornerstones would make it worse.

Regards,
Stathis

#4 Updated by Anonymous almost 6 years ago

Alright, I am working on a patch. I'll let you know.

#6 Updated by Anonymous almost 6 years ago

Updated patch, based on discussion with Simon in #dragonflybsd

http://stathisk.ath.cx/0001-Silent-mount-p-when-there-is-no-fstab-file.patch

#7 Updated by dillon almost 6 years ago

:Stathis Kamperis <> added the comment:
:
:Updated patch, based on discussion with Simon in #dragonfly
:
:http://stathisk.ath.cx/0001-Silent-mount-p-when-there-is-no-fstab-file.patch

Looks reasonable, but please put in matching braces. If either
part of an if statement sequence uses a braced block then both
parts should use a braced block. Just semantics but it makes the
code more readable.

-Matt
Matthew Dillon
<>

#8 Updated by Anonymous almost 6 years ago

Thanks for the feedback.

Matching braces added. Updated patch in the same link as before.

#9 Updated by dillon almost 6 years ago

:Stathis Kamperis <> added the comment:
:
:Updated patch, based on discussion with Simon in #dragonflybsd
:
:http://stathisk.ath.cx/0001-Silent-mount-p-when-there-is-no-fstab-file.patch

Looks good, I will commit it on Tuesday.

-Matt
Matthew Dillon
<>

#10 Updated by corecode almost 6 years ago

committed as 3e5c58ea9fae3002473278841dec7b456daffe95

Also available in: Atom PDF