ReactOS  0.4.14-dev-608-gd495a4f
Lwext4

Files

file  ext4_xattr.h
 Extended Attribute manipulation.
 

Classes

struct  ext4_xattr_header
 
struct  ext4_xattr_ibody_header
 
struct  ext4_xattr_entry
 
struct  ext4_xattr_item
 
struct  ext4_xattr_ref
 

Macros

#define EXT4_XATTR_MAGIC   0xEA020000
 
#define EXT4_XATTR_REFCOUNT_MAX   1024
 
#define EXT4_XATTR_INDEX_USER   1
 
#define EXT4_XATTR_INDEX_POSIX_ACL_ACCESS   2
 
#define EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT   3
 
#define EXT4_XATTR_INDEX_TRUSTED   4
 
#define EXT4_XATTR_INDEX_LUSTRE   5
 
#define EXT4_XATTR_INDEX_SECURITY   6
 
#define EXT4_XATTR_INDEX_SYSTEM   7
 
#define EXT4_XATTR_INDEX_RICHACL   8
 
#define EXT4_XATTR_INDEX_ENCRYPTION   9
 
#define EXT4_GOOD_OLD_INODE_SIZE   EXT2_GOOD_OLD_INODE_SIZE
 
#define EXT4_XATTR_PAD_BITS   2
 
#define EXT4_XATTR_PAD   (1<<EXT4_XATTR_PAD_BITS)
 
#define EXT4_XATTR_ROUND   (EXT4_XATTR_PAD-1)
 
#define EXT4_XATTR_LEN(name_len)
 
#define EXT4_XATTR_NEXT(entry)
 
#define EXT4_XATTR_SIZE(size)   (((size) + EXT4_XATTR_ROUND) & ~EXT4_XATTR_ROUND)
 
#define EXT4_XATTR_NAME(entry)   ((char *)((entry) + 1))
 
#define EXT4_XATTR_IHDR(raw_inode)
 
#define EXT4_XATTR_IFIRST(hdr)   ((struct ext4_xattr_entry *)((hdr)+1))
 
#define EXT4_XATTR_BHDR(block)   ((struct ext4_xattr_header *)((block)->b_data))
 
#define EXT4_XATTR_ENTRY(ptr)   ((struct ext4_xattr_entry *)(ptr))
 
#define EXT4_XATTR_BFIRST(block)   EXT4_XATTR_ENTRY(EXT4_XATTR_BHDR(block)+1)
 
#define EXT4_XATTR_IS_LAST_ENTRY(entry)   (*(__le32 *)(entry) == 0)
 
#define EXT4_ZERO_XATTR_VALUE   ((void *)-1)
 
#define EXT4_XATTR_ITERATE_CONT   0
 
#define EXT4_XATTR_ITERATE_STOP   1
 
#define EXT4_XATTR_ITERATE_PAUSE   2
 

Functions

int ext4_fs_get_xattr_ref (PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB fs, PEXT2_MCB inode_ref, struct ext4_xattr_ref *ref)
 
int ext4_fs_put_xattr_ref (struct ext4_xattr_ref *ref)
 
int ext4_fs_set_xattr (struct ext4_xattr_ref *ref, __u8 name_index, const char *name, size_t name_len, const void *data, size_t data_size, BOOL replace)
 
int ext4_fs_set_xattr_ordered (struct ext4_xattr_ref *ref, __u8 name_index, const char *name, size_t name_len, const void *data, size_t data_size)
 
int ext4_fs_remove_xattr (struct ext4_xattr_ref *ref, __u8 name_index, const char *name, size_t name_len)
 
int ext4_fs_get_xattr (struct ext4_xattr_ref *ref, __u8 name_index, const char *name, size_t name_len, void *buf, size_t buf_size, size_t *data_size)
 
void ext4_fs_xattr_iterate (struct ext4_xattr_ref *ref, int(*iter)(struct ext4_xattr_ref *ref, struct ext4_xattr_item *item, BOOL is_last))
 
void ext4_fs_xattr_iterate_reset (struct ext4_xattr_ref *ref)
 
const charext4_extract_xattr_name (const char *full_name, size_t full_name_len, __u8 *name_index, size_t *name_len, BOOL *found)
 
