[patch] Proposal: move getmntopts(3) into libutil

From: Sergey Kandaurov <pluknet_at_gmail.com>
Date: Tue, 26 Feb 2013 14:39:26 +0300
Hi.

The functions from sbin/mount/getmntopts.c are used in a bunch of other
stuff like mount_* utilities which have to suck them in as their own
functions in quite a hackish way. getmntopts.c copies are compiled in to
an every utility-consumer instead of being present in one place.  Looks
like getmntopts.c was brought together with mount_ufs.c in 4.4BSD-Lite.
After that other mount_* were converted to use getmntopts().

The utilities consuming getmntopts.c as currently present in HEAD:
mount_smbfs
fsck_ffs
growfs
mksnap_ffs
mount
mount_cd9660
mount_ext2fs
mount_fusefs
mount_hpfs
mount_msdosfs
mount_nfs
mount_nullfs
mount_reiserfs
mount_std
mount_udf
mount_unionfs
mount_nwfs
mount_portalfs
mount_smbfs
mountd

External mount-like utilities may also have difficulties with building
to get getmntopts.c source as this requires /usr/src presence which is
in sync with installed world. Look how mount_fusefs from ports compiles:
# mount_fusefs needs mntopts.h and getmntopts.c from src/sbin/mount/

The attached patch moves them to the IMHO architecturally more correct
place: a separate library -lutil.
sbin/mount/mntopts.h            -> include/mntopts.h
sbin/mount/getmntopts.[3c]      -> lib/libutil/getmntopts.[3c]

The full list of functions in getmntopts.c:
getmntopts()
rmslashes()
checkpath()
build_iovec()
build_iovec_argf()

This will eventually give them public and documented status. It will
also bring back to live its semi-dead man page getmntopts(3) currently
disconnected from build, that will force us to update (and use) it which
is also a goody. getmntopts.3 was never installed.

As a bonus, it will bring us in sync with others BSDs.

The attached patch was buildworld-tested and contains only minimal changes;
getmntopts(3) updates and other improvements could be made separately.
- rearrange files from sbin/mount/ to the new place
- update Makefiles's of mount_* to use getmntopts(3) from libutil
- #include "mntopts.h" -> #include <mntopts.h>

Well, the include changes should be safe to commit as is.

Below is a changelist from svn stat, for convenience 'sake.
M       contrib/smbfs/mount_smbfs/mount_smbfs.c
M       include/Makefile
A  +    include/mntopts.h
M       lib/libutil/Makefile
A  +    lib/libutil/getmntopts.3
A  +    lib/libutil/getmntopts.c
M       sbin/fsck_ffs/Makefile
M       sbin/growfs/Makefile
M       sbin/mksnap_ffs/Makefile
M       sbin/mount/Makefile
D       sbin/mount/getmntopts.3
D       sbin/mount/getmntopts.c
D       sbin/mount/mntopts.h
M       sbin/mount/mount.c
M       sbin/mount/mount_fs.c
M       sbin/mount_cd9660/Makefile
M       sbin/mount_cd9660/mount_cd9660.c
M       sbin/mount_ext2fs/Makefile
M       sbin/mount_ext2fs/mount_ext2fs.c
M       sbin/mount_fusefs/Makefile
M       sbin/mount_fusefs/mount_fusefs.c
M       sbin/mount_hpfs/Makefile
M       sbin/mount_hpfs/mount_hpfs.c
M       sbin/mount_msdosfs/Makefile
M       sbin/mount_msdosfs/mount_msdosfs.c
M       sbin/mount_nfs/Makefile
M       sbin/mount_nfs/mount_nfs.c
M       sbin/mount_ntfs/Makefile
M       sbin/mount_ntfs/mount_ntfs.c
M       sbin/mount_nullfs/Makefile
M       sbin/mount_nullfs/mount_nullfs.c
M       sbin/mount_reiserfs/Makefile
M       sbin/mount_reiserfs/mount_reiserfs.c
M       sbin/mount_std/Makefile
M       sbin/mount_std/mount_std.c
M       sbin/mount_udf/Makefile
M       sbin/mount_udf/mount_udf.c
M       sbin/mount_unionfs/Makefile
M       sbin/mount_unionfs/mount_unionfs.c
M       usr.sbin/mount_nwfs/Makefile
M       usr.sbin/mount_nwfs/mount_nwfs.c
M       usr.sbin/mount_portalfs/Makefile
M       usr.sbin/mount_portalfs/mount_portalfs.c
M       usr.sbin/mount_smbfs/Makefile
M       usr.sbin/mountd/Makefile
M       usr.sbin/mountd/mountd.c

-- 
wbr,
pluknet

Received on Tue Feb 26 2013 - 10:39:28 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:35 UTC