From efff783602d4f4872b1733b70ed89cbd5c685dc8 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Tue, 27 Nov 2007 20:41:09 +0100 Subject: [PATCH] Added getters/setters from IsoNode permissions and owners. --- src/libisofs.h | 49 +++++++++++++++++++++++++++++++++++- src/node.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++- src/node.h | 18 +++++++++++++ 3 files changed, 133 insertions(+), 2 deletions(-) diff --git a/src/libisofs.h b/src/libisofs.h index bb369ab..056e54f 100644 --- a/src/libisofs.h +++ b/src/libisofs.h @@ -8,8 +8,11 @@ #ifndef LIBISO_LIBISOFS_H_ #define LIBISO_LIBISOFS_H_ +#include + typedef struct Iso_Node IsoNode; typedef struct Iso_Dir IsoDir; +typedef struct Iso_Symlink IsoSymlink; /** * Increments the reference counting of the given node. @@ -35,6 +38,50 @@ void iso_node_set_name(IsoNode *node, const char *name); * The returned string belongs to the node and should not be modified nor * freed. Use strdup if you really need your own copy. */ -const char *iso_node_get_name(IsoNode *node); +const char *iso_node_get_name(const IsoNode *node); + +/** + * Set the permissions for the node. This attribute is only useful when + * Rock Ridge extensions are enabled. + * + * @param mode + * bitmask with the permissions of the node, as specified in 'man 2 stat'. + * The file type bitfields will be ignored, only file permissions will be + * modified. + */ +void iso_node_set_permissions(IsoNode *node, mode_t mode); + +/** + * Get the permissions for the node + */ +mode_t iso_node_get_permissions(const IsoNode *node); + +/** + * Get the mode of the node, both permissions and file type, as specified in + * 'man 2 stat'. + */ +mode_t iso_node_get_mode(const IsoNode *node); + +/** + * Set the user id for the node. This attribute is only useful when + * Rock Ridge extensions are enabled. + */ +void iso_node_set_uid(IsoNode *node, uid_t uid); + +/** + * Get the user id of the node. + */ +uid_t iso_node_get_uid(const IsoNode *node); + +/** + * Set the group id for the node. This attribute is only useful when + * Rock Ridge extensions are enabled. + */ +void iso_node_set_gid(IsoNode *node, gid_t gid); + +/** + * Get the group id of the node. + */ +gid_t iso_node_get_gid(const IsoNode *node); #endif /*LIBISO_LIBISOFS_H_*/ diff --git a/src/node.c b/src/node.c index 4299741..66a4b42 100644 --- a/src/node.c +++ b/src/node.c @@ -50,7 +50,73 @@ void iso_node_set_name(IsoNode *node, const char *name) * The returned string belongs to the node and should not be modified nor * freed. Use strdup if you really need your own copy. */ -const char *iso_node_get_name(IsoNode *node) +const char *iso_node_get_name(const IsoNode *node) { return node->name; } + +/** + * Set the permissions for the node. This attribute is only useful when + * Rock Ridge extensions are enabled. + * + * @param mode + * bitmask with the permissions of the node, as specified in 'man 2 stat'. + * The file type bitfields will be ignored, only file permissions will be + * modified. + */ +void iso_node_set_permissions(IsoNode *node, mode_t mode) +{ + node->mode = (node->mode & S_IFMT) | (mode & ~S_IFMT); +} + +/** + * Get the permissions for the node + */ +mode_t iso_node_get_permissions(const IsoNode *node) +{ + return node->mode & ~S_IFMT; +} + +/** + * Get the mode of the node, both permissions and file type, as specified in + * 'man 2 stat'. + */ +mode_t iso_node_get_mode(const IsoNode *node) +{ + return node->mode; +} + + +/** + * Set the user id for the node. This attribute is only useful when + * Rock Ridge extensions are enabled. + */ +void iso_node_set_uid(IsoNode *node, uid_t uid) +{ + node->uid = uid; +} + +/** + * Get the user id of the node. + */ +uid_t iso_node_get_uid(const IsoNode *node) +{ + return node->uid; +} + +/** + * Set the group id for the node. This attribute is only useful when + * Rock Ridge extensions are enabled. + */ +void iso_node_set_gid(IsoNode *node, gid_t gid) +{ + node->gid = gid; +} + +/** + * Get the group id of the node. + */ +gid_t iso_node_get_gid(const IsoNode *node) +{ + return node->gid; +} diff --git a/src/node.h b/src/node.h index 11da0c9..faacdac 100644 --- a/src/node.h +++ b/src/node.h @@ -29,6 +29,16 @@ enum IsoNodeType { LIBISO_BOOT }; +/** + * Flag used to hide a file in the RR/ISO or Joliet tree. + * + * \see iso_tree_node_set_hidden + */ +enum IsoHideNodeFlag { + LIBISO_HIDE_ON_RR = 1 << 0, + LIBISO_HIDE_ON_JOLIET = 1 << 1 +}; + /** * */ @@ -56,6 +66,8 @@ struct Iso_Node time_t atime; /**< time of last access */ time_t mtime; /**< time of last modification */ time_t ctime; /**< time of last status change */ + + int hidden; /**< whether the node will be hidden, see IsoHideNodeFlag */ struct IsoDir *parent; /**< parent node, NULL for root */ @@ -88,5 +100,11 @@ struct Iso_File }; +struct Iso_Symlink +{ + IsoNode node; + + char *dest; +}; #endif /*LIBISO_NODE_H_*/