Added getters/setters from IsoNode permissions and owners.

This commit is contained in:
Vreixo Formoso 2007-11-27 20:41:09 +01:00
parent b9152421f3
commit efff783602
3 changed files with 133 additions and 2 deletions

View File

@ -8,8 +8,11 @@
#ifndef LIBISO_LIBISOFS_H_
#define LIBISO_LIBISOFS_H_
#include <sys/stat.h>
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_*/

View File

@ -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;
}

View File

@ -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_*/