diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile --- a/lib/libutil/Makefile +++ b/lib/libutil/Makefile @@ -10,7 +10,7 @@ SHLIB_MAJOR= 9 SRCS= _secure_path.c auth.c cpuset.c expand_number.c flopen.c fparseln.c \ - ftime.c getlocalbase.c gr_util.c \ + ftime.c getlocalbase.c getmntopts.c gr_util.c \ hexdump.c humanize_number.c kinfo_getfile.c \ kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ kinfo_getvmobject.c kld.c \ @@ -18,7 +18,7 @@ login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \ pidfile.c property.c pty.c pw_scan.c pw_util.c quotafile.c \ realhostname.c stub.c trimdomain.c uucplock.c -INCS= libutil.h login_cap.h +INCS= libutil.h login_cap.h mntopts.h CFLAGS+= -DNO__SCCSID @@ -54,6 +54,14 @@ login_times.3 in_ltms.3 \ login_times.3 in_lts.3 \ login_times.3 parse_lt.3 +MLINKS+=mntopts.3 getmntopts.3 \ + mntopts.3 getmntpoint.3 \ + mntopts.3 chkdoreload.3 \ + mntopts.3 build_iovec.3 \ + mntopts.3 build_iovec_argf.3 \ + mntopts.3 free_iovec.3 \ + mntopts.3 checkpath.3 \ + mntopts.3 rmslashes.3 \ MLINKS+=pidfile.3 pidfile_close.3 \ pidfile.3 pidfile_fileno.3 \ pidfile.3 pidfile_open.3 \ diff --git a/sbin/mount/getmntopts.c b/lib/libutil/getmntopts.c rename from sbin/mount/getmntopts.c rename to lib/libutil/getmntopts.c diff --git a/sbin/mount/mntopts.h b/lib/libutil/mntopts.h rename from sbin/mount/mntopts.h rename to lib/libutil/mntopts.h diff --git a/sbin/mount/mntopts.3 b/lib/libutil/mntopts.3 rename from sbin/mount/mntopts.3 rename to lib/libutil/mntopts.3 --- a/sbin/mount/mntopts.3 +++ b/lib/libutil/mntopts.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd January 19, 2023 +.Dd April 21, 2025 .Dt MNTOPTS 3 .Os .Sh NAME @@ -35,6 +35,8 @@ .Nm checkpath , .Nm rmslashes .Nd "mount point operations" +.Sh LIBRARY +.Lb libutil .Sh SYNOPSIS .In mntopts.h .Ft void @@ -69,18 +71,6 @@ The .Nm mntopts functions support operations associated with a mount point. -For historic reasons are in a file in the sources for the -.Xr mount 8 -program. -Thus, to access them the following lines need to be added to the -.Nm Makefile -of the program wanting to use them: -.Bd -literal -SRCS+= getmntopts.c -MOUNT= ${SRCTOP}/sbin/mount -CFLAGS+= -I${MOUNT} -\&.PATH: ${MOUNT} -.Ed .Pp The .Fn getmntopts @@ -326,7 +316,7 @@ entry. This can be declared and used as follows: .Bd -literal -#include "mntopts.h" +#include struct mntopt mopts[] = { MOPT_STDOPTS, @@ -377,3 +367,11 @@ .Fn chkdoreload functions were added in .Fx 13.2 . +.Pp +Historically, these functions were found in getmntopts.c in the sources for the +.Xr mount 8 +program. +As of +.Fx 15.0 +they are part of the +.Lb libutil . diff --git a/sbin/fsck/Makefile b/sbin/fsck/Makefile --- a/sbin/fsck/Makefile +++ b/sbin/fsck/Makefile @@ -3,10 +3,7 @@ PACKAGE=runtime PROG= fsck SRCS= fsck.c fsutil.c preen.c -SRCS+= getmntopts.c MAN= fsck.8 -MOUNT= ${SRCTOP}/sbin/mount -CFLAGS+= -I${MOUNT} -.PATH: ${MOUNT} +LIBADD= util .include diff --git a/sbin/fsck_ffs/Makefile b/sbin/fsck_ffs/Makefile --- a/sbin/fsck_ffs/Makefile +++ b/sbin/fsck_ffs/Makefile @@ -5,12 +5,12 @@ MAN= fsck_ffs.8 MLINKS= fsck_ffs.8 fsck_ufs.8 fsck_ffs.8 fsck_4.2bsd.8 SRCS= dir.c ea.c fsutil.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c \ - pass4.c pass5.c setup.c suj.c utilities.c gjournal.c getmntopts.c \ + pass4.c pass5.c setup.c suj.c utilities.c gjournal.c \ globs.c -LIBADD= ufs +LIBADD= ufs util WARNS?= 2 -CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/mount +CFLAGS+= -I${.CURDIR} -.PATH: ${SRCTOP}/sys/ufs/ffs ${.CURDIR:H}/mount +.PATH: ${SRCTOP}/sys/ufs/ffs .include diff --git a/sbin/growfs/Makefile b/sbin/growfs/Makefile --- a/sbin/growfs/Makefile +++ b/sbin/growfs/Makefile @@ -3,13 +3,10 @@ .include -.PATH: ${.CURDIR:H}/mount - PACKAGE=ufs PROG= growfs -SRCS= growfs.c getmntopts.c +SRCS= growfs.c MAN= growfs.8 -CFLAGS+=-I${.CURDIR:H}/mount .if defined(GFSDBG) SRCS+= debug.c diff --git a/sbin/init/Makefile b/sbin/init/Makefile --- a/sbin/init/Makefile +++ b/sbin/init/Makefile @@ -1,7 +1,6 @@ CONFGROUPS= CONFTTYS PACKAGE=runtime PROG= init -SRCS= init.c getmntopts.c MAN= init.8 PRECIOUSPROG= INSTALLFLAGS=-b -B.bak @@ -11,11 +10,6 @@ CONFTTYSNAME= ttys CONFTTYS+= ttys -# Needed for getmntopts.c -MOUNT= ${SRCTOP}/sbin/mount -CFLAGS+=-I${MOUNT} -.PATH: ${MOUNT} - NO_SHARED?= YES .include diff --git a/sbin/mksnap_ffs/Makefile b/sbin/mksnap_ffs/Makefile --- a/sbin/mksnap_ffs/Makefile +++ b/sbin/mksnap_ffs/Makefile @@ -2,11 +2,10 @@ PACKAGE=ufs PROG= mksnap_ffs -SRCS= mksnap_ffs.c getmntopts.c +LIBADD= util MAN= mksnap_ffs.8 WARNS?= 2 -CFLAGS+=-I${.CURDIR:H}/mount .if defined(NOSUID) BINMODE=554 diff --git a/sbin/mount/Makefile b/sbin/mount/Makefile --- a/sbin/mount/Makefile +++ b/sbin/mount/Makefile @@ -1,15 +1,7 @@ PACKAGE=runtime PROG= mount -SRCS= mount.c mount_fs.c getmntopts.c vfslist.c -MAN= mntopts.3 mount.8 -MLINKS+= mntopts.3 getmntopts.3 -MLINKS+= mntopts.3 getmntpoint.3 -MLINKS+= mntopts.3 chkdoreload.3 -MLINKS+= mntopts.3 build_iovec.3 -MLINKS+= mntopts.3 build_iovec_argf.3 -MLINKS+= mntopts.3 free_iovec.3 -MLINKS+= mntopts.3 checkpath.3 -MLINKS+= mntopts.3 rmslashes.3 +SRCS= mount.c mount_fs.c vfslist.c +MAN= mount.8 LIBADD= util xo diff --git a/sbin/mount_cd9660/Makefile b/sbin/mount_cd9660/Makefile --- a/sbin/mount_cd9660/Makefile +++ b/sbin/mount_cd9660/Makefile @@ -1,16 +1,10 @@ PACKAGE=runtime PROG= mount_cd9660 -SRCS= mount_cd9660.c getmntopts.c MAN= mount_cd9660.8 -LIBADD= kiconv - -MOUNT= ${.CURDIR:H}/mount -CFLAGS+= -I${MOUNT} +LIBADD= kiconv util # Needs to be dynamically linked for optional dlopen() access to # userland libiconv NO_SHARED?= NO -.PATH: ${MOUNT} - .include diff --git a/sbin/mount_fusefs/Makefile b/sbin/mount_fusefs/Makefile --- a/sbin/mount_fusefs/Makefile +++ b/sbin/mount_fusefs/Makefile @@ -20,12 +20,7 @@ PACKAGE=runtime PROG= mount_fusefs -SRCS= mount_fusefs.c getmntopts.c MAN8= mount_fusefs.8 - -MOUNT= ${.CURDIR:H}/mount -CFLAGS+= -I${MOUNT} - -.PATH: ${MOUNT} +LIBADD= util .include diff --git a/sbin/mount_msdosfs/Makefile b/sbin/mount_msdosfs/Makefile --- a/sbin/mount_msdosfs/Makefile +++ b/sbin/mount_msdosfs/Makefile @@ -1,19 +1,10 @@ -# -# - PACKAGE=runtime PROG= mount_msdosfs -SRCS= mount_msdosfs.c getmntopts.c MAN= mount_msdosfs.8 -LIBADD= kiconv - -MOUNT= ${.CURDIR:H}/mount -CFLAGS+= -I${MOUNT} +LIBADD= kiconv util # Needs to be dynamically linked for optional dlopen() access to # userland libiconv NO_SHARED?= NO -.PATH: ${MOUNT} - .include diff --git a/sbin/mount_nfs/Makefile b/sbin/mount_nfs/Makefile --- a/sbin/mount_nfs/Makefile +++ b/sbin/mount_nfs/Makefile @@ -1,12 +1,12 @@ PACKAGE=nfs PROG= mount_nfs -SRCS= mount_nfs.c getmntopts.c mounttab.c +SRCS= mount_nfs.c mounttab.c MAN= mount_nfs.8 +LIBADD= util -MOUNT= ${.CURDIR:H}/mount UMNTALL= ${SRCTOP}/usr.sbin/rpc.umntall -CFLAGS+= -DNFS -I${MOUNT} -I${UMNTALL} +CFLAGS+= -DNFS -I${UMNTALL} -.PATH: ${MOUNT} ${UMNTALL} +.PATH: ${UMNTALL} .include diff --git a/sbin/mount_nullfs/Makefile b/sbin/mount_nullfs/Makefile --- a/sbin/mount_nullfs/Makefile +++ b/sbin/mount_nullfs/Makefile @@ -1,11 +1,6 @@ PACKAGE=runtime PROG= mount_nullfs -SRCS= mount_nullfs.c getmntopts.c MAN= mount_nullfs.8 - -MOUNT= ${.CURDIR:H}/mount -CFLAGS+=-I${MOUNT} - -.PATH: ${MOUNT} +LIBADD= util .include diff --git a/sbin/mount_udf/Makefile b/sbin/mount_udf/Makefile --- a/sbin/mount_udf/Makefile +++ b/sbin/mount_udf/Makefile @@ -1,12 +1,7 @@ PACKAGE=runtime PROG= mount_udf -SRCS= mount_udf.c getmntopts.c MAN= mount_udf.8 -LIBADD= kiconv - -MOUNT= ${.CURDIR:H}/mount -CFLAGS+= -I${MOUNT} -I${SRCTOP}/sys -.PATH: ${MOUNT} +LIBADD= kiconv util # Needs to be dynamically linked for optional dlopen() access to # userland libiconv diff --git a/sbin/mount_unionfs/Makefile b/sbin/mount_unionfs/Makefile --- a/sbin/mount_unionfs/Makefile +++ b/sbin/mount_unionfs/Makefile @@ -1,11 +1,6 @@ PACKAGE=runtime PROG= mount_unionfs -SRCS= mount_unionfs.c getmntopts.c MAN= mount_unionfs.8 - -MOUNT= ${.CURDIR:H}/mount -CFLAGS+=-I${MOUNT} - -.PATH: ${MOUNT} +LIBADD= util .include diff --git a/sbin/tunefs/Makefile b/sbin/tunefs/Makefile --- a/sbin/tunefs/Makefile +++ b/sbin/tunefs/Makefile @@ -1,13 +1,8 @@ PACKAGE=ufs PROG= tunefs -SRCS= tunefs.c getmntopts.c -LIBADD= ufs +LIBADD= ufs util MAN= tunefs.8 -MOUNT= ${SRCTOP}/sbin/mount -CFLAGS+= -I${MOUNT} -.PATH: ${MOUNT} - WARNS?= 3 .include diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -55,7 +55,6 @@ .for p in ${GTESTS} SRCS.$p+= ${p}.cc -SRCS.$p+= getmntopts.c SRCS.$p+= mockfs.cc SRCS.$p+= utils.cc .endfor @@ -68,7 +67,6 @@ TEST_METADATA+= timeout=10 FUSEFS= ${SRCTOP}/sys/fs/fuse -MOUNT= ${SRCTOP}/sbin/mount # Suppress warnings that GCC generates for the libc++ and gtest headers. CXXWARNFLAGS.gcc+= -Wno-placement-new -Wno-attributes # Suppress Wcast-align for readdir.cc, because it is unavoidable when using @@ -87,8 +85,6 @@ .endif CXXFLAGS+= -I${SRCTOP}/tests CXXFLAGS+= -I${FUSEFS} -CXXFLAGS+= -I${MOUNT} -.PATH: ${MOUNT} LIBADD+= pthread LIBADD+= gmock gtest diff --git a/usr.sbin/autofs/Makefile b/usr.sbin/autofs/Makefile --- a/usr.sbin/autofs/Makefile +++ b/usr.sbin/autofs/Makefile @@ -6,7 +6,6 @@ SRCS+= autounmountd.c SRCS+= common.c SRCS+= defined.c -SRCS+= getmntopts.c SRCS+= log.c SRCS+= popen.c SRCS+= token.l @@ -18,15 +17,9 @@ LIBADD= util -# Needed for getmntopts.c -MOUNT= ${SRCTOP}/sbin/mount -CFLAGS+=-I${MOUNT} - LINKS= ${BINDIR}/automountd ${BINDIR}/automount LINKS+= ${BINDIR}/automountd ${BINDIR}/autounmountd -.PATH: ${MOUNT} - SUBDIR= autofs .include diff --git a/usr.sbin/mount_smbfs/Makefile b/usr.sbin/mount_smbfs/Makefile --- a/usr.sbin/mount_smbfs/Makefile +++ b/usr.sbin/mount_smbfs/Makefile @@ -1,15 +1,12 @@ PROG= mount_smbfs PACKAGE= smbutils -SRCS= mount_smbfs.c getmntopts.c MAN= mount_smbfs.8 -MOUNTDIR= ${SRCTOP}/sbin/mount CONTRIBDIR= ${SRCTOP}/contrib/smbfs -CFLAGS+= -DSMBFS -I${MOUNTDIR} -I${CONTRIBDIR}/include +CFLAGS+= -DSMBFS -I${CONTRIBDIR}/include -LIBADD= smb +LIBADD= smb util .PATH: ${CONTRIBDIR}/mount_smbfs -.PATH: ${MOUNTDIR} .include diff --git a/usr.sbin/mountd/Makefile b/usr.sbin/mountd/Makefile --- a/usr.sbin/mountd/Makefile +++ b/usr.sbin/mountd/Makefile @@ -1,13 +1,8 @@ PROG= mountd -SRCS= mountd.c getmntopts.c MAN= exports.5 netgroup.5 mountd.8 -MOUNT= ${SRCTOP}/sbin/mount -CFLAGS+= -I${MOUNT} WARNS?= 2 -.PATH: ${MOUNT} - LIBADD= util .include