const charext4_get_xattr_name_prefix (__u8 name_index, size_t *ret_prefix_len)
 
void ext4_xattr_purge_items (struct ext4_xattr_ref *xattr_ref)
 

Detailed Description

Macro Definition Documentation

◆ EXT4_GOOD_OLD_INODE_SIZE

#define EXT4_GOOD_OLD_INODE_SIZE   EXT2_GOOD_OLD_INODE_SIZE

Definition at line 89 of file ext4_xattr.h.

◆ EXT4_XATTR_BFIRST

#define EXT4_XATTR_BFIRST (   block)    EXT4_XATTR_ENTRY(EXT4_XATTR_BHDR(block)+1)

Definition at line 117 of file ext4_xattr.h.

◆ EXT4_XATTR_BHDR

#define EXT4_XATTR_BHDR (   block)    ((struct ext4_xattr_header *)((block)->b_data))

Definition at line 113 of file ext4_xattr.h.

◆ EXT4_XATTR_ENTRY

#define EXT4_XATTR_ENTRY (   ptr)    ((struct ext4_xattr_entry *)(ptr))

Definition at line 115 of file ext4_xattr.h.

◆ EXT4_XATTR_IFIRST

#define EXT4_XATTR_IFIRST (   hdr)    ((struct ext4_xattr_entry *)((hdr)+1))

Definition at line 110 of file ext4_xattr.h.

◆ EXT4_XATTR_IHDR

#define EXT4_XATTR_IHDR (   raw_inode)
Value:
((char *)raw_inode + \
EXT4_GOOD_OLD_INODE_SIZE + \
(raw_inode)->i_extra_isize))

Definition at line 105 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_ENCRYPTION

#define EXT4_XATTR_INDEX_ENCRYPTION   9

Definition at line 60 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_LUSTRE

#define EXT4_XATTR_INDEX_LUSTRE   5

Definition at line 56 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_POSIX_ACL_ACCESS

#define EXT4_XATTR_INDEX_POSIX_ACL_ACCESS   2

Definition at line 53 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT

#define EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT   3

Definition at line 54 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_RICHACL

#define EXT4_XATTR_INDEX_RICHACL   8

Definition at line 59 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_SECURITY

#define EXT4_XATTR_INDEX_SECURITY   6

Definition at line 57 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_SYSTEM

#define EXT4_XATTR_INDEX_SYSTEM   7

Definition at line 58 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_TRUSTED

#define EXT4_XATTR_INDEX_TRUSTED   4

Definition at line 55 of file ext4_xattr.h.

◆ EXT4_XATTR_INDEX_USER

#define EXT4_XATTR_INDEX_USER   1

Definition at line 52 of file ext4_xattr.h.

◆ EXT4_XATTR_IS_LAST_ENTRY

#define EXT4_XATTR_IS_LAST_ENTRY (   entry)    (*(__le32 *)(entry) == 0)

Definition at line 119 of file ext4_xattr.h.

◆ EXT4_XATTR_ITERATE_CONT

#define EXT4_XATTR_ITERATE_CONT   0

Definition at line 162 of file ext4_xattr.h.

◆ EXT4_XATTR_ITERATE_PAUSE

#define EXT4_XATTR_ITERATE_PAUSE   2

Definition at line 164 of file ext4_xattr.h.

◆ EXT4_XATTR_ITERATE_STOP

#define EXT4_XATTR_ITERATE_STOP   1

Definition at line 163 of file ext4_xattr.h.

◆ EXT4_XATTR_LEN

#define EXT4_XATTR_LEN (   name_len)
Value:
(((name_len) + EXT4_XATTR_ROUND + \
sizeof(struct ext4_xattr_entry)) & ~EXT4_XATTR_ROUND)
#define EXT4_XATTR_ROUND
Definition: ext4_xattr.h:93
Definition: ext4_xattr.h:78

Definition at line 94 of file ext4_xattr.h.

◆ EXT4_XATTR_MAGIC

#define EXT4_XATTR_MAGIC   0xEA020000

Definition at line 46 of file ext4_xattr.h.

◆ EXT4_XATTR_NAME

#define EXT4_XATTR_NAME (   entry)    ((char *)((entry) + 1))

Definition at line 102 of file ext4_xattr.h.

