Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Apr 2017 10:40:58 -0700
From:      Maxim Sobolev <sobomax@freebsd.org>
To:        Kirk McKusick <mckusick@mckusick.com>, FreeBSD Filesystems <freebsd-fs@freebsd.org>
Subject:   mksnap_ffs(8) is not working while chrooted
Message-ID:  <CAH7qZfvO9AjiZM0FyHqRBzp-KN4u=7Pq4Y2xNhQ2W4t53rApTQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi Kirk et al,

I've stumbled upon problem that it is impossible to use mksnap_ffs(8) while
in the chrooted environment. Other utilities that manipulate fs'es (i.e.
mount(8) / umount(8)) work just fine. Quick glance through the code shows
that the problem stems from the fact that mksnap_ffs uses f_mntonname
returned by the statfs(2) system call to fill fspath parameter for the
nmount call. And the statfs() returns f_mntonname path outside chroot. As
far as I can see, there are two options to address this issue.

1. Adjust statfs(2) system call to substract chroot prefix while
returning f_mntonname. Similar to what prison_enforce_statfs() function
does for jails.

2. Enhance nmount(2) to allow taking FSID in place of mount path to do
resolution using existing flag MNT_BYFSID and adjust mksnap_ffs to use that
instead. This is what umount(8) does to work around the problem.

Which of two approaches would be preferred solution if any? The second one
seems a bit simpler to me. Please advise. Thanks!

-Max



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAH7qZfvO9AjiZM0FyHqRBzp-KN4u=7Pq4Y2xNhQ2W4t53rApTQ>