Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

um/hostfs: define HOSTFS_ATTR_* via asm-offsets

The HOSTFS_ATTR_* values were meant to be standalone for
communication between hostfs's kernel and user code parts.
However, it's easy to forget that HOSTFS_ATTR_* should be
used even on the kernel side, and that wasn't consistently
done. As a result, the values need to match ATTR_* values,
which is not useful to maintain by hand. Instead, generate
them via asm-offsets like other constants that UML needs
in user-side code that aren't otherwise available in any
header files that can be included there.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
Link: https://patch.msgid.link/20251007071452.367989-3-johannes@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+12 -33
+10
arch/um/include/shared/common-offsets.h
··· 18 18 DEFINE(UM_KERN_GDT_ENTRY_TLS_ENTRIES, GDT_ENTRY_TLS_ENTRIES); 19 19 20 20 DEFINE(UM_SECCOMP_ARCH_NATIVE, SECCOMP_ARCH_NATIVE); 21 + 22 + DEFINE(HOSTFS_ATTR_MODE, ATTR_MODE); 23 + DEFINE(HOSTFS_ATTR_UID, ATTR_UID); 24 + DEFINE(HOSTFS_ATTR_GID, ATTR_GID); 25 + DEFINE(HOSTFS_ATTR_SIZE, ATTR_SIZE); 26 + DEFINE(HOSTFS_ATTR_ATIME, ATTR_ATIME); 27 + DEFINE(HOSTFS_ATTR_MTIME, ATTR_MTIME); 28 + DEFINE(HOSTFS_ATTR_CTIME, ATTR_CTIME); 29 + DEFINE(HOSTFS_ATTR_ATIME_SET, ATTR_ATIME_SET); 30 + DEFINE(HOSTFS_ATTR_MTIME_SET, ATTR_MTIME_SET);
+1
arch/x86/um/shared/sysdep/kernel-offsets.h
··· 5 5 #include <linux/crypto.h> 6 6 #include <linux/kbuild.h> 7 7 #include <linux/audit.h> 8 + #include <linux/fs.h> 8 9 #include <asm/mman.h> 9 10 #include <asm/seccomp.h> 10 11
+1 -33
fs/hostfs/hostfs.h
··· 3 3 #define __UM_FS_HOSTFS 4 4 5 5 #include <os.h> 6 + #include <generated/asm-offsets.h> 6 7 7 - /* 8 - * These are exactly the same definitions as in fs.h, but the names are 9 - * changed so that this file can be included in both kernel and user files. 10 - */ 11 - 12 - #define HOSTFS_ATTR_MODE 1 13 - #define HOSTFS_ATTR_UID 2 14 - #define HOSTFS_ATTR_GID 4 15 - #define HOSTFS_ATTR_SIZE 8 16 - #define HOSTFS_ATTR_ATIME 16 17 - #define HOSTFS_ATTR_MTIME 32 18 - #define HOSTFS_ATTR_CTIME 64 19 - #define HOSTFS_ATTR_ATIME_SET 128 20 - #define HOSTFS_ATTR_MTIME_SET 256 21 - 22 - /* This one is unused by hostfs. */ 23 - #define HOSTFS_ATTR_FORCE 512 /* Not a change, but a change it */ 24 - #define HOSTFS_ATTR_ATTR_FLAG 1024 25 - 26 - /* 27 - * If you are very careful, you'll notice that these two are missing: 28 - * 29 - * #define ATTR_KILL_SUID 2048 30 - * #define ATTR_KILL_SGID 4096 31 - * 32 - * and this is because they were added in 2.5 development. 33 - * Actually, they are not needed by most ->setattr() methods - they are set by 34 - * callers of notify_change() to notify that the setuid/setgid bits must be 35 - * dropped. 36 - * notify_change() will delete those flags, make sure attr->ia_valid & ATTR_MODE 37 - * is on, and remove the appropriate bits from attr->ia_mode (attr is a 38 - * "struct iattr *"). -BlaisorBlade 39 - */ 40 8 struct hostfs_timespec { 41 9 long long tv_sec; 42 10 long long tv_nsec;