◆ EXT4_XATTR_NEXT

#define EXT4_XATTR_NEXT (   entry)
Value:
((struct ext4_xattr_entry *)( \
(char *)(entry) + EXT4_XATTR_LEN((entry)->e_name_len)))
#define EXT4_XATTR_LEN(name_len)
Definition: ext4_xattr.h:94
uint32_t entry
Definition: isohybrid.c:63
Definition: ext4_xattr.h:78

Definition at line 97 of file ext4_xattr.h.

◆ EXT4_XATTR_PAD

#define EXT4_XATTR_PAD   (1<<EXT4_XATTR_PAD_BITS)

Definition at line 92 of file ext4_xattr.h.

◆ EXT4_XATTR_PAD_BITS

#define EXT4_XATTR_PAD_BITS   2

Definition at line 91 of file ext4_xattr.h.

◆ EXT4_XATTR_REFCOUNT_MAX

#define EXT4_XATTR_REFCOUNT_MAX   1024

Definition at line 49 of file ext4_xattr.h.

◆ EXT4_XATTR_ROUND

#define EXT4_XATTR_ROUND   (EXT4_XATTR_PAD-1)

Definition at line 93 of file ext4_xattr.h.

◆ EXT4_XATTR_SIZE

#define EXT4_XATTR_SIZE (   size)    (((size) + EXT4_XATTR_ROUND) & ~EXT4_XATTR_ROUND)

Definition at line 100 of file ext4_xattr.h.

◆ EXT4_ZERO_XATTR_VALUE

#define EXT4_ZERO_XATTR_VALUE   ((void *)-1)

Definition at line 122 of file ext4_xattr.h.

Function Documentation

◆ ext4_extract_xattr_name()

const char* ext4_extract_xattr_name ( const char full_name,
size_t  full_name_len,
__u8 name_index,
size_t name_len,
BOOL found 
)

Definition at line 1234 of file ext4_xattr.c.

