Date: Thu, 23 Nov 2017 08:49:40 -0000
| raw e-mail | index | archive | help
CPT TO:<freebsd-hackers@freebsd.org> DATA Received: from donotpassgo.dyslexicfish.net (donotpassgo.dyslexicfish.net [104.207.135.49]) by donotpassgo.dyslexicfish.net (8.14.5/8.14.5) with ESMTP id vAKGdAdt099456; Mon, 20 Nov 2017 16:39:11 GMT (envelope-from jamie@donotpassgo.dyslexicfish.net) Received: (from jamie@localhost) by donotpassgo.dyslexicfish.net (8.14.5/8.14.5/Submit) id vAKGdA0m099455; Mon, 20 Nov 2017 16:39:10 GMT (envelope-from jamie) From: Jamie Landeg-Jones <jamie@dyslexicfish.net> Message-Id: <201711201639.vAKGdA0m099455@donotpassgo.dyslexicfish.net> Date: Mon, 20 Nov 2017 16:39:10 +0000 Organization: Dyslexic Fish To: trasz@freebsd.org, freebsd-current@freebsd.org, freebsd-hackers@freebsd.org Cc: jamie@catflap.org Subject: getfsstat / nullsfs / automount bug? User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit There appears to be a bug in the system call related to getmntinfo(3) / getfsstat(2) , when if the "automount" flag is set on "nullfs" mounts, it is not returned on a getfsstat "WAIT" call. The non-refreshed, non-blocking "MNT_NOWAIT" produces the correct result. I first noticed this when debugging why my nullfs autofs partitions weren't being automatically unmounted. (FreeBSD current and release) The somewhat hacked snippet from automount.c in the example below demonstrates this - When called with no parameters, it performs a MNT_WAIT request, otherwise a MNT_NOWAIT request is performed: Cheers, Jamie | #include <stdio.h> | #include <string.h> | #include <sys/mount.h> | | int main(int argc, char **argv) | { | struct statfs *mntbuf; | int i, nitems; | | nitems = getmntinfo(&mntbuf, (argc == 1) ? MNT_WAIT : MNT_NOWAIT); | if (nitems <= 0) | printf ("getmntinfo fail\n"); | | for (i = 0; i < nitems; i++) { | if (strcmp(mntbuf[i].f_fstypename, "autofs") == 0) { | printf("skipping %s, filesystem type is autofs\n", | mntbuf[i].f_mntonname); | continue; | } | | if ((mntbuf[i].f_flags & MNT_AUTOMOUNTED) == 0) { | printf("skipping %s, not automounted\n", | mntbuf[i].f_mntonname); | continue; | } | | printf("%s IS automounted!!!!!!!!!\n", | mntbuf[i].f_mntonname); | } | } | 14:24 [2] (1) "autofs" root@thompson# df | Filesystem 1K-blocks Used Avail Capacity Mounted on | /dev/ada1p2 5061628 707264 3949436 15% / | devfs 1 1 0 100% /dev | /dev/ada1p4 5061628 535004 4121696 11% /var | /dev/ada1p5 978973296 21689416 878966020 2% /usr | | 14:24 [2] (2) "autofs" root@thompson# mount | /dev/ada1p2 on / (ufs, local) | devfs on /dev (devfs, local, multilabel) | /dev/ada1p4 on /var (ufs, local, soft-updates) | /dev/ada1p5 on /usr (ufs, local, soft-updates) | | 14:25 [2] (3) "autofs" root@thompson# mkdir /tmp/automounted /tmp/manual | | 14:25 [2] (4) "autofs" root@thompson# mount -t nullfs -o ro /usr/src /tmp/manual | | 14:25 [2] (5) "autofs" root@thompson# mount -t nullfs -o ro,automounted /usr/src /tmp/automounted/ | | 14:26 [2] (6) "autofs" root@thompson# df | Filesystem 1K-blocks Used Avail Capacity Mounted on | /dev/ada1p2 5061628 707264 3949436 15% / | devfs 1 1 0 100% /dev | /dev/ada1p4 5061628 535004 4121696 11% /var | /dev/ada1p5 978973296 21689420 878966016 2% /usr | /usr/src 978973296 21689420 878966016 2% /tmp/manual | /usr/src 978973296 21689420 878966016 2% /tmp/automounted | | 14:26 [2] (7) "autofs" root@thompson# mount | /dev/ada1p2 on / (ufs, local) | devfs on /dev (devfs, local, multilabel) | /dev/ada1p4 on /var (ufs, local, soft-updates) | /dev/ada1p5 on /usr (ufs, local, soft-updates) | /usr/src on /tmp/manual (nullfs, local, read-only) | /usr/src on /tmp/automounted (nullfs, local, read-only, automounted) | | 14:26 [2] (8) "autofs" root@thompson# ./a.out | skipping /, not automounted | skipping /dev, not automounted | skipping /var, not automounted | skipping /usr, not automounted | skipping /tmp/manual, not automounted | skipping /tmp/automounted, not automounted | | 14:26 [2] (9) "autofs" root@thompson# ./a.out x | skipping /, not automounted | skipping /dev, not automounted | skipping /var, not automounted | skipping /usr, not automounted | skipping /tmp/manual, not automounted | /tmp/automounted IS automounted!!!!!!!!! .
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?>