From fb2309ea167cb226df8180912e77cc9f2a4a9c6f Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 16 Feb 2009 08:29:21 +0100 Subject: [PATCH] Moved iso_local_*() API functions from node.c to fs_local.c --- libisofs/fs_local.c | 134 ++++++++++++++++++++++++++++++++++++++++++++ libisofs/libisofs.h | 4 +- libisofs/node.c | 133 ------------------------------------------- 3 files changed, 136 insertions(+), 135 deletions(-) diff --git a/libisofs/fs_local.c b/libisofs/fs_local.c index 125c473..ddb55c0 100644 --- a/libisofs/fs_local.c +++ b/libisofs/fs_local.c @@ -768,3 +768,137 @@ int iso_local_filesystem_new(IsoFilesystem **fs) *fs = lfs; return ISO_SUCCESS; } + + +/* ts A90127 */ +int iso_local_get_acl_text(char *disk_path, char **text, int flag) +{ + +#ifdef Libisofs_with_aaiP + + int ret; + + ret = aaip_get_acl_text(disk_path, text, flag & (1 | 16 | 32 | (1 << 15))); + return ret; + +#else /* Libisofs_with_aaiP */ + + return 0; + +#endif /* ! Libisofs_with_aaiP */ + +} + + +/* ts A90118 */ +int iso_local_set_acl_text(char *disk_path, char *text, int flag) +{ + +#ifdef Libisofs_with_aaiP + + int ret; + + ret = aaip_set_acl_text(disk_path, text, flag & (1 | 32)); + if (ret < 0) + return ISO_AAIP_NO_SET_LOCAL; + return ret; + +#else /* Libisofs_with_aaiP */ + + return 0; + +#endif /* ! Libisofs_with_aaiP */ + +} + + +/* ts A90131 */ +int iso_local_get_attrs(char *disk_path, size_t *num_attrs, char ***names, + size_t **value_lengths, char ***values, int flag) +{ + +#ifdef Libisofs_with_aaiP + + int ret; + + ret = aaip_get_attr_list(disk_path, + num_attrs, names, value_lengths, values, + (flag & (1 | 4 | 8 | 32 | (1 << 15))) | 2 | 16); + if (ret <= 0) + return ISO_AAIP_NO_GET_LOCAL; + return 1; + +#else /* Libisofs_with_aaiP */ + + *num_attrs = 0; + *names = NULL; + *value_lengths = NULL; + *values = NULL; + return 1; + +#endif /* ! Libisofs_with_aaiP */ + +} + + +/* ts A90131 */ +int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names, + size_t *value_lengths, char **values, int flag) +{ + +#ifdef Libisofs_with_aaiP + int ret; + + ret = aaip_set_attr_list(disk_path, num_attrs, names, value_lengths, + values, (flag & (8 | 32)) | !(flag & 1)); + if (ret <= 0) { + if (ret == -1) + return ISO_OUT_OF_MEM; + if (ret == -2) + return ISO_AAIP_BAD_AASTRING; + return ISO_AAIP_NO_SET_LOCAL; + } + return 1; + +#else /* Libisofs_with_aaiP */ + + if (num_attrs > 0) + return ISO_AAIP_NOT_ENABLED; + return 1; + +#endif /* ! Libisofs_with_aaiP */ + +} + + +/* ts A90207 */ +int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag) +{ + struct stat stbuf; + int ret; + +#ifdef Libisofs_with_aaiP + char *a_text = NULL; +#endif + + if (flag & 32) + ret = stat(disk_path, &stbuf); + else + ret = lstat(disk_path, &stbuf); + if (ret == -1) + return -1; + *st_mode = stbuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); + +#ifdef Libisofs_with_aaiP + + ret = iso_local_get_acl_text(disk_path, &a_text, 16 | (flag & 32)); + if (a_text != NULL) { + aaip_cleanout_st_mode(a_text, st_mode, 4 | 16); + iso_local_get_acl_text(disk_path, &a_text, 1 << 15); /* free a_text */ + } + +#endif /* Libisofs_with_aaiP */ + + return 1; +} + diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index ac61098..a0e9e49 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -4293,7 +4293,7 @@ int aaip_xinfo_func(void *data, int flag); * Bitfield for control purposes * bit4= if no "access" ACL is available: return *access_text == NULL * else: produce ACL from stat(2) permissions - * bit15= free memory and return 1 + * bit15= free memory and return 1 (node may be NULL) * @return * 2 *access_text was produced from stat(2) permissions * 1 *access_text was produced from ACL of node @@ -4391,7 +4391,7 @@ mode_t iso_node_get_perms_wo_acl(const IsoNode *node); * Bitfield for control purposes * bit0= obtain eventual ACLs as attribute with empty name * bit2= with bit0: do not obtain attributes other than ACLs - * bit15= free memory + * bit15= free memory (node may be NULL) * @return * 1 = ok (but *num_attrs may be 0) * < 0 = error diff --git a/libisofs/node.c b/libisofs/node.c index 43f3bba..13acf64 100644 --- a/libisofs/node.c +++ b/libisofs/node.c @@ -2113,107 +2113,6 @@ bad_decode:; } -/* ts A90127 */ -int iso_local_get_acl_text(char *disk_path, char **text, int flag) -{ - -#ifdef Libisofs_with_aaiP - - int ret; - - ret = aaip_get_acl_text(disk_path, text, flag & (1 | 16 | 32 | (1 << 15))); - return ret; - -#else /* Libisofs_with_aaiP */ - - return 0; - -#endif /* ! Libisofs_with_aaiP */ - -} - - -/* ts A90118 */ -int iso_local_set_acl_text(char *disk_path, char *text, int flag) -{ - -#ifdef Libisofs_with_aaiP - - int ret; - - ret = aaip_set_acl_text(disk_path, text, flag & (1 | 32)); - if (ret < 0) - return ISO_AAIP_NO_SET_LOCAL; - return ret; - -#else /* Libisofs_with_aaiP */ - - return 0; - -#endif /* ! Libisofs_with_aaiP */ - -} - - -/* ts A90131 */ -int iso_local_get_attrs(char *disk_path, size_t *num_attrs, char ***names, - size_t **value_lengths, char ***values, int flag) -{ - -#ifdef Libisofs_with_aaiP - - int ret; - - ret = aaip_get_attr_list(disk_path, - num_attrs, names, value_lengths, values, - (flag & (1 | 4 | 8 | 32 | (1 << 15))) | 2 | 16); - if (ret <= 0) - return ISO_AAIP_NO_GET_LOCAL; - return 1; - -#else /* Libisofs_with_aaiP */ - - *num_attrs = 0; - *names = NULL; - *value_lengths = NULL; - *values = NULL; - return 1; - -#endif /* ! Libisofs_with_aaiP */ - -} - - -/* ts A90131 */ -int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names, - size_t *value_lengths, char **values, int flag) -{ - -#ifdef Libisofs_with_aaiP - int ret; - - ret = aaip_set_attr_list(disk_path, num_attrs, names, value_lengths, - values, (flag & (8 | 32)) | !(flag & 1)); - if (ret <= 0) { - if (ret == -1) - return ISO_OUT_OF_MEM; - if (ret == -2) - return ISO_AAIP_BAD_AASTRING; - return ISO_AAIP_NO_SET_LOCAL; - } - return 1; - -#else /* Libisofs_with_aaiP */ - - if (num_attrs > 0) - return ISO_AAIP_NOT_ENABLED; - return 1; - -#endif /* ! Libisofs_with_aaiP */ - -} - - /* ts A90206 */ mode_t iso_node_get_perms_wo_acl(const IsoNode *node) { @@ -2242,35 +2141,3 @@ ex:; } - -/* ts A90207 */ -int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag) -{ - struct stat stbuf; - int ret; - -#ifdef Libisofs_with_aaiP - char *a_text = NULL; -#endif - - if (flag & 32) - ret = stat(disk_path, &stbuf); - else - ret = lstat(disk_path, &stbuf); - if (ret == -1) - return -1; - *st_mode = stbuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); - -#ifdef Libisofs_with_aaiP - - ret = iso_local_get_acl_text(disk_path, &a_text, 16 | (flag & 32)); - if (a_text != NULL) { - aaip_cleanout_st_mode(a_text, st_mode, 4 | 16); - iso_local_get_acl_text(disk_path, &a_text, 1 << 15); /* free a_text */ - } - -#endif /* Libisofs_with_aaiP */ - - return 1; -} -