go x/sys/unix: 在FreeBSD上缺少MS_*标志

thtygnil  于 4个月前  发布在  Go
关注(0)|答案(3)|浏览(36)

你正在使用哪个版本的Go( go version )?

$ go version
go version go1.20.3 freebsd/amd64

这个问题在最新版本中是否会重现?

是的。

你正在使用什么操作系统和处理器架构( go env )?

go env 输出

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/meena/.cache/go-build"
GOENV="/home/meena/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOINSECURE=""
GOMODCACHE="/home/meena/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/meena/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go120"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go120/pkg/tool/freebsd_amd64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="cc"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build37119700=/tmp/go-build -gno-record-gcc-switches"

你做了什么?

% go install github.com:/lxc/lxd/lxd-agent

你期望看到什么?

一个成功的编译

你看到了什么?

# github.com/lxc/lxd/lxd/storage/filesystem
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:176:32: undefined: unix.MS_SYNCHRONOUS
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:177:32: undefined: unix.MS_NOATIME
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:178:31: undefined: unix.MS_BIND
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:180:32: undefined: unix.MS_NODEV
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:181:32: undefined: unix.MS_NODIRATIME
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:182:31: undefined: unix.MS_DIRSYNC
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:183:32: undefined: unix.MS_NOEXEC
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:184:31: undefined: unix.MS_LAZYTIME
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:185:31: undefined: unix.MS_MANDLOCK
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:186:31: undefined: unix.MS_NOATIME
go/pkg/mod/github.com/lxc/lxd@v0.0.0-20230425125636-f8330b39bba3/lxd/storage/filesystem/fs.go:186:31: too many errors

大多数这些标志存在于FreeBSD上,但有不同的前缀:

