1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2021 Samsung Electronics Co., Ltd.
10 * These are on-disk structures to store additional metadata into xattr to
11 * reproduce windows filesystem semantics. And they are encoded with NDR to
12 * compatible with samba's xattr meta format. The compatibility with samba
13 * is important because it can lose the information(file attribute,
14 * creation time, acls) about the existing files when switching between
19 * Dos attribute flags used for what variable is valid.
22 XATTR_DOSINFO_ATTRIB = 0x00000001,
23 XATTR_DOSINFO_EA_SIZE = 0x00000002,
24 XATTR_DOSINFO_SIZE = 0x00000004,
25 XATTR_DOSINFO_ALLOC_SIZE = 0x00000008,
26 XATTR_DOSINFO_CREATE_TIME = 0x00000010,
27 XATTR_DOSINFO_CHANGE_TIME = 0x00000020,
28 XATTR_DOSINFO_ITIME = 0x00000040
32 * Dos attribute structure which is compatible with samba's one.
33 * Storing it into the xattr named "DOSATTRIB" separately from inode
34 * allows ksmbd to faithfully reproduce windows filesystem semantics
35 * on top of a POSIX filesystem.
37 struct xattr_dos_attrib {
38 __u16 version; /* version 3 or version 4 */
39 __u32 flags; /* valid flags */
40 __u32 attr; /* Dos attribute */
41 __u32 ea_size; /* EA size */
44 __u64 create_time; /* File creation time */
45 __u64 change_time; /* File change time */
46 __u64 itime; /* Invented/Initial time */
50 * Enumeration is used for computing posix acl hash.
53 SMB_ACL_TAG_INVALID = 0,
62 #define SMB_ACL_READ 4
63 #define SMB_ACL_WRITE 2
64 #define SMB_ACL_EXECUTE 1
66 struct xattr_acl_entry {
74 * xattr_smb_acl structure is used for computing posix acl hash.
76 struct xattr_smb_acl {
79 struct xattr_acl_entry entries[] __counted_by(count);
82 /* 64bytes hash in xattr_ntacl is computed with sha256 */
83 #define XATTR_SD_HASH_TYPE_SHA256 0x1
84 #define XATTR_SD_HASH_SIZE 64
87 * xattr_ntacl is used for storing ntacl and hashes.
88 * Hash is used for checking valid posix acl and ntacl in xattr.
91 __u16 version; /* version 4*/
94 __u16 hash_type; /* hash type */
95 __u8 desc[10]; /* posix_acl description */
98 __u8 hash[XATTR_SD_HASH_SIZE]; /* 64bytes hash for ntacl */
99 __u8 posix_acl_hash[XATTR_SD_HASH_SIZE]; /* 64bytes hash for posix acl */
102 /* DOS ATTRIBUTE XATTR PREFIX */
103 #define DOS_ATTRIBUTE_PREFIX "DOSATTRIB"
104 #define DOS_ATTRIBUTE_PREFIX_LEN (sizeof(DOS_ATTRIBUTE_PREFIX) - 1)
105 #define XATTR_NAME_DOS_ATTRIBUTE (XATTR_USER_PREFIX DOS_ATTRIBUTE_PREFIX)
106 #define XATTR_NAME_DOS_ATTRIBUTE_LEN \
107 (sizeof(XATTR_USER_PREFIX DOS_ATTRIBUTE_PREFIX) - 1)
109 /* STREAM XATTR PREFIX */
110 #define STREAM_PREFIX "DosStream."
111 #define STREAM_PREFIX_LEN (sizeof(STREAM_PREFIX) - 1)
112 #define XATTR_NAME_STREAM (XATTR_USER_PREFIX STREAM_PREFIX)
113 #define XATTR_NAME_STREAM_LEN (sizeof(XATTR_NAME_STREAM) - 1)
115 /* SECURITY DESCRIPTOR(NTACL) XATTR PREFIX */
116 #define SD_PREFIX "NTACL"
117 #define SD_PREFIX_LEN (sizeof(SD_PREFIX) - 1)
118 #define XATTR_NAME_SD (XATTR_SECURITY_PREFIX SD_PREFIX)
119 #define XATTR_NAME_SD_LEN \
120 (sizeof(XATTR_SECURITY_PREFIX SD_PREFIX) - 1)
122 #endif /* __XATTR_H__ */