diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile index 8178d33b7ba8..0639745d08fc 100644 --- a/lib/libutil/Makefile +++ b/lib/libutil/Makefile @@ -1,93 +1,103 @@ SHLIBDIR?= /lib .include PACKAGE= runtime .PATH: ${SRCTOP}/lib/libc/gen # for pw_scan.c LIB= util 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 \ hexdump.c humanize_number.c kinfo_getfile.c \ kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ kinfo_getvmobject.c kld.c \ login_auth.c login_cap.c \ login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \ + mntopts.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 .if ${MK_INET6_SUPPORT} != "no" CFLAGS+= -DINET6 .endif CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ MAN+= cpuset.3 expand_number.3 flopen.3 fparseln.3 ftime.3 getlocalbase.3 \ hexdump.3 humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \ login_auth.3 login_cap.3 \ - login_class.3 login_ok.3 login_times.3 login_tty.3 pidfile.3 \ + login_class.3 login_ok.3 login_times.3 login_tty.3 mntopts.3 \ + pidfile.3 \ property.3 pty.3 quotafile.3 realhostname.3 realhostname_sa.3 \ _secure_path.3 trimdomain.3 uucplock.3 pw_util.3 MAN+= login.conf.5 MLINKS+=flopen.3 flopenat.3 MLINKS+=kld.3 kld_isloaded.3 kld.3 kld_load.3 MLINKS+=login_auth.3 auth_cat.3 login_auth.3 auth_checknologin.3 MLINKS+=login_cap.3 login_close.3 login_cap.3 login_getcapbool.3 \ login_cap.3 login_getcaplist.3 login_cap.3 login_getcapnum.3 \ login_cap.3 login_getcapsize.3 login_cap.3 login_getcapstr.3 \ login_cap.3 login_getcaptime.3 login_cap.3 login_getclass.3 \ login_cap.3 login_getclassbyname.3 login_cap.3 login_getpath.3 \ login_cap.3 login_getpwclass.3 login_cap.3 login_getstyle.3 \ login_cap.3 login_getuserclass.3 login_cap.3 login_setcryptfmt.3 MLINKS+=login_class.3 setclasscontext.3 login_class.3 setclassenvironment.3 \ login_class.3 setclassresources.3 login_class.3 setusercontext.3 MLINKS+=login_ok.3 auth_hostok.3 login_ok.3 auth_timeok.3 \ login_ok.3 auth_ttyok.3 MLINKS+=login_times.3 in_lt.3 login_times.3 in_ltm.3 \ 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 \ pidfile.3 pidfile_remove.3 \ pidfile.3 pidfile_write.3 MLINKS+=property.3 property_find.3 property.3 properties_free.3 MLINKS+=property.3 properties_read.3 MLINKS+=pty.3 forkpty.3 pty.3 openpty.3 MLINKS+=quotafile.3 quota_close.3 \ quotafile.3 quota_fsname.3 \ quotafile.3 quota_open.3 \ quotafile.3 quota_qfname.3 \ quotafile.3 quota_read.3 \ quotafile.3 quota_statfs.3 \ quotafile.3 quota_write_limits.3 \ quotafile.3 quota_write_usage.3 MLINKS+=uucplock.3 uu_lock.3 uucplock.3 uu_lock_txfr.3 \ uucplock.3 uu_lockerr.3 uucplock.3 uu_unlock.3 MLINKS+=pw_util.3 pw_copy.3 \ pw_util.3 pw_dup.3 \ pw_util.3 pw_edit.3 \ pw_util.3 pw_equal.3 \ pw_util.3 pw_fini.3 \ pw_util.3 pw_init.3 \ pw_util.3 pw_make.3 \ pw_util.3 pw_make_v7.3 \ pw_util.3 pw_mkdb.3 \ pw_util.3 pw_lock.3 \ pw_util.3 pw_scan.3 \ pw_util.3 pw_tempname.3 \ pw_util.3 pw_tmp.3 MLINKS+=cpuset.3 cpuset_parselist.3 HAS_TESTS= SUBDIR.${MK_TESTS}+= tests .include diff --git a/sbin/mount/mntopts.3 b/lib/libutil/mntopts.3 similarity index 96% rename from sbin/mount/mntopts.3 rename to lib/libutil/mntopts.3 index 74fca612479f..35f6d476fcec 100644 --- a/sbin/mount/mntopts.3 +++ b/lib/libutil/mntopts.3 @@ -1,379 +1,377 @@ .\" Copyright (c) 2023 Marshall Kirk McKusick .\" Copyright (c) 1994 The Regents of the University of California. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" 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 .Nm getmntopts , .Nm getmntpoint , .Nm chkdoreload , .Nm build_iovec , .Nm build_iovec_argf , .Nm free_iovec , .Nm checkpath , .Nm rmslashes .Nd "mount point operations" +.Sh LIBRARY +.Lb libutil .Sh SYNOPSIS .In mntopts.h .Ft void .Fo getmntopts .Fa "const char *options" "const struct mntopt *mopts" .Fa "int *flagp" "int *altflagp" .Fc .Ft struct statfs * .Fn getmntpoint "const char *name" .Ft int .Fo chkdoreload .Fa "struct statfs *mntp" .Fa "void (*prtmsg)(const char *fmt, ...)" .Fc .Ft void .Fo build_iovec .Fa "struct iovec **iov" "int *iovlen" "const char *name" "void *val" .Fa "size_t len" .Fc .Ft void .Fo build_iovec_argf .Fa "struct iovec **iov" "int *iovlen" "const char *name" .Fa "const char *fmt" "..." .Fc .Ft void .Fn free_iovec "struct iovec **iov" "int *iovlen" .Ft int .Fn checkpath "const char *path" "char *resolved" .Ft void .Fn rmslashes "char *rrpin" "char *rrpout" .Sh DESCRIPTION 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 function takes a comma separated option list and a list of valid option names, and computes the bitmask corresponding to the requested set of options. .Pp The string .Fa options is broken down into a sequence of comma separated tokens. Each token is looked up in the table described by .Fa mopts and the bits in the word referenced by either .Fa flagp or .Fa altflagp (depending on the .Va m_altloc field of the option's table entry) are updated. The flag words are not initialized by .Fn getmntopts . The table, .Fa mopts , has the following format: .Bd -literal struct mntopt { char *m_option; /* option name */ int m_inverse; /* is this a negative option, e.g., "dev" */ int m_flag; /* bit to set, e.g., MNT_RDONLY */ int m_altloc; /* non-zero to use altflagp rather than flagp */ }; .Ed .Pp The members of this structure are: .Bl -tag -width m_inverse .It Va m_option the option name, for example .Dq Li suid . .It Va m_inverse tells .Fn getmntopts that the name has the inverse meaning of the bit. For example, .Dq Li suid is the string, whereas the mount flag is .Dv MNT_NOSUID . In this case, the sense of the string and the flag are inverted, so the .Va m_inverse flag should be set. .It Va m_flag the value of the bit to be set or cleared in the flag word when the option is recognized. The bit is set when the option is discovered, but cleared if the option name was preceded by the letters .Dq Li no . The .Va m_inverse flag causes these two operations to be reversed. .It Va m_altloc the bit should be set or cleared in .Fa altflagp rather than .Fa flagp . .El .Pp Each of the user visible .Dv MNT_ flags has a corresponding .Dv MOPT_ macro which defines an appropriate .Vt "struct mntopt" entry. To simplify the program interface and ensure consistency across all programs, a general purpose macro, .Dv MOPT_STDOPTS , is defined which contains an entry for all the generic VFS options. In addition, the macros .Dv MOPT_FORCE and .Dv MOPT_UPDATE exist to enable the .Dv MNT_FORCE and .Dv MNT_UPDATE flags to be set. Finally, the table must be terminated by an entry with a .Dv NULL first element. .Pp The .Fn getmntpoint function takes the pathname of a possible mount point or of a device (with or without .Pa /dev/ prepended to it). If the pathname is a directory or a file, .Fn getmntpoint checks to see if the mount point currently has a filesystem mounted on it. If the pathname is a device, .Fn getmntpoint checks to see if it is currently mounted. If there is an associated mount, a pointer to a .Vt "struct statfs" is returned. The returned result is stored in a static buffer that is over-written each time the .Fn getmntpoint function or the .Xr getmntinfo 3 library routine is called. If no mount is found, NULL is returned. .Pp The .Fn chkdoreload function takes a pointer to a .Vt "struct statfs" . If the filesystem associated with the mount point is mounted read-only, .Fn chkdoreload requests the filesystem to reload all of its metadata from its backing store. The second parameter is the function to call to print an error message if the reload fails. If no error message is desired, a .Dv NULL can be passed as the second argument. The .Fn chkdoreload function returns zero on success or non-zero on failure. .Pp The .Fn build_iovec function adds a parameter to a list of parameters to be passed to the .Xr nmount 2 system call. The parameter list is built up in .Va iov and its length is kept in .Va iovlen . Before the first call to .Fn build_iovec , .Va iov should be set to .Dv NULL and .Va iovlen should be set to 0. The parameter name is passed in .Va name . The value of the parameter name is pointed to by .Va val . The size of the value is passed in .Va len . If the value is a string, a .Va len of -1 is passed to indicate that the length should be determined using .Xr strlen 3 . If the parameter has no value, .Va name should be .Dv NULL and .Va len should be 0. .Pp The .Fn build_iovec_argf function adds a formatted parameter to a list of parameters to be passed to the .Xr nmount 2 system call. The parameter list is built up in .Va iov and its length is kept in .Va iovlen . Before the first call to .Fn build_iovec_argf , .Va iov should be set to .Dv NULL and .Va iovlen should be set to 0. The parameter name is passed in .Va name . The value of the parameter name is described by a format string pointed to by .Va fmt . If the parameter has no value, .Va name should be .Dv NULL . .Pp The .Fn free_iovec function frees the memory in the .Va iov vector of the length specified in .Va iovlen that was previously allocated by the .Fn build_iovec and / or .Fn build_iovec_argf functions. The .Va iov is set to .Dv NULL and the .Va iovlen is set to 0 to indicate that the space has been freed. .Pp The .Fn checkpath function uses .Xr realpath 3 to verify that its .Va path argument is valid and references a directory. The .Fn checkpath function returns zero on success or non-zero on failure. .Pp The .Fn rmslashes function removes all double slashes and trailing slashes from its .Va rrpin pathname parameter and returns the resulting pathname in its .Va rrpout parameter. .Sh EXAMPLES Most commands will use the standard option set. Local file systems which support the .Dv MNT_UPDATE flag, would also have an .Dv MOPT_UPDATE entry. This can be declared and used as follows: .Bd -literal -#include "mntopts.h" +#include struct mntopt mopts[] = { MOPT_STDOPTS, MOPT_UPDATE, { NULL } }; ... mntflags = mntaltflags = 0; ... getmntopts(options, mopts, &mntflags, &mntaltflags); ... .Ed .Sh DIAGNOSTICS If the external integer variable .Va getmnt_silent is zero, then the .Fn getmntopts function displays an error message and exits if an unrecognized option is encountered. Otherwise unrecognized options are silently ignored. By default .Va getmnt_silent is zero. .Sh SEE ALSO .Xr err 3 , .Xr mount 8 , .Xr nmount 8 .Sh HISTORY The .Fn getmntopts function appeared in .Bx 4.4 . The .Fn build_iovec , .Fn build_iovec_argf , .Fn free_iovec , .Fn checkpath , and .Fn rmslashes functions were added with .Xr nmount 8 in .Fx 5.0 . The .Fn getmntpoint and .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 +.Nm libutil . diff --git a/sbin/mount/getmntopts.c b/lib/libutil/mntopts.c similarity index 100% rename from sbin/mount/getmntopts.c rename to lib/libutil/mntopts.c diff --git a/sbin/mount/mntopts.h b/lib/libutil/mntopts.h similarity index 98% rename from sbin/mount/mntopts.h rename to lib/libutil/mntopts.h index dc1452097ed8..0027b8ca7155 100644 --- a/sbin/mount/mntopts.h +++ b/lib/libutil/mntopts.h @@ -1,109 +1,114 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +#ifndef _MNTOPTS_H_ +#define _MNTOPTS_H_ + struct mntopt { const char *m_option; /* option name */ int m_inverse; /* if a negative option, e.g. "atime" */ long long m_flag; /* bit to set, e.g. MNT_RDONLY */ int m_altloc; /* 1 => set bit in altflags */ }; /* User-visible MNT_ flags. */ #define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } #define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 } #define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 } #define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 } #define MOPT_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 0 } #define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 } #define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 } #define MOPT_UNION { "union", 0, MNT_UNION, 0 } #define MOPT_USERQUOTA { "userquota", 0, 0, 0 } #define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 } #define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 } #define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 } #define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 } #define MOPT_SNAPSHOT { "snapshot", 0, MNT_SNAPSHOT, 0 } #define MOPT_MULTILABEL { "multilabel", 0, MNT_MULTILABEL, 0 } #define MOPT_ACLS { "acls", 0, MNT_ACLS, 0 } #define MOPT_NFS4ACLS { "nfsv4acls", 0, MNT_NFS4ACLS, 0 } #define MOPT_AUTOMOUNTED { "automounted",0, MNT_AUTOMOUNTED, 0 } #define MOPT_UNTRUSTED { "untrusted", 0, MNT_UNTRUSTED, 0 } /* Control flags. */ #define MOPT_FORCE { "force", 0, MNT_FORCE, 0 } #define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 } #define MOPT_RO { "ro", 0, MNT_RDONLY, 0 } #define MOPT_RW { "rw", 1, MNT_RDONLY, 0 } #define MOPT_NOCOVER { "cover", 1, MNT_NOCOVER, 0 } #define MOPT_EMPTYDIR { "emptydir", 0, MNT_EMPTYDIR, 0 } /* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */ #define MOPT_AUTO { "auto", 0, 0, 0 } /* A handy macro as terminator of MNT_ array. */ #define MOPT_END { NULL, 0, 0, 0 } #define MOPT_FSTAB_COMPAT \ MOPT_RO, \ MOPT_RW, \ MOPT_AUTO /* Standard options which all mounts can understand. */ #define MOPT_STDOPTS \ MOPT_USERQUOTA, \ MOPT_GROUPQUOTA, \ MOPT_FSTAB_COMPAT, \ MOPT_NOATIME, \ MOPT_NOEXEC, \ MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \ MOPT_NOSUID, \ MOPT_NOSYMFOLLOW, \ MOPT_RDONLY, \ MOPT_UNION, \ MOPT_NOCLUSTERR, \ MOPT_NOCLUSTERW, \ MOPT_MULTILABEL, \ MOPT_ACLS, \ MOPT_NFS4ACLS, \ MOPT_AUTOMOUNTED, \ MOPT_UNTRUSTED, \ MOPT_NOCOVER, \ MOPT_EMPTYDIR void getmntopts(const char *, const struct mntopt *, int *, int *); void rmslashes(char *, char *); int checkpath(const char *, char resolved_path[]); int checkpath_allow_file(const char *, char resolved_path[]); struct statfs *getmntpoint(const char *); int chkdoreload(struct statfs *, void (*)(const char *, ...) __printflike(1,2)); extern int getmnt_silent; void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len); void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...); void free_iovec(struct iovec **iovec, int *iovlen); + +#endif /* !_MNTOPTS_H_ */ diff --git a/sbin/fsck/Makefile b/sbin/fsck/Makefile index 3273ea730dc8..33ff4784a92b 100644 --- a/sbin/fsck/Makefile +++ b/sbin/fsck/Makefile @@ -1,12 +1,9 @@ # $NetBSD: Makefile,v 1.14 1996/09/27 22:38:37 christos Exp $ 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 index 7b0f0ed822bf..c6676007db2a 100644 --- a/sbin/fsck_ffs/Makefile +++ b/sbin/fsck_ffs/Makefile @@ -1,16 +1,16 @@ PACKAGE=ufs PROG= fsck_ffs LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_ufs LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd 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 index 6fb1ba51db00..b5b3d99f287d 100644 --- a/sbin/growfs/Makefile +++ b/sbin/growfs/Makefile @@ -1,25 +1,22 @@ # $TSHeader: src/sbin/growfs/Makefile,v 1.4 2000/12/05 19:45:24 tomsoft Exp $ # .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 CFLAGS+= -DFS_DEBUG NO_WCAST_ALIGN= yes .endif LIBADD= ufs util HAS_TESTS= SUBDIR.${MK_TESTS}+= tests .include diff --git a/sbin/init/Makefile b/sbin/init/Makefile index 124a9f77dede..1fc9b633f664 100644 --- a/sbin/init/Makefile +++ b/sbin/init/Makefile @@ -1,21 +1,15 @@ CONFGROUPS= CONFTTYS PACKAGE=runtime PROG= init -SRCS= init.c getmntopts.c MAN= init.8 PRECIOUSPROG= INSTALLFLAGS=-b -B.bak CFLAGS+=-DDEBUGSHELL -DSECURE -DLOGIN_CAP -DCOMPAT_SYSV_INIT LIBADD= util crypt 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 index 591fd6adcc22..cf5079fdfa8e 100644 --- a/sbin/mksnap_ffs/Makefile +++ b/sbin/mksnap_ffs/Makefile @@ -1,19 +1,18 @@ .PATH: ${.CURDIR:H}/mount 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 .else BINMODE=4554 BINOWN= root .endif BINGRP= operator .include diff --git a/sbin/mount/Makefile b/sbin/mount/Makefile index 9b5c9b9e593d..e2a3098813c4 100644 --- a/sbin/mount/Makefile +++ b/sbin/mount/Makefile @@ -1,16 +1,8 @@ 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 .include diff --git a/sbin/mount_cd9660/Makefile b/sbin/mount_cd9660/Makefile index 3a8f9cd45cb4..9fa8e7436169 100644 --- 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 index 0c173bf1b687..e683b35f0c8a 100644 --- a/sbin/mount_fusefs/Makefile +++ b/sbin/mount_fusefs/Makefile @@ -1,31 +1,26 @@ .if defined(DEBUG) DEBUG_FLAGS+= -D_DEBUG -g .endif .if defined(DEBUG2G) DEBUG_FLAGS+= -D_DEBUG2G -g .endif .if defined(DEBUG3G) DEBUG_FLAGS+= -D_DEBUG3G -g .endif .if defined(DEBUG_MSG) DEBUG_FLAGS+= -D_DEBUG_MSG .endif .if defined(F4BVERS) DEBUG_FLAGS+= -DFUSE4BSD_VERSION="\"${F4BVERS}\"" .endif 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 index e01755b2fce2..50f07f175001 100644 --- 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 index 3e61a9f680e0..fb425106dd81 100644 --- 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 index 12e87308ed13..1844aa14b24f 100644 --- 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 index c41c051fc315..6506f6ba3985 100644 --- a/sbin/mount_udf/Makefile +++ b/sbin/mount_udf/Makefile @@ -1,15 +1,10 @@ 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 NO_SHARED?= NO .include diff --git a/sbin/mount_unionfs/Makefile b/sbin/mount_unionfs/Makefile index 2096386a3784..35e7e8fa75b7 100644 --- 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 index e236525557e1..4ea2219c8e03 100644 --- 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 index 06b82071fe31..4265f5b71dfa 100644 --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -1,97 +1,93 @@ .include PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/fs/fusefs # We could simply link all of these files into a single executable. But since # Kyua treats googletest programs as plain tests, it's better to separate them # out, so we get more granular reporting. GTESTS+= access GTESTS+= allow_other GTESTS+= bad_server GTESTS+= bmap GTESTS+= cache GTESTS+= copy_file_range GTESTS+= create GTESTS+= default_permissions GTESTS+= default_permissions_privileged GTESTS+= destroy GTESTS+= dev_fuse_poll GTESTS+= fallocate GTESTS+= fifo GTESTS+= flush GTESTS+= forget GTESTS+= fsync GTESTS+= fsyncdir GTESTS+= getattr GTESTS+= interrupt GTESTS+= io GTESTS+= last_local_modify GTESTS+= link GTESTS+= locks GTESTS+= lookup GTESTS+= lseek GTESTS+= mkdir GTESTS+= mknod GTESTS+= mount GTESTS+= nfs GTESTS+= notify GTESTS+= open GTESTS+= opendir GTESTS+= read GTESTS+= readdir GTESTS+= readlink GTESTS+= release GTESTS+= releasedir GTESTS+= rename GTESTS+= rmdir GTESTS+= setattr GTESTS+= statfs GTESTS+= symlink GTESTS+= unlink GTESTS+= write GTESTS+= xattr .for p in ${GTESTS} SRCS.$p+= ${p}.cc -SRCS.$p+= getmntopts.c SRCS.$p+= mockfs.cc SRCS.$p+= utils.cc .endfor TEST_METADATA.default_permissions+= required_user="unprivileged" TEST_METADATA.default_permissions_privileged+= required_user="root" TEST_METADATA.mknod+= required_user="root" TEST_METADATA.nfs+= required_user="root" 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 # getdirentries. CXXWARNFLAGS.readdir.cc+= -Wno-cast-align .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 80000 CXXWARNFLAGS+= -Wno-class-memaccess .endif # Suppress false warning about set but unused DNAME in inval_entry_below_root CXXWARNFLAGS.gcc+= -Wno-unused-but-set-variable # Suppress warnings about deprecated implicit copy constructors in gtest. CXXWARNFLAGS+= -Wno-deprecated-copy .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000 # clang 18.0.0 introduces a new warning about variable length arrays in C++. CXXWARNFLAGS+= -Wno-vla-cxx-extension .endif CXXFLAGS+= -I${SRCTOP}/tests CXXFLAGS+= -I${FUSEFS} -CXXFLAGS+= -I${MOUNT} -.PATH: ${MOUNT} LIBADD+= pthread LIBADD+= gmock gtest LIBADD+= util .include diff --git a/usr.sbin/autofs/Makefile b/usr.sbin/autofs/Makefile index 2d0c1bcb8806..b32c617cfd56 100644 --- a/usr.sbin/autofs/Makefile +++ b/usr.sbin/autofs/Makefile @@ -1,32 +1,25 @@ CONFS= auto_master PACKAGE=autofs PROG= automountd SRCS= automount.c SRCS+= automountd.c SRCS+= autounmountd.c SRCS+= common.c SRCS+= defined.c -SRCS+= getmntopts.c SRCS+= log.c SRCS+= popen.c SRCS+= token.l CFLAGS+=-I${.CURDIR} CFLAGS+=-I${SRCTOP}/sys/fs/autofs MAN= automount.8 automountd.8 autounmountd.8 auto_master.5 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 index 8bd1b0f34d99..857d475103d0 100644 --- 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 index e63b03bbfe45..ebc4d3438cc1 100644 --- 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