Lines Matching refs:n
12 static inline char *ndr_get_field(struct ndr *n) in ndr_get_field() argument
14 return n->data + n->offset; in ndr_get_field()
17 static int try_to_realloc_ndr_blob(struct ndr *n, size_t sz) in try_to_realloc_ndr_blob() argument
21 data = krealloc(n->data, n->offset + sz + 1024, GFP_KERNEL); in try_to_realloc_ndr_blob()
25 n->data = data; in try_to_realloc_ndr_blob()
26 n->length += 1024; in try_to_realloc_ndr_blob()
27 memset(n->data + n->offset, 0, 1024); in try_to_realloc_ndr_blob()
31 static int ndr_write_int16(struct ndr *n, __u16 value) in ndr_write_int16() argument
33 if (n->length <= n->offset + sizeof(value)) { in ndr_write_int16()
36 ret = try_to_realloc_ndr_blob(n, sizeof(value)); in ndr_write_int16()
41 *(__le16 *)ndr_get_field(n) = cpu_to_le16(value); in ndr_write_int16()
42 n->offset += sizeof(value); in ndr_write_int16()
46 static int ndr_write_int32(struct ndr *n, __u32 value) in ndr_write_int32() argument
48 if (n->length <= n->offset + sizeof(value)) { in ndr_write_int32()
51 ret = try_to_realloc_ndr_blob(n, sizeof(value)); in ndr_write_int32()
56 *(__le32 *)ndr_get_field(n) = cpu_to_le32(value); in ndr_write_int32()
57 n->offset += sizeof(value); in ndr_write_int32()
61 static int ndr_write_int64(struct ndr *n, __u64 value) in ndr_write_int64() argument
63 if (n->length <= n->offset + sizeof(value)) { in ndr_write_int64()
66 ret = try_to_realloc_ndr_blob(n, sizeof(value)); in ndr_write_int64()
71 *(__le64 *)ndr_get_field(n) = cpu_to_le64(value); in ndr_write_int64()
72 n->offset += sizeof(value); in ndr_write_int64()
76 static int ndr_write_bytes(struct ndr *n, void *value, size_t sz) in ndr_write_bytes() argument
78 if (n->length <= n->offset + sz) { in ndr_write_bytes()
81 ret = try_to_realloc_ndr_blob(n, sz); in ndr_write_bytes()
86 memcpy(ndr_get_field(n), value, sz); in ndr_write_bytes()
87 n->offset += sz; in ndr_write_bytes()
91 static int ndr_write_string(struct ndr *n, char *value) in ndr_write_string() argument
96 if (n->length <= n->offset + sz) { in ndr_write_string()
99 ret = try_to_realloc_ndr_blob(n, sz); in ndr_write_string()
104 memcpy(ndr_get_field(n), value, sz); in ndr_write_string()
105 n->offset += sz; in ndr_write_string()
106 n->offset = ALIGN(n->offset, 2); in ndr_write_string()
110 static int ndr_read_string(struct ndr *n, void *value, size_t sz) in ndr_read_string() argument
114 if (n->offset + sz > n->length) in ndr_read_string()
117 len = strnlen(ndr_get_field(n), sz); in ndr_read_string()
119 memcpy(value, ndr_get_field(n), len); in ndr_read_string()
121 n->offset += len; in ndr_read_string()
122 n->offset = ALIGN(n->offset, 2); in ndr_read_string()
126 static int ndr_read_bytes(struct ndr *n, void *value, size_t sz) in ndr_read_bytes() argument
128 if (n->offset + sz > n->length) in ndr_read_bytes()
132 memcpy(value, ndr_get_field(n), sz); in ndr_read_bytes()
133 n->offset += sz; in ndr_read_bytes()
137 static int ndr_read_int16(struct ndr *n, __u16 *value) in ndr_read_int16() argument
139 if (n->offset + sizeof(__u16) > n->length) in ndr_read_int16()
143 *value = le16_to_cpu(*(__le16 *)ndr_get_field(n)); in ndr_read_int16()
144 n->offset += sizeof(__u16); in ndr_read_int16()
148 static int ndr_read_int32(struct ndr *n, __u32 *value) in ndr_read_int32() argument
150 if (n->offset + sizeof(__u32) > n->length) in ndr_read_int32()
154 *value = le32_to_cpu(*(__le32 *)ndr_get_field(n)); in ndr_read_int32()
155 n->offset += sizeof(__u32); in ndr_read_int32()
159 static int ndr_read_int64(struct ndr *n, __u64 *value) in ndr_read_int64() argument
161 if (n->offset + sizeof(__u64) > n->length) in ndr_read_int64()
165 *value = le64_to_cpu(*(__le64 *)ndr_get_field(n)); in ndr_read_int64()
166 n->offset += sizeof(__u64); in ndr_read_int64()
170 int ndr_encode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da) in ndr_encode_dos_attr() argument
175 n->offset = 0; in ndr_encode_dos_attr()
176 n->length = 1024; in ndr_encode_dos_attr()
177 n->data = kzalloc(n->length, GFP_KERNEL); in ndr_encode_dos_attr()
178 if (!n->data) in ndr_encode_dos_attr()
183 ret = ndr_write_string(n, hex_attr); in ndr_encode_dos_attr()
185 ret = ndr_write_string(n, ""); in ndr_encode_dos_attr()
190 ret = ndr_write_int16(n, da->version); in ndr_encode_dos_attr()
194 ret = ndr_write_int32(n, da->version); in ndr_encode_dos_attr()
198 ret = ndr_write_int32(n, da->flags); in ndr_encode_dos_attr()
202 ret = ndr_write_int32(n, da->attr); in ndr_encode_dos_attr()
207 ret = ndr_write_int32(n, da->ea_size); in ndr_encode_dos_attr()
210 ret = ndr_write_int64(n, da->size); in ndr_encode_dos_attr()
213 ret = ndr_write_int64(n, da->alloc_size); in ndr_encode_dos_attr()
215 ret = ndr_write_int64(n, da->itime); in ndr_encode_dos_attr()
220 ret = ndr_write_int64(n, da->create_time); in ndr_encode_dos_attr()
225 ret = ndr_write_int64(n, da->change_time); in ndr_encode_dos_attr()
229 int ndr_decode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da) in ndr_decode_dos_attr() argument
235 n->offset = 0; in ndr_decode_dos_attr()
236 ret = ndr_read_string(n, hex_attr, sizeof(hex_attr)); in ndr_decode_dos_attr()
240 ret = ndr_read_int16(n, &da->version); in ndr_decode_dos_attr()
249 ret = ndr_read_int32(n, &version2); in ndr_decode_dos_attr()
259 ret = ndr_read_int32(n, NULL); in ndr_decode_dos_attr()
263 ret = ndr_read_int32(n, &da->attr); in ndr_decode_dos_attr()
268 ret = ndr_read_int64(n, &da->itime); in ndr_decode_dos_attr()
272 ret = ndr_read_int64(n, &da->create_time); in ndr_decode_dos_attr()
274 ret = ndr_read_int32(n, NULL); in ndr_decode_dos_attr()
278 ret = ndr_read_int64(n, NULL); in ndr_decode_dos_attr()
282 ret = ndr_read_int64(n, NULL); in ndr_decode_dos_attr()
286 ret = ndr_read_int64(n, &da->create_time); in ndr_decode_dos_attr()
290 ret = ndr_read_int64(n, NULL); in ndr_decode_dos_attr()
296 static int ndr_encode_posix_acl_entry(struct ndr *n, struct xattr_smb_acl *acl) in ndr_encode_posix_acl_entry() argument
300 ret = ndr_write_int32(n, acl->count); in ndr_encode_posix_acl_entry()
304 n->offset = ALIGN(n->offset, 8); in ndr_encode_posix_acl_entry()
305 ret = ndr_write_int32(n, acl->count); in ndr_encode_posix_acl_entry()
309 ret = ndr_write_int32(n, 0); in ndr_encode_posix_acl_entry()
314 n->offset = ALIGN(n->offset, 8); in ndr_encode_posix_acl_entry()
315 ret = ndr_write_int16(n, acl->entries[i].type); in ndr_encode_posix_acl_entry()
319 ret = ndr_write_int16(n, acl->entries[i].type); in ndr_encode_posix_acl_entry()
324 n->offset = ALIGN(n->offset, 8); in ndr_encode_posix_acl_entry()
325 ret = ndr_write_int64(n, acl->entries[i].uid); in ndr_encode_posix_acl_entry()
327 n->offset = ALIGN(n->offset, 8); in ndr_encode_posix_acl_entry()
328 ret = ndr_write_int64(n, acl->entries[i].gid); in ndr_encode_posix_acl_entry()
334 ret = ndr_write_int32(n, acl->entries[i].perm); in ndr_encode_posix_acl_entry()
340 int ndr_encode_posix_acl(struct ndr *n, in ndr_encode_posix_acl() argument
351 n->offset = 0; in ndr_encode_posix_acl()
352 n->length = 1024; in ndr_encode_posix_acl()
353 n->data = kzalloc(n->length, GFP_KERNEL); in ndr_encode_posix_acl()
354 if (!n->data) in ndr_encode_posix_acl()
359 ret = ndr_write_int32(n, ref_id); in ndr_encode_posix_acl()
362 ret = ndr_write_int32(n, 0); in ndr_encode_posix_acl()
369 ret = ndr_write_int32(n, ref_id); in ndr_encode_posix_acl()
372 ret = ndr_write_int32(n, 0); in ndr_encode_posix_acl()
378 ret = ndr_write_int64(n, from_kuid(&init_user_ns, vfsuid_into_kuid(vfsuid))); in ndr_encode_posix_acl()
382 ret = ndr_write_int64(n, from_kgid(&init_user_ns, vfsgid_into_kgid(vfsgid))); in ndr_encode_posix_acl()
385 ret = ndr_write_int32(n, inode->i_mode); in ndr_encode_posix_acl()
390 ret = ndr_encode_posix_acl_entry(n, acl); in ndr_encode_posix_acl()
392 ret = ndr_encode_posix_acl_entry(n, def_acl); in ndr_encode_posix_acl()
397 int ndr_encode_v4_ntacl(struct ndr *n, struct xattr_ntacl *acl) in ndr_encode_v4_ntacl() argument
402 n->offset = 0; in ndr_encode_v4_ntacl()
403 n->length = 2048; in ndr_encode_v4_ntacl()
404 n->data = kzalloc(n->length, GFP_KERNEL); in ndr_encode_v4_ntacl()
405 if (!n->data) in ndr_encode_v4_ntacl()
408 ret = ndr_write_int16(n, acl->version); in ndr_encode_v4_ntacl()
412 ret = ndr_write_int32(n, acl->version); in ndr_encode_v4_ntacl()
416 ret = ndr_write_int16(n, 2); in ndr_encode_v4_ntacl()
420 ret = ndr_write_int32(n, ref_id); in ndr_encode_v4_ntacl()
425 ret = ndr_write_int16(n, acl->hash_type); in ndr_encode_v4_ntacl()
429 ret = ndr_write_bytes(n, acl->hash, XATTR_SD_HASH_SIZE); in ndr_encode_v4_ntacl()
433 ret = ndr_write_bytes(n, acl->desc, acl->desc_len); in ndr_encode_v4_ntacl()
437 ret = ndr_write_int64(n, acl->current_time); in ndr_encode_v4_ntacl()
441 ret = ndr_write_bytes(n, acl->posix_acl_hash, XATTR_SD_HASH_SIZE); in ndr_encode_v4_ntacl()
446 ret = ndr_write_bytes(n, acl->sd_buf, acl->sd_size); in ndr_encode_v4_ntacl()
450 int ndr_decode_v4_ntacl(struct ndr *n, struct xattr_ntacl *acl) in ndr_decode_v4_ntacl() argument
455 n->offset = 0; in ndr_decode_v4_ntacl()
456 ret = ndr_read_int16(n, &acl->version); in ndr_decode_v4_ntacl()
464 ret = ndr_read_int32(n, &version2); in ndr_decode_v4_ntacl()
474 ret = ndr_read_int16(n, NULL); in ndr_decode_v4_ntacl()
479 ret = ndr_read_int32(n, NULL); in ndr_decode_v4_ntacl()
483 ret = ndr_read_int16(n, &acl->hash_type); in ndr_decode_v4_ntacl()
487 ret = ndr_read_bytes(n, acl->hash, XATTR_SD_HASH_SIZE); in ndr_decode_v4_ntacl()
491 ndr_read_bytes(n, acl->desc, 10); in ndr_decode_v4_ntacl()
498 ret = ndr_read_int64(n, NULL); in ndr_decode_v4_ntacl()
503 ret = ndr_read_bytes(n, acl->posix_acl_hash, XATTR_SD_HASH_SIZE); in ndr_decode_v4_ntacl()
507 acl->sd_size = n->length - n->offset; in ndr_decode_v4_ntacl()
512 ret = ndr_read_bytes(n, acl->sd_buf, acl->sd_size); in ndr_decode_v4_ntacl()