-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
I needed the ST_NOEXEC constant for statfs, but found it missing in x/sys/unix.
I tried the obvious,
$ git di
diff --git a/unix/linux/types.go b/unix/linux/types.go
index 3bc7035..d4ec87a 100644
--- a/unix/linux/types.go
+++ b/unix/linux/types.go
@@ -46,6 +46,7 @@ package unix
#include <sys/user.h>
#include <sys/utsname.h>
#include <sys/wait.h>
+#include <sys/vfs.h>
#include <linux/filter.h>
#include <linux/icmpv6.h>
#include <linux/keyctl.h>
@@ -337,8 +338,6 @@ type _Gid_t C.gid_t
type Stat_t C.struct_stat
-type Statfs_t C.struct_statfs
-
type StatxTimestamp C.struct_statx_timestamp
type Statx_t C.struct_statx
@@ -972,3 +971,19 @@ type HDDriveCmdHdr C.struct_hd_drive_cmd_hdr
type HDGeometry C.struct_hd_geometry
type HDDriveID C.struct_hd_driveid
+
+// Statfs
+
+type Statfs_t C.struct_statfs
+
+const (
+ ST_MANDLOCK = C.ST_MANDLOCK
+ ST_NOATIME = C.ST_NOATIME
+ ST_NODEV = C.ST_NODEV
+ ST_NODIRATIME = C.ST_NODIRATIME
+ ST_NOEXEC = C.ST_NOEXEC
+ ST_NOSUID = C.ST_NOSUID
+ ST_RDONLY = C.ST_RDONLY
+ ST_RELATIME = C.ST_RELATIME
+ ST_SYNCHRONOUS = C.ST_SYNCHRONOUS
+)but I got:
/build/linux/types.go:980:19: could not determine kind of name for C.ST_MANDLOCK
/build/linux/types.go:981:19: could not determine kind of name for C.ST_NOATIME
/build/linux/types.go:982:19: could not determine kind of name for C.ST_NODEV
/build/linux/types.go:983:19: could not determine kind of name for C.ST_NODIRATIME
/build/linux/types.go:984:19: could not determine kind of name for C.ST_NOEXEC
/build/linux/types.go:985:19: could not determine kind of name for C.ST_NOSUID
/build/linux/types.go:986:19: could not determine kind of name for C.ST_RDONLY
/build/linux/types.go:987:19: could not determine kind of name for C.ST_RELATIME
/build/linux/types.go:988:19: could not determine kind of name for C.ST_SYNCHRONOUS
I then went to search how they were defined and found https://elixir.bootlin.com/linux/latest/source/include/linux/statfs.h#L33
/*
* Definitions for the flag in f_flag.
*
* Generally these flags are equivalent to the MS_ flags used in the mount
* ABI. The exception is ST_VALID which has the same value as MS_REMOUNT
* which doesn't make any sense for statfs.
*/
#define ST_RDONLY 0x0001 /* mount read-only */
#define ST_NOSUID 0x0002 /* ignore suid and sgid bits */
#define ST_NODEV 0x0004 /* disallow access to device special files */
#define ST_NOEXEC 0x0008 /* disallow program execution */
...And I discovered we do have MS_NOEXEC, so that'll do for now.
But it'd be nice to also have the ST_ names in there, even if they're the same. It would save others this distraction in the future.
/cc @tklauser
Reactions are currently unavailable