1237 {
1238  int i;
1239  ASSERT(name_index);
1240  ASSERT(found);
1241 
1242  *found = FALSE;
1243 
1244  if (!full_name_len) {
1245  if (name_len)
1246  *name_len = 0;
1247 
1248  return NULL;
1249  }
1250 
1251  for (i = 0; prefix_tbl[i].prefix; i++) {
1252  size_t prefix_len = strlen(prefix_tbl[i].prefix);
1253  if (full_name_len >= prefix_len &&
1254  !memcmp(full_name, prefix_tbl[i].prefix, prefix_len)) {
1255  BOOL require_name =
1256  prefix_tbl[i].prefix[prefix_len - 1] == '.';
1257  *name_index = prefix_tbl[i].name_index;
1258  if (name_len)
1259  *name_len = full_name_len - prefix_len;
1260 
1261  if (!(full_name_len - prefix_len) && require_name)
1262  return NULL;
1263 
1264  *found = TRUE;
1265  if (require_name)
1266  return full_name + prefix_len;
1267 
1268  return NULL;
1269  }
1270  }
1271  if (name_len)
1272  *name_len = 0;
1273 
1274  return NULL;
1275 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static const struct xattr_prefix prefix_tbl[]
Definition: ext4_xattr.c:1223
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

◆ ext4_fs_get_xattr()

int ext4_fs_get_xattr ( struct ext4_xattr_ref ref,
__u8  name_index,
const char name,
size_t  name_len,
void buf,
size_t  buf_size,
size_t data_size 
)

Definition at line 1078 of file ext4_xattr.c.

1081 {
1082  int ret = 0;
1083  size_t item_size = 0;
1084  struct ext4_xattr_item *item =
1086 
1087  if (!item) {
1088  ret = -ENODATA;
1089  goto Finish;
1090  }
1091  item_size = item->data_size;
1092  if (buf_size > item_size)
1093  buf_size = item_size;
1094 
1095  if (buf)
1096  memcpy(buf, item->data, buf_size);
1097 
1098 Finish:
1099  if (data_size)
1100  *data_size = item_size;
1101 
1102  return ret;
1103 }
size_t data_size
Definition: ext4_xattr.h:134
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ENODATA
Definition: errno.h:65
Definition: send.c:47
static struct ext4_xattr_item * ext4_xattr_lookup_item(struct ext4_xattr_ref *xattr_ref, __u8 name_index, const char *name, size_t name_len)
Definition: ext4_xattr.c:467
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ATOM item
Definition: dde.c:856
Definition: name.c:38

Referenced by Ext2QueryEa().

◆ ext4_fs_get_xattr_ref()

int ext4_fs_get_xattr_ref ( PEXT2_IRP_CONTEXT  IrpContext,
PEXT2_VCB  fs,
PEXT2_MCB  inode_ref,
struct ext4_xattr_ref ref 
)

Definition at line 1105 of file ext4_xattr.c.

1107 {
1108  int rc;
1109  ext4_fsblk_t xattr_block;
1110  xattr_block = inode_ref->Inode.i_file_acl;
1111  memset(&ref->root, 0, sizeof(struct rb_root));
1112  ref->ea_size = 0;
1113  ref->iter_from = NULL;
1114  if (xattr_block) {
1115  ref->block_bh = extents_bread(&fs->sb, xattr_block);
1116  if (!ref->block_bh)
1117  return -EIO;
1118 
1119  ref->block_loaded = TRUE;
1120  } else
1121  ref->block_loaded = FALSE;
1122 
1123  ref->inode_ref = inode_ref;
1124  ref->fs = fs;
1125  INIT_LIST_HEAD(&ref->ordered_list);
1126 
1127  ref->OnDiskInode = Ext2AllocateInode(fs);
1128  if (!ref->OnDiskInode) {
1129  if (xattr_block) {
1130  extents_brelse(ref->block_bh);
1131  ref->block_bh = NULL;
1132  }
1133  return -ENOMEM;
1134  }
1135  if (!Ext2LoadInodeXattr(fs, &inode_ref->Inode, ref->OnDiskInode)) {
1136  if (xattr_block) {
1137  extents_brelse(ref->block_bh);
1138  ref->block_bh = NULL;
1139  }
1140 
1141  Ext2DestroyInode(fs, ref->OnDiskInode);
1142  return -EIO;
1143  }
1144  ref->IsOnDiskInodeDirty = FALSE;
1145 
1147  sizeof(struct ext4_xattr_ibody_header) +
1148  sizeof(__u32))
1149  ref->inode_size_rem = 0;
1150  else {
1151  ref->inode_size_rem =
1153  sizeof(struct ext4_xattr_ibody_header);
1154  }
1155 
1156  ref->block_size_rem =
1158  sizeof(struct ext4_xattr_header) -
1159  sizeof(__u32);
1160 
1161  rc = ext4_xattr_fetch(ref);
1162  if (rc != 0) {
1164  if (xattr_block) {
1165  extents_brelse(ref->block_bh);
1166  ref->block_bh = NULL;
1167  }
1168 
1169  Ext2DestroyInode(fs, ref->OnDiskInode);
1170  return rc;
1171  }
1172  ref->IrpContext = IrpContext;
1173  return 0;
1174 }
static __s32 ext4_xattr_inode_space(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:436
PEXT2_INODE Ext2AllocateInode(PEXT2_VCB Vcb)
Definition: memory.c:387
#define TRUE
Definition: types.h:120
struct inode Inode
Definition: ext2fs.h:936
static int ext4_xattr_fetch(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:449
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define INIT_LIST_HEAD(ptr)
Definition: list.h:24
Definition: fs.h:235
Definition: send.c:47
Definition: arc.h:48
unsigned long long ext4_fsblk_t
Definition: ext3_fs_i.h:27
void extents_brelse(struct buffer_head *bh)
Definition: ext4_bh.c:51
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN Ext2LoadInodeXattr(IN PEXT2_VCB Vcb, IN struct inode *Inode, IN PEXT2_INODE InodeXattr)
Definition: generic.c:586
unsigned int __u32
Definition: compat.h:90
VOID Ext2DestroyInode(IN PEXT2_VCB Vcb, IN PEXT2_INODE inode)
Definition: memory.c:406
#define fs
Definition: i386-dis.c:435
static __s32 ext4_xattr_block_space(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:444
Definition: arc.h:40
struct buffer_head * extents_bread(struct super_block *sb, sector_t block)
Definition: ext4_bh.c:15
#define memset(x, y, z)
Definition: compat.h:39
void ext4_xattr_purge_items(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:736

Referenced by Ext2OverwriteEa(), Ext2QueryEa(), Ext2QueryFileInformation(), and Ext2SetEa().

◆ ext4_fs_put_xattr_ref()

int ext4_fs_put_xattr_ref ( struct ext4_xattr_ref ref)

Definition at line 1176 of file ext4_xattr.c.

1177 {
1178  int ret;
1179  sector_t orig_file_acl = ref->inode_ref->Inode.i_file_acl;
1181  if (ref->IsOnDiskInodeDirty) {
1182  ASSERT(ref->fs->InodeSize > EXT4_GOOD_OLD_INODE_SIZE);
1183 
1184  /* As we may do block allocation in ext4_xattr_write_to_disk */
1185  if (ret)
1186  ref->inode_ref->Inode.i_file_acl = orig_file_acl;
1187 
1188  if (!ret) {
1189  ret = Ext2SaveInode(ref->IrpContext, ref->fs, &ref->inode_ref->Inode)
1190  ? 0 : -EIO;
1191  if (!ret) {
1192  ret = Ext2SaveInodeXattr(ref->IrpContext,
1193  ref->fs,
1194  &ref->inode_ref->Inode,
1195  ref->OnDiskInode)
1196  ? 0 : -EIO;
1197  }
1198  }
1199  ref->IsOnDiskInodeDirty = FALSE;
1200  }
1201  if (ref->block_loaded) {
1202  if (!ret)
1203  extents_brelse(ref->block_bh);
1204  else
1205  extents_bforget(ref->block_bh);
1206 
1207  ref->block_bh = NULL;
1208  ref->block_loaded = FALSE;
1209  }
1211  Ext2DestroyInode(ref->fs, ref->OnDiskInode);
1212  ref->OnDiskInode = NULL;
1213  ref->inode_ref = NULL;
1214  ref->fs = NULL;
1215  return ret;
1216 }
BOOLEAN Ext2SaveInodeXattr(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode, IN PEXT2_INODE InodeXattr)
Definition: generic.c:617
unsigned __int64 sector_t
Definition: types.h:78
Definition: send.c:47
static int ext4_xattr_write_to_disk(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:858
void extents_brelse(struct buffer_head *bh)
Definition: ext4_bh.c:51
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
int ret
VOID Ext2DestroyInode(IN PEXT2_VCB Vcb, IN PEXT2_INODE inode)
Definition: memory.c:406
Definition: arc.h:40
#define EXT4_GOOD_OLD_INODE_SIZE
Definition: ext4_xattr.h:89
BOOLEAN Ext2SaveInode(IN PEXT2_IRP_CONTEXT IrpContext, IN PEXT2_VCB Vcb, IN struct inode *Inode)
Definition: generic.c:548
void ext4_xattr_purge_items(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:736
void extents_bforget(struct buffer_head *bh)
Definition: ext4_bh.c:64

Referenced by Ext2OverwriteEa(), Ext2QueryEa(), Ext2QueryFileInformation(), and Ext2SetEa().

◆ ext4_fs_remove_xattr()

int ext4_fs_remove_xattr ( struct ext4_xattr_ref ref,
__u8  name_index,
const char name,
size_t  name_len 
)

Definition at line 1072 of file ext4_xattr.c.

1074 {
1075  return ext4_xattr_remove_item(ref, name_index, name, name_len);
1076 }
Definition: send.c:47
static int ext4_xattr_remove_item(struct ext4_xattr_ref *xattr_ref, __u8 name_index, const char *name, size_t name_len)
Definition: ext4_xattr.c:605
Definition: name.c:38

◆ ext4_fs_set_xattr()

int ext4_fs_set_xattr ( struct ext4_xattr_ref ref,
__u8  name_index,
const char name,
size_t  name_len,
const void data,
size_t  data_size,
BOOL  replace 
)

Definition at line 1024 of file ext4_xattr.c.

1027 {
1028  int ret = 0;
1029  struct ext4_xattr_item *item =
1031  if (replace) {
1032  if (!item) {
1033  ret = -ENODATA;
1034  goto Finish;
1035  }
1036  if (item->data_size != data_size)
1038 
1039  if (ret != 0) {
1040  goto Finish;
1041  }
1042  memcpy(item->data, data, data_size);
1043  } else {
1044  if (item) {
1045  ret = -EEXIST;
1046  goto Finish;
1047  }
1049  data, data_size, &ret);
1050  }
1051 Finish:
1052  return ret;
1053 }
size_t data_size
Definition: ext4_xattr.h:134
static int ext4_xattr_resize_item(struct ext4_xattr_ref *xattr_ref, struct ext4_xattr_item *item, size_t new_data_size)
Definition: ext4_xattr.c:646
#define ENODATA
Definition: errno.h:65
Definition: send.c:47
#define EEXIST
Definition: acclib.h:88
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:47
static struct ext4_xattr_item * ext4_xattr_lookup_item(struct ext4_xattr_ref *xattr_ref, __u8 name_index, const char *name, size_t name_len)
Definition: ext4_xattr.c:467
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ATOM item
Definition: dde.c:856
static struct ext4_xattr_item * ext4_xattr_insert_item(struct ext4_xattr_ref *xattr_ref, __u8 name_index, const char *name, size_t name_len, const void *data, size_t data_size, int *err)
Definition: ext4_xattr.c:486
Definition: name.c:38

Referenced by Ext2OverwriteEa().

◆ ext4_fs_set_xattr_ordered()

int ext4_fs_set_xattr_ordered ( struct ext4_xattr_ref ref,
__u8  name_index,
const char name,
size_t  name_len,
const void data,
size_t  data_size 
)

Definition at line 1055 of file ext4_xattr.c.

1058 {
1059  int ret = 0;
1060  struct ext4_xattr_item *item =
1062  if (item) {
1063  ret = -EEXIST;
1064  goto Finish;
1065  }
1067  data, data_size, &ret);
1068 Finish:
1069  return ret;
1070 }
size_t data_size
Definition: ext4_xattr.h:134
static struct ext4_xattr_item * ext4_xattr_insert_item_ordered(struct ext4_xattr_ref *xattr_ref, __u8 name_index, const char *name, size_t name_len, const void *data, size_t data_size, int *err)
Definition: ext4_xattr.c:542
Definition: send.c:47
#define EEXIST
Definition: acclib.h:88
static struct ext4_xattr_item * ext4_xattr_lookup_item(struct ext4_xattr_ref *xattr_ref, __u8 name_index, const char *name, size_t name_len)
Definition: ext4_xattr.c:467
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
static ATOM item
Definition: dde.c:856
Definition: name.c:38

Referenced by Ext2SetEa().

◆ ext4_fs_xattr_iterate()

void ext4_fs_xattr_iterate ( struct ext4_xattr_ref ref,
int(*)(struct ext4_xattr_ref *ref, struct ext4_xattr_item *item, BOOL is_last)  iter 
)

Definition at line 978 of file ext4_xattr.c.

982 {
983  struct ext4_xattr_item *item;
984  if (!ref->iter_from) {
985  struct list_head *first_node;
986  first_node = ref->ordered_list.next;
987  if (first_node && first_node != &ref->ordered_list) {
988  ref->iter_from =
989  list_entry(first_node,
990  struct ext4_xattr_item,
991  list_node);
992  }
993  }
994 
995  item = ref->iter_from;
996  while (item) {
997  struct list_head *next_node;
998  struct ext4_xattr_item *next_item;
1000  next_node = item->list_node.next;
1001  if (next_node && next_node != &ref->ordered_list)
1003  list_node);
1004  else
1005  next_item = NULL;
1006  if (iter)
1007  ret = iter(ref, item, !next_item);
1008 
1009  if (ret != EXT4_XATTR_ITERATE_CONT) {
1011  ref->iter_from = NULL;
1012 
1013  break;
1014  }
1015  item = next_item;
1016  }
1017 }
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
Definition: send.c:47
#define list_entry(ptr, type, member)
Definition: list.h:185
Definition: list.h:15
smooth NULL
Definition: ftsmooth.c:416
struct list_head list_node
Definition: ext4_xattr.h:137
static __inline tree_data * next_item(tree *t, tree_data *td)
Definition: treefuncs.c:334
int ret
#define EXT4_XATTR_ITERATE_STOP
Definition: ext4_xattr.h:163
static ATOM item
Definition: dde.c:856
#define EXT4_XATTR_ITERATE_CONT
Definition: ext4_xattr.h:162

Referenced by Ext2QueryEa(), and Ext2QueryFileInformation().

◆ ext4_fs_xattr_iterate_reset()

void ext4_fs_xattr_iterate_reset ( struct ext4_xattr_ref ref)

Definition at line 1019 of file ext4_xattr.c.

1020 {
1021  ref->iter_from = NULL;
1022 }
Definition: send.c:47
smooth NULL
Definition: ftsmooth.c:416

◆ ext4_get_xattr_name_prefix()

const char* ext4_get_xattr_name_prefix ( __u8  name_index,
size_t ret_prefix_len 
)

Definition at line 1277 of file ext4_xattr.c.

1279 {
1280  int i;
1281 
1282  for (i = 0; prefix_tbl[i].prefix; i++) {
1283  size_t prefix_len = strlen(prefix_tbl[i].prefix);
1284  if (prefix_tbl[i].name_index == name_index) {
1285  if (ret_prefix_len)
1286  *ret_prefix_len = prefix_len;
1287 
1288  return prefix_tbl[i].prefix;
1289  }
1290  }
1291  if (ret_prefix_len)
1292  *ret_prefix_len = 0;
1293 
1294  return NULL;
1295 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static const struct xattr_prefix prefix_tbl[]
Definition: ext4_xattr.c:1223
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416

◆ ext4_xattr_purge_items()

void ext4_xattr_purge_items ( struct ext4_xattr_ref xattr_ref)

Definition at line 736 of file ext4_xattr.c.

737 {
738  struct rb_node *first_node;
739  struct ext4_xattr_item *item = NULL;
740  first_node = rb_first(&xattr_ref->root);
741  if (first_node)
742  item = container_of(first_node, struct ext4_xattr_item,
743  node);
744 
745  while (item) {
746  struct rb_node *next_node;
747  struct ext4_xattr_item *next_item = NULL;
748  next_node = rb_next(&item->node);
749  if (next_node)
751  node);
752  else
753  next_item = NULL;
754 
755  ext4_xattr_item_remove(xattr_ref, item);
757 
758  item = next_item;
759  }
760  xattr_ref->ea_size = 0;
761  if (ext4_xattr_inode_space(xattr_ref) <
762  sizeof(struct ext4_xattr_ibody_header))
763  xattr_ref->inode_size_rem = 0;
764  else
765  xattr_ref->inode_size_rem =
766  ext4_xattr_inode_space(xattr_ref) -
767  sizeof(struct ext4_xattr_ibody_header);
768 
769  xattr_ref->block_size_rem =
770  ext4_xattr_block_space(xattr_ref) -
771  sizeof(struct ext4_xattr_header);
772 }
static __s32 ext4_xattr_inode_space(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:436
size_t block_size_rem
Definition: ext4_xattr.h:152
struct rb_node * rb_next(struct rb_node *)
Definition: rbtree.c:320
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
struct rb_node * rb_first(struct rb_root *)
Definition: rbtree.c:294
static void ext4_xattr_item_remove(struct ext4_xattr_ref *xattr_ref, struct ext4_xattr_item *item)
Definition: ext4_xattr.c:224
size_t ea_size
Definition: ext4_xattr.h:150
smooth NULL
Definition: ftsmooth.c:416
static __inline tree_data * next_item(tree *t, tree_data *td)
Definition: treefuncs.c:334
size_t inode_size_rem
Definition: ext4_xattr.h:151
#define container_of(ptr, type, member)
Definition: glue.h:15
static void ext4_xattr_item_free(struct ext4_xattr_item *item)
Definition: ext4_xattr.c:301
static ATOM item
Definition: dde.c:856
struct rb_root root
Definition: ext4_xattr.h:158
static __s32 ext4_xattr_block_space(struct ext4_xattr_ref *xattr_ref)
Definition: ext4_xattr.c:444
Definition: rbtree.h:97
Definition: dlist.c:348

Referenced by Ext2OverwriteEa(), Ext2SetEa(), ext4_fs_get_xattr_ref(), and ext4_fs_put_xattr_ref().