1254885Sdumbbell/*- 2254885Sdumbbell * SPDX-License-Identifier: BSD-3-Clause 3254885Sdumbbell * 4254885Sdumbbell * Copyright (c) 1994 5254885Sdumbbell * The Regents of the University of California. All rights reserved. 6254885Sdumbbell * 7254885Sdumbbell * Redistribution and use in source and binary forms, with or without 8254885Sdumbbell * modification, are permitted provided that the following conditions 9254885Sdumbbell * are met: 10254885Sdumbbell * 1. Redistributions of source code must retain the above copyright 11254885Sdumbbell * notice, this list of conditions and the following disclaimer. 12254885Sdumbbell * 2. Redistributions in binary form must reproduce the above copyright 13254885Sdumbbell * notice, this list of conditions and the following disclaimer in the 14254885Sdumbbell * documentation and/or other materials provided with the distribution. 15254885Sdumbbell * 3. Neither the name of the University nor the names of its contributors 16254885Sdumbbell * may be used to endorse or promote products derived from this software 17254885Sdumbbell * without specific prior written permission. 18254885Sdumbbell * 19254885Sdumbbell * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20254885Sdumbbell * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21254885Sdumbbell * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22254885Sdumbbell * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23254885Sdumbbell * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24254885Sdumbbell * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25254885Sdumbbell * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26254885Sdumbbell * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27254885Sdumbbell * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28254885Sdumbbell * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29254885Sdumbbell * SUCH DAMAGE. 30254885Sdumbbell */ 31254885Sdumbbell 32254885Sdumbbellstruct mntopt { 33254885Sdumbbell const char *m_option; /* option name */ 34254885Sdumbbell int m_inverse; /* if a negative option, e.g. "atime" */ 35254885Sdumbbell long long m_flag; /* bit to set, e.g. MNT_RDONLY */ 36254885Sdumbbell int m_altloc; /* 1 => set bit in altflags */ 37254885Sdumbbell}; 38254885Sdumbbell 39282199Sdumbbell/* User-visible MNT_ flags. */ 40254885Sdumbbell#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } 41254885Sdumbbell#define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 } 42254885Sdumbbell#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 } 43254885Sdumbbell#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 } 44254885Sdumbbell#define MOPT_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 0 } 45254885Sdumbbell#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 } 46254885Sdumbbell#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 } 47254885Sdumbbell#define MOPT_UNION { "union", 0, MNT_UNION, 0 } 48254885Sdumbbell#define MOPT_USERQUOTA { "userquota", 0, 0, 0 } 49254885Sdumbbell#define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 } 50282199Sdumbbell#define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 } 51254885Sdumbbell#define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 } 52254885Sdumbbell#define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 } 53254885Sdumbbell#define MOPT_SNAPSHOT { "snapshot", 0, MNT_SNAPSHOT, 0 } 54254885Sdumbbell#define MOPT_MULTILABEL { "multilabel", 0, MNT_MULTILABEL, 0 } 55254885Sdumbbell#define MOPT_ACLS { "acls", 0, MNT_ACLS, 0 } 56254885Sdumbbell#define MOPT_NFS4ACLS { "nfsv4acls", 0, MNT_NFS4ACLS, 0 } 57254885Sdumbbell#define MOPT_AUTOMOUNTED { "automounted",0, MNT_AUTOMOUNTED, 0 } 58254885Sdumbbell#define MOPT_UNTRUSTED { "untrusted", 0, MNT_UNTRUSTED, 0 } 59254885Sdumbbell 60254885Sdumbbell/* Control flags. */ 61254885Sdumbbell#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 } 62254885Sdumbbell#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 } 63254885Sdumbbell#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 } 64254885Sdumbbell#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 } 65254885Sdumbbell#define MOPT_NOCOVER { "cover", 1, MNT_NOCOVER, 0 } 66254885Sdumbbell#define MOPT_EMPTYDIR { "emptydir", 0, MNT_EMPTYDIR, 0 } 67254885Sdumbbell/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */ 68254885Sdumbbell#define MOPT_AUTO { "auto", 0, 0, 0 } 69254885Sdumbbell 70254885Sdumbbell/* A handy macro as terminator of MNT_ array. */ 71254885Sdumbbell#define MOPT_END { NULL, 0, 0, 0 } 72254885Sdumbbell 73254885Sdumbbell#define MOPT_FSTAB_COMPAT \ 74254885Sdumbbell MOPT_RO, \ 75254885Sdumbbell MOPT_RW, \ 76254885Sdumbbell MOPT_AUTO 77254885Sdumbbell 78254885Sdumbbell/* Standard options which all mounts can understand. */ 79254885Sdumbbell#define MOPT_STDOPTS \ 80254885Sdumbbell MOPT_USERQUOTA, \ 81254885Sdumbbell MOPT_GROUPQUOTA, \ 82254885Sdumbbell MOPT_FSTAB_COMPAT, \ 83254885Sdumbbell MOPT_NOATIME, \ 84254885Sdumbbell MOPT_NOEXEC, \ 85254885Sdumbbell MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \ 86254885Sdumbbell MOPT_NOSUID, \ 87254885Sdumbbell MOPT_NOSYMFOLLOW, \ 88254885Sdumbbell MOPT_RDONLY, \ 89254885Sdumbbell MOPT_UNION, \ 90254885Sdumbbell MOPT_NOCLUSTERR, \ 91254885Sdumbbell MOPT_NOCLUSTERW, \ 92254885Sdumbbell MOPT_MULTILABEL, \ 93254885Sdumbbell MOPT_ACLS, \ 94254885Sdumbbell MOPT_NFS4ACLS, \ 95254885Sdumbbell MOPT_AUTOMOUNTED, \ 96254885Sdumbbell MOPT_UNTRUSTED, \ 97254885Sdumbbell MOPT_NOCOVER, \ 98254885Sdumbbell MOPT_EMPTYDIR 99254885Sdumbbell 100254885Sdumbbellvoid getmntopts(const char *, const struct mntopt *, int *, int *); 101254885Sdumbbellvoid rmslashes(char *, char *); 102254885Sdumbbellint checkpath(const char *, char resolved_path[]); 103254885Sdumbbellint checkpath_allow_file(const char *, char resolved_path[]); 104254885Sdumbbellstruct statfs *getmntpoint(const char *); 105254885Sdumbbellint chkdoreload(struct statfs *, void (*)(const char *, ...) __printflike(1,2)); 106254885Sdumbbellextern int getmnt_silent; 107254885Sdumbbellvoid build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len); 108254885Sdumbbellvoid build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...); 109254885Sdumbbellvoid free_iovec(struct iovec **iovec, int *iovlen); 110254885Sdumbbell