sys/sys/mount.h:#define MNT_VNODE_FOREACH_ALL(vp, mp, mvp)				\
sys/sys/mount.h:#define MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp)				\
sys/sys/mount.h:#define MNT_VNODE_FOREACH_LAZY(vp, mp, mvp, cb, cbarg)			\
sys/sys/mount.h:#define MNT_VNODE_FOREACH_LAZY_ABORT(mp, mvp)				\
sys/sys/mount.h:#define	MNT_ILOCK(mp)	mtx_lock(&(mp)->mnt_mtx)
sys/sys/mount.h:#define	MNT_ITRYLOCK(mp) mtx_trylock(&(mp)->mnt_mtx)
sys/sys/mount.h:#define	MNT_IUNLOCK(mp)	mtx_unlock(&(mp)->mnt_mtx)
sys/sys/mount.h:#define	MNT_MTX(mp)	(&(mp)->mnt_mtx)
sys/sys/mount.h:#define	MNT_REF(mp)	do {						\
sys/sys/mount.h:#define	MNT_REL(mp)	do {						\
sys/sys/mount.h:#define MNTOPT_NAMES							\
sys/sys/mount.h:#define	MNT_RDONLY	0x0000000000000001ULL /* read only filesystem */
sys/sys/mount.h:#define	MNT_SYNCHRONOUS	0x0000000000000002ULL /* fs written synchronously */
sys/sys/mount.h:#define	MNT_NOEXEC	0x0000000000000004ULL /* can't exec from filesystem */
sys/sys/mount.h:#define	MNT_NOSUID	0x0000000000000008ULL /* don't honor setuid fs bits */
sys/sys/mount.h:#define	MNT_NFS4ACLS	0x0000000000000010ULL /* enable NFS version 4 ACLs */
sys/sys/mount.h:#define	MNT_UNION	0x0000000000000020ULL /* union with underlying fs */
sys/sys/mount.h:#define	MNT_ASYNC	0x0000000000000040ULL /* fs written asynchronously */
sys/sys/mount.h:#define	MNT_SUIDDIR	0x0000000000100000ULL /* special SUID dir handling */
sys/sys/mount.h:#define	MNT_SOFTDEP	0x0000000000200000ULL /* using soft updates */
sys/sys/mount.h:#define	MNT_NOSYMFOLLOW	0x0000000000400000ULL /* do not follow symlinks */
sys/sys/mount.h:#define	MNT_GJOURNAL	0x0000000002000000ULL /* GEOM journal support enabled */
sys/sys/mount.h:#define	MNT_MULTILABEL	0x0000000004000000ULL /* MAC support for objects */
sys/sys/mount.h:#define	MNT_ACLS	0x0000000008000000ULL /* ACL support enabled */
sys/sys/mount.h:#define	MNT_NOATIME	0x0000000010000000ULL /* dont update file access time */
sys/sys/mount.h:#define	MNT_NOCLUSTERR	0x0000000040000000ULL /* disable cluster read */
sys/sys/mount.h:#define	MNT_NOCLUSTERW	0x0000000080000000ULL /* disable cluster write */
sys/sys/mount.h:#define	MNT_SUJ		0x0000000100000000ULL /* using journaled soft updates */
sys/sys/mount.h:#define	MNT_AUTOMOUNTED	0x0000000200000000ULL /* mounted by automountd(8) */
sys/sys/mount.h:#define	MNT_UNTRUSTED	0x0000000800000000ULL /* filesys metadata untrusted */
sys/sys/mount.h:#define	MNT_EXRDONLY	0x0000000000000080ULL	/* exported read only */
sys/sys/mount.h:#define	MNT_EXPORTED	0x0000000000000100ULL	/* filesystem is exported */
sys/sys/mount.h:#define	MNT_DEFEXPORTED	0x0000000000000200ULL	/* exported to the world */
sys/sys/mount.h:#define	MNT_EXPORTANON	0x0000000000000400ULL	/* anon uid mapping for all */
sys/sys/mount.h:#define	MNT_EXKERB	0x0000000000000800ULL	/* exported with Kerberos */
sys/sys/mount.h:#define	MNT_EXPUBLIC	0x0000000020000000ULL	/* public export (WebNFS) */
sys/sys/mount.h:#define	MNT_EXTLS	0x0000004000000000ULL /* require TLS */
sys/sys/mount.h:#define	MNT_EXTLSCERT	0x0000008000000000ULL /* require TLS with client cert */
sys/sys/mount.h:#define	MNT_EXTLSCERTUSER 0x0000010000000000ULL /* require TLS with user cert */
sys/sys/mount.h:#define	MNT_LOCAL	0x0000000000001000ULL /* filesystem is stored locally */
sys/sys/mount.h:#define	MNT_QUOTA	0x0000000000002000ULL /* quotas are enabled on fs */
sys/sys/mount.h:#define	MNT_ROOTFS	0x0000000000004000ULL /* identifies the root fs */
sys/sys/mount.h:#define	MNT_USER	0x0000000000008000ULL /* mounted by a user */
sys/sys/mount.h:#define	MNT_IGNORE	0x0000000000800000ULL /* do not show entry in df */
sys/sys/mount.h:#define	MNT_VERIFIED	0x0000000400000000ULL /* filesystem is verified */
sys/sys/mount.h:#define	MNT_VISFLAGMASK	(MNT_RDONLY	| MNT_SYNCHRONOUS | MNT_NOEXEC	| \
sys/sys/mount.h:#define	MNT_UPDATEMASK (MNT_NOSUID	| MNT_NOEXEC	| \
sys/sys/mount.h:#define	MNT_UPDATE	0x0000000000010000ULL /* not real mount, just update */
sys/sys/mount.h:#define	MNT_DELEXPORT	0x0000000000020000ULL /* delete export host lists */
sys/sys/mount.h:#define	MNT_RELOAD	0x0000000000040000ULL /* reload filesystem data */
sys/sys/mount.h:#define	MNT_FORCE	0x0000000000080000ULL /* force unmount or readonly */
sys/sys/mount.h:#define	MNT_SNAPSHOT	0x0000000001000000ULL /* snapshot the filesystem */
sys/sys/mount.h:#define	MNT_NONBUSY	0x0000000004000000ULL /* check vnode use counts. */
sys/sys/mount.h:#define	MNT_BYFSID	0x0000000008000000ULL /* specify filesystem by ID. */
sys/sys/mount.h:#define	MNT_NOCOVER	0x0000001000000000ULL /* Do not cover a mount point */
sys/sys/mount.h:#define	MNT_EMPTYDIR	0x0000002000000000ULL /* Only mount on empty dir */
sys/sys/mount.h:#define	MNT_RECURSE	0x0000100000000000ULL /* recursively unmount uppers */
sys/sys/mount.h:#define	MNT_DEFERRED    0x0000200000000000ULL /* unmount in async context */
sys/sys/mount.h:#define	MNT_CMDFLAGS   (MNT_UPDATE	| MNT_DELEXPORT	| MNT_RELOAD	| \
sys/sys/mount.h:#define MNTK_UNMOUNTF	0x00000001	/* forced unmount in progress */
sys/sys/mount.h:#define MNTK_ASYNC	0x00000002	/* filtered async flag */
sys/sys/mount.h:#define MNTK_SOFTDEP	0x00000004	/* async disabled by softdep */
sys/sys/mount.h:#define MNTK_NOMSYNC	0x00000008	/* don't do msync */
sys/sys/mount.h:#define	MNTK_DRAINING	0x00000010	/* lock draining is happening */
sys/sys/mount.h:#define	MNTK_REFEXPIRE	0x00000020	/* refcount expiring is happening */
sys/sys/mount.h:#define MNTK_EXTENDED_SHARED	0x00000040 /* Allow shared locking for more ops */
sys/sys/mount.h:#define	MNTK_SHARED_WRITES	0x00000080 /* Allow shared locking for writes */
sys/sys/mount.h:#define	MNTK_NO_IOPF	0x00000100	/* Disallow page faults during reads
sys/sys/mount.h:#define	MNTK_RECURSE		0x00000200 /* pending recursive unmount */
sys/sys/mount.h:#define	MNTK_UPPER_WAITER	0x00000400 /* waiting to drain MNTK_UPPER_PENDING */
sys/sys/mount.h:#define	MNTK_UNLOCKED_INSMNTQUE	0x00001000 /* fs does not lock the vnode for insmntque */
sys/sys/mount.h:#define	MNTK_UNMAPPED_BUFS	0x00002000
sys/sys/mount.h:#define	MNTK_USES_BCACHE	0x00004000 /* FS uses the buffer cache. */
sys/sys/mount.h:#define	MNTK_VMSETSIZE_BUG	0x00010000
sys/sys/mount.h:#define	MNTK_UNIONFS	0x00020000	/* A hack for F_ISUNIONSTACK */
sys/sys/mount.h:#define	MNTK_FPLOOKUP	0x00040000	/* fast path lookup is supported */
sys/sys/mount.h:#define	MNTK_SUSPEND_ALL	0x00080000 /* Suspended by all-fs suspension */
sys/sys/mount.h:#define	MNTK_TASKQUEUE_WAITER	0x00100000 /* Waiting on unmount taskqueue */
sys/sys/mount.h:#define	MNTK_NOASYNC	0x00800000	/* disable async */
sys/sys/mount.h:#define	MNTK_UNMOUNT	0x01000000	/* unmount in progress */
sys/sys/mount.h:#define	MNTK_MWAIT	0x02000000	/* waiting for unmount to finish */
sys/sys/mount.h:#define	MNTK_SUSPEND	0x08000000	/* request write suspension */
sys/sys/mount.h:#define	MNTK_SUSPEND2	0x04000000	/* block secondary writes */
sys/sys/mount.h:#define	MNTK_SUSPENDED	0x10000000	/* write operations are suspended */
sys/sys/mount.h:#define	MNTK_NULL_NOCACHE	0x20000000 /* auto disable cache for nullfs
sys/sys/mount.h:#define MNTK_LOOKUP_SHARED	0x40000000 /* FS supports shared lock lookups */
sys/sys/mount.h:#define MNT_WAIT	1	/* synchronously wait for I/O to complete */
sys/sys/mount.h:#define MNT_NOWAIT	2	/* start all I/O, but do not wait for it */
sys/sys/mount.h:#define MNT_LAZY	3	/* push data not written by filesystem syncer */
sys/sys/mount.h:#define MNT_SUSPEND	4	/* Suspend file system after sync */
sys/kern/vfs_subr.c:#define	MNT_FLAG(flag)	do {						\
sys/kern/vfs_subr.c:#define	MNT_KERN_FLAG(flag)	do {					\
yfwxisqw

yfwxisqw2#

如果FreeBSD内核头文件中的内核标志与Linux中的等效标志命名不同,我实际上认为像unix这样的低级模块不应该尝试将它们重命名为与Linux保持一致。
我完全同意@stgraber的观点。即使某些标志具有相似的名称,也不能保证它们具有完全相同的语义。
一些标志在FreeBSD中没有等效项。例如,MS_MOVE可以通过使用nullfs挂载目录来模拟MS_BIND,但不能模拟文件。然而,这是一个用户应用程序关注的问题。

lsmepo6l

lsmepo6l3#

MS_BIND 可能可以使用 nullfs 挂载目录来模拟,但不能模拟文件。
启动 13.2: https://reviews.freebsd.org/D37478

相关问题