2007-11-24 12:14:45 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Vreixo Formoso
|
|
|
|
*
|
|
|
|
* This file is part of the libisofs project; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation. See COPYING file for details.
|
|
|
|
*/
|
|
|
|
#ifndef LIBISO_LIBISOFS_H_
|
|
|
|
#define LIBISO_LIBISOFS_H_
|
|
|
|
|
2007-11-27 19:41:09 +00:00
|
|
|
#include <sys/stat.h>
|
2007-12-02 18:10:30 +00:00
|
|
|
|
|
|
|
typedef struct Iso_Image IsoImage;
|
|
|
|
|
2007-11-24 15:58:36 +00:00
|
|
|
typedef struct Iso_Node IsoNode;
|
|
|
|
typedef struct Iso_Dir IsoDir;
|
2007-11-27 19:41:09 +00:00
|
|
|
typedef struct Iso_Symlink IsoSymlink;
|
2007-12-02 16:59:36 +00:00
|
|
|
typedef struct Iso_File IsoFile;
|
2007-12-06 01:43:24 +00:00
|
|
|
typedef struct Iso_Special IsoSpecial;
|
2007-12-02 16:59:36 +00:00
|
|
|
|
2007-12-01 01:22:00 +00:00
|
|
|
typedef struct Iso_Dir_Iter IsoDirIter;
|
2007-11-24 12:14:45 +00:00
|
|
|
|
2007-12-04 21:33:40 +00:00
|
|
|
/**
|
|
|
|
* The type of an IsoNode.
|
2007-12-07 21:25:31 +00:00
|
|
|
*
|
|
|
|
* When an user gets an IsoNode from an image, (s)he can use
|
|
|
|
* iso_node_get_type() to get the current type of the node, and then
|
|
|
|
* cast to the appropriate subtype. For example:
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* IsoNode *node;
|
|
|
|
* res = iso_dir_iter_next(iter, &node);
|
|
|
|
* if (res == 1 && iso_node_get_type(node) == LIBISO_DIR) {
|
|
|
|
* IsoDir *dir = (IsoDir *)node;
|
|
|
|
* ...
|
|
|
|
* }
|
2007-12-04 21:33:40 +00:00
|
|
|
*/
|
|
|
|
enum IsoNodeType {
|
|
|
|
LIBISO_DIR,
|
|
|
|
LIBISO_FILE,
|
|
|
|
LIBISO_SYMLINK,
|
|
|
|
LIBISO_SPECIAL,
|
|
|
|
LIBISO_BOOT
|
|
|
|
};
|
|
|
|
|
2007-12-02 18:10:30 +00:00
|
|
|
/**
|
|
|
|
* Create a new image, empty.
|
|
|
|
*
|
|
|
|
* The image will be owned by you and should be unref() when no more needed.
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* Name of the image. This will be used as volset_id and volume_id.
|
|
|
|
* @param image
|
|
|
|
* Location where the image pointer will be stored.
|
|
|
|
* @return
|
|
|
|
* 1 sucess, < 0 error
|
|
|
|
*/
|
|
|
|
int iso_image_new(const char *name, IsoImage **image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Increments the reference counting of the given image.
|
|
|
|
*/
|
|
|
|
void iso_image_ref(IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Decrements the reference couting of the given image.
|
|
|
|
* If it reaches 0, the image is free, together with its tree nodes (whether
|
|
|
|
* their refcount reach 0 too, of course).
|
|
|
|
*/
|
|
|
|
void iso_image_unref(IsoImage *image);
|
|
|
|
|
2007-12-02 18:49:11 +00:00
|
|
|
/**
|
|
|
|
* Get the root directory of the image.
|
|
|
|
* No extra ref is added to it, so you musn't unref it. Use iso_node_ref()
|
|
|
|
* if you want to get your own reference.
|
|
|
|
*/
|
|
|
|
IsoDir *iso_image_get_root(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in the volset identifier for a image.
|
|
|
|
*/
|
|
|
|
void iso_image_set_volset_id(IsoImage *image, const char *volset_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the volset identifier.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_volset_id(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in the volume identifier for a image.
|
|
|
|
*/
|
|
|
|
void iso_image_set_volume_id(IsoImage *image, const char *volume_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the volume identifier.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_volume_id(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in the publisher for a image.
|
|
|
|
*/
|
|
|
|
void iso_image_set_publisher_id(IsoImage *image, const char *publisher_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the publisher of a image.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_publisher_id(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in the data preparer for a image.
|
|
|
|
*/
|
|
|
|
void iso_image_set_data_preparer_id(IsoImage *image,
|
|
|
|
const char *data_preparer_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the data preparer of a image.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_data_preparer_id(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in the system id for a image. Up to 32 characters.
|
|
|
|
*/
|
|
|
|
void iso_image_set_system_id(IsoImage *image, const char *system_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the system id of a image.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_system_id(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in the application id for a image. Up to 128 chars.
|
|
|
|
*/
|
|
|
|
void iso_image_set_application_id(IsoImage *image, const char *application_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the application id of a image.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_application_id(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill copyright information for the image. Usually this refers
|
|
|
|
* to a file on disc. Up to 37 characters.
|
|
|
|
*/
|
|
|
|
void iso_image_set_copyright_file_id(IsoImage *image,
|
|
|
|
const char *copyright_file_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the copyright information of a image.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_copyright_file_id(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill abstract information for the image. Usually this refers
|
|
|
|
* to a file on disc. Up to 37 characters.
|
|
|
|
*/
|
|
|
|
void iso_image_set_abstract_file_id(IsoImage *image,
|
|
|
|
const char *abstract_file_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the abstract information of a image.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_abstract_file_id(const IsoImage *image);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill biblio information for the image. Usually this refers
|
|
|
|
* to a file on disc. Up to 37 characters.
|
|
|
|
*/
|
|
|
|
void iso_image_set_biblio_file_id(IsoImage *image,
|
|
|
|
const char *biblio_file_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the biblio information of a image.
|
|
|
|
* The returned string is owned by the image and should not be freed nor
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
const char *iso_image_get_biblio_file_id(const IsoImage *image);
|
|
|
|
|
2007-11-24 12:14:45 +00:00
|
|
|
/**
|
|
|
|
* Increments the reference counting of the given node.
|
|
|
|
*/
|
2007-11-24 15:58:36 +00:00
|
|
|
void iso_node_ref(IsoNode *node);
|
2007-11-24 12:14:45 +00:00
|
|
|
|
2007-11-24 15:58:36 +00:00
|
|
|
/**
|
|
|
|
* Decrements the reference couting of the given node.
|
|
|
|
* If it reach 0, the node is free, and, if the node is a directory,
|
|
|
|
* its children will be unref() too.
|
|
|
|
*/
|
|
|
|
void iso_node_unref(IsoNode *node);
|
|
|
|
|
2007-12-07 21:25:31 +00:00
|
|
|
/**
|
|
|
|
* Get the type of an IsoNode.
|
|
|
|
*/
|
|
|
|
enum IsoNodeType iso_node_get_type(IsoNode *node);
|
|
|
|
|
2007-11-24 15:58:36 +00:00
|
|
|
/**
|
2007-12-06 01:22:11 +00:00
|
|
|
* Set the name of a node. Note that if the node is already added to a dir
|
|
|
|
* this can fail if dir already contains a node with the new name.
|
2007-11-24 15:58:36 +00:00
|
|
|
*
|
2007-12-06 01:22:11 +00:00
|
|
|
* @param name
|
|
|
|
* The name in UTF-8 encoding
|
|
|
|
* @return
|
|
|
|
* 1 on success, < 0 on error
|
2007-11-24 15:58:36 +00:00
|
|
|
*/
|
2007-12-06 01:22:11 +00:00
|
|
|
int iso_node_set_name(IsoNode *node, const char *name);
|
2007-11-24 15:58:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of a node (in UTF-8).
|
|
|
|
* The returned string belongs to the node and should not be modified nor
|
|
|
|
* freed. Use strdup if you really need your own copy.
|
|
|
|
*/
|
2007-11-27 19:41:09 +00:00
|
|
|
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);
|
2007-11-24 12:14:45 +00:00
|
|
|
|
2007-12-06 21:52:01 +00:00
|
|
|
/**
|
|
|
|
* Set the time of last modification of the file
|
|
|
|
*/
|
|
|
|
void iso_node_set_mtime(IsoNode *node, time_t time);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the time of last modification of the file
|
|
|
|
*/
|
|
|
|
time_t iso_node_get_mtime(const IsoNode *node);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the time of last access to the file
|
|
|
|
*/
|
|
|
|
void iso_node_set_atime(IsoNode *node, time_t time);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the time of last access to the file
|
|
|
|
*/
|
|
|
|
time_t iso_node_get_atime(const IsoNode *node);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the time of last status change of the file
|
|
|
|
*/
|
|
|
|
void iso_node_set_ctime(IsoNode *node, time_t time);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the time of last status change of the file
|
|
|
|
*/
|
|
|
|
time_t iso_node_get_ctime(const IsoNode *node);
|
|
|
|
|
2007-12-01 00:42:21 +00:00
|
|
|
/**
|
|
|
|
* Add a new node to a dir. Note that this function don't add a new ref to
|
|
|
|
* the node, so you don't need to free it, it will be automatically freed
|
|
|
|
* when the dir is deleted. Of course, if you want to keep using the node
|
|
|
|
* after the dir life, you need to iso_node_ref() it.
|
|
|
|
*
|
|
|
|
* @param dir
|
|
|
|
* the dir where to add the node
|
|
|
|
* @param child
|
|
|
|
* the node to add. You must ensure that the node hasn't previously added
|
|
|
|
* to other dir, and that the node name is unique inside the child.
|
|
|
|
* Otherwise this function will return a failure, and the child won't be
|
|
|
|
* inserted.
|
2007-12-05 21:37:57 +00:00
|
|
|
* @param replace
|
|
|
|
* if the dir already contains a node with the same name, whether to
|
|
|
|
* replace or not the old node with this.
|
|
|
|
* - 0 not replace (will fail with ISO_NODE_NAME_NOT_UNIQUE)
|
|
|
|
* - 1 replace
|
|
|
|
* TODO #00006 define more values
|
|
|
|
* to replace only if both are the same kind of file
|
|
|
|
* if both are dirs, add contents (and what to do with conflicts?)
|
2007-12-01 00:42:21 +00:00
|
|
|
* @return
|
|
|
|
* number of nodes in dir if succes, < 0 otherwise
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if dir or child are NULL
|
|
|
|
* ISO_NODE_ALREADY_ADDED, if child is already added to other dir
|
|
|
|
* ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
|
2007-12-05 21:37:57 +00:00
|
|
|
* ISO_WRONG_ARG_VALUE, if child == dir, or replace != (0,1)
|
2007-12-01 00:42:21 +00:00
|
|
|
*/
|
2007-12-05 21:37:57 +00:00
|
|
|
int iso_dir_add_node(IsoDir *dir, IsoNode *child, int replace);
|
2007-12-01 00:42:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate a node inside a given dir.
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* The name of the node
|
|
|
|
* @param node
|
|
|
|
* Location for a pointer to the node, it will filled with NULL if the dir
|
|
|
|
* doesn't have a child with the given name.
|
|
|
|
* The node will be owned by the dir and shouldn't be unref(). Just call
|
|
|
|
* iso_node_ref() to get your own reference to the node.
|
2007-12-06 01:22:11 +00:00
|
|
|
* Note that you can pass NULL is the only thing you want to do is check
|
|
|
|
* if a node with such name already exists on dir.
|
2007-12-01 00:42:21 +00:00
|
|
|
* @return
|
|
|
|
* 1 node found, 0 child has no such node, < 0 error
|
|
|
|
* Possible errors:
|
2007-12-06 01:22:11 +00:00
|
|
|
* ISO_NULL_POINTER, if dir or name are NULL
|
2007-12-01 00:42:21 +00:00
|
|
|
*/
|
|
|
|
int iso_dir_get_node(IsoDir *dir, const char *name, IsoNode **node);
|
|
|
|
|
2007-12-01 00:45:35 +00:00
|
|
|
/**
|
|
|
|
* Get the number of children of a directory.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* >= 0 number of items, < 0 error
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if dir is NULL
|
|
|
|
*/
|
|
|
|
int iso_dir_get_nchildren(IsoDir *dir);
|
|
|
|
|
2007-12-02 16:17:04 +00:00
|
|
|
/**
|
|
|
|
* Removes a child from a directory.
|
|
|
|
* The child is not freed, so you will become the owner of the node. Later
|
|
|
|
* you can add the node to another dir (calling iso_dir_add_node), or free
|
|
|
|
* it if you don't need it (with iso_node_unref).
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 on success, < 0 error
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if node is NULL
|
|
|
|
* ISO_NODE_NOT_ADDED_TO_DIR, if node doesn't belong to a dir
|
|
|
|
*/
|
|
|
|
int iso_node_take(IsoNode *node);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a child from a directory and free (unref) it.
|
|
|
|
* If you want to keep the child alive, you need to iso_node_ref() it
|
|
|
|
* before this call, but in that case iso_node_take() is a better
|
|
|
|
* alternative.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 on success, < 0 error
|
|
|
|
*/
|
|
|
|
int iso_node_remove(IsoNode *node);
|
|
|
|
|
2007-12-01 01:22:00 +00:00
|
|
|
/**
|
|
|
|
* Get an iterator for the children of the given dir.
|
|
|
|
*
|
|
|
|
* You can iterate over the children with iso_dir_iter_next. When finished,
|
|
|
|
* you should free the iterator with iso_dir_iter_free.
|
|
|
|
* You musn't delete a child of the same dir, using iso_node_take() or
|
|
|
|
* iso_node_remove(), while you're using the iterator. You can use
|
|
|
|
* iso_node_take_iter() or iso_node_remove_iter() instead.
|
|
|
|
*
|
|
|
|
* You can use the iterator in the way like this
|
|
|
|
*
|
|
|
|
* IsoDirIter *iter;
|
|
|
|
* IsoNode *node;
|
|
|
|
* if ( iso_dir_get_children(dir, &iter) != 1 ) {
|
|
|
|
* // handle error
|
|
|
|
* }
|
|
|
|
* while ( iso_dir_iter_next(iter, &node) == 1 ) {
|
|
|
|
* // do something with the child
|
|
|
|
* }
|
|
|
|
* iso_dir_iter_free(iter);
|
|
|
|
*
|
|
|
|
* An iterator is intended to be used in a single iteration over the
|
|
|
|
* children of a dir. Thus, it should be treated as a temporary object,
|
|
|
|
* and free as soon as possible.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 success, < 0 error
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if dir or iter are NULL
|
|
|
|
* ISO_OUT_OF_MEM
|
|
|
|
*/
|
|
|
|
int iso_dir_get_children(const IsoDir *dir, IsoDirIter **iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the next child.
|
|
|
|
* Take care that the node is owned by its parent, and will be unref() when
|
|
|
|
* the parent is freed. If you want your own ref to it, call iso_node_ref()
|
|
|
|
* on it.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 success, 0 if dir has no more elements, < 0 error
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if node or iter are NULL
|
|
|
|
* ISO_ERROR, on wrong iter usage, usual caused by modiying the
|
|
|
|
* dir during iteration
|
|
|
|
*/
|
|
|
|
int iso_dir_iter_next(IsoDirIter *iter, IsoNode **node);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if there're more children.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 dir has more elements, 0 no, < 0 error
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if iter is NULL
|
|
|
|
*/
|
|
|
|
int iso_dir_iter_has_next(IsoDirIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free a dir iterator.
|
|
|
|
*/
|
|
|
|
void iso_dir_iter_free(IsoDirIter *iter);
|
|
|
|
|
2007-12-01 01:43:37 +00:00
|
|
|
/**
|
2007-12-02 16:17:04 +00:00
|
|
|
* Removes a child from a directory during an iteration, without freeing it.
|
|
|
|
* It's like iso_node_take(), but to be used during a directory iteration.
|
|
|
|
* The node removed will be the last returned by the iteration.
|
2007-12-01 01:43:37 +00:00
|
|
|
*
|
2007-12-02 16:17:04 +00:00
|
|
|
* The behavior on two call to this function without calling iso_dir_iter_next
|
|
|
|
* between then is undefined, and should never occur. (TODO protect against this?)
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 on succes, < 0 error
|
2007-12-01 01:43:37 +00:00
|
|
|
* Possible errors:
|
2007-12-02 16:17:04 +00:00
|
|
|
* ISO_NULL_POINTER, if iter is NULL
|
|
|
|
* ISO_ERROR, on wrong iter usage, for example by call this before
|
|
|
|
* iso_dir_iter_next.
|
2007-12-01 01:43:37 +00:00
|
|
|
*/
|
2007-12-02 16:17:04 +00:00
|
|
|
int iso_dir_iter_take(IsoDirIter *iter);
|
2007-12-01 01:43:37 +00:00
|
|
|
|
|
|
|
/**
|
2007-12-02 16:17:04 +00:00
|
|
|
* Removes a child from a directory during an iteration and unref() it.
|
|
|
|
* It's like iso_node_remove(), but to be used during a directory iteration.
|
|
|
|
* The node removed will be the last returned by the iteration.
|
2007-12-01 01:43:37 +00:00
|
|
|
*
|
2007-12-02 16:17:04 +00:00
|
|
|
* The behavior on two call to this function without calling iso_tree_iter_next
|
|
|
|
* between then is undefined, and should never occur. (TODO protect against this?)
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 on succes, < 0 error
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if iter is NULL
|
|
|
|
* ISO_ERROR, on wrong iter usage, for example by call this before
|
|
|
|
* iso_dir_iter_next.
|
2007-12-01 01:43:37 +00:00
|
|
|
*/
|
2007-12-02 16:17:04 +00:00
|
|
|
int iso_dir_iter_remove(IsoDirIter *iter);
|
2007-12-01 01:43:37 +00:00
|
|
|
|
2007-12-06 01:11:05 +00:00
|
|
|
/**
|
|
|
|
* Get the destination of a node (in UTF-8).
|
|
|
|
* 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_symlink_get_dest(const IsoSymlink *link);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the destination of a link.
|
|
|
|
*/
|
|
|
|
void iso_symlink_set_dest(IsoSymlink *link, const char *dest);
|
|
|
|
|
2007-12-07 21:36:26 +00:00
|
|
|
/**
|
|
|
|
* Sets the order in which a node will be written on image. High weihted files
|
|
|
|
* will be written first, so in a disc them will be written near the center.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* The node which weight will be changed. If it's a dir, this function
|
|
|
|
* will change the weight of all its children. For nodes other that dirs
|
|
|
|
* or regular files, this function has no effect.
|
|
|
|
* @param w
|
|
|
|
* The weight as a integer number, the greater this value is, the
|
|
|
|
* closer from the begining of image the file will be written.
|
|
|
|
*/
|
|
|
|
void iso_node_set_sort_weight(IsoNode *node, int w);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the sort weight of a file.
|
|
|
|
*/
|
|
|
|
int iso_file_get_sort_weight(IsoFile *file);
|
|
|
|
|
2007-12-06 01:11:05 +00:00
|
|
|
/**
|
|
|
|
* Add a new directory to the iso tree. Permissions, owner and hidden atts
|
|
|
|
* are taken from parent, you can modify them later.
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* the dir where the new directory will be created
|
|
|
|
* @param name
|
|
|
|
* name for the new dir. If a node with same name already exists on
|
|
|
|
* parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
|
|
|
|
* @param dir
|
|
|
|
* place where to store a pointer to the newly created dir. No extra
|
|
|
|
* ref is addded, so you will need to call iso_node_ref() if you really
|
|
|
|
* need it. You can pass NULL in this parameter if you don't need the
|
|
|
|
* pointer.
|
|
|
|
* @return
|
|
|
|
* number of nodes in parent if success, < 0 otherwise
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if parent or name are NULL
|
|
|
|
* ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
|
|
|
|
* ISO_MEM_ERROR
|
|
|
|
*/
|
|
|
|
int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir);
|
|
|
|
|
|
|
|
/*
|
|
|
|
TODO #00007 expose Strem and thi function:
|
|
|
|
int iso_tree_add_new_file(IsoDir *parent, const char *name, stream, file)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new symlink to the directory tree. Permissions are set to 0777,
|
|
|
|
* owner and hidden atts are taken from parent. You can modify any of them
|
|
|
|
* later.
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* the dir where the new symlink will be created
|
|
|
|
* @param name
|
2007-12-06 01:43:24 +00:00
|
|
|
* name for the new symlink. If a node with same name already exists on
|
2007-12-06 01:11:05 +00:00
|
|
|
* parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
|
|
|
|
* @param dest
|
|
|
|
* destination of the link
|
|
|
|
* @param link
|
|
|
|
* place where to store a pointer to the newly created link. No extra
|
|
|
|
* ref is addded, so you will need to call iso_node_ref() if you really
|
|
|
|
* need it. You can pass NULL in this parameter if you don't need the
|
|
|
|
* pointer
|
|
|
|
* @return
|
|
|
|
* number of nodes in parent if success, < 0 otherwise
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if parent, name or dest are NULL
|
|
|
|
* ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
|
|
|
|
* ISO_MEM_ERROR
|
|
|
|
*/
|
|
|
|
int iso_tree_add_new_symlink(IsoDir *parent, const char *name,
|
|
|
|
const char *dest, IsoSymlink **link);
|
|
|
|
|
2007-12-06 01:43:24 +00:00
|
|
|
/**
|
|
|
|
* Add a new special file to the directory tree. As far as libisofs concerns,
|
|
|
|
* an special file is a block device, a character device, a FIFO (named pipe)
|
|
|
|
* or a socket. You can choose the specific kind of file you want to add
|
|
|
|
* by setting mode propertly (see man 2 stat).
|
|
|
|
*
|
|
|
|
* Note that special files are only written to image when Rock Ridge
|
|
|
|
* extensions are enabled. Moreover, a special file is just a directory entry
|
|
|
|
* in the image tree, no data is written beyond that.
|
|
|
|
*
|
|
|
|
* Owner and hidden atts are taken from parent. You can modify any of them
|
|
|
|
* later.
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* the dir where the new special file will be created
|
|
|
|
* @param name
|
|
|
|
* name for the new special file. If a node with same name already exists
|
|
|
|
* on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
|
|
|
|
* @param mode
|
|
|
|
* file type and permissions for the new node. Note that you can't
|
|
|
|
* specify any kind of file here, only special types are allowed. i.e,
|
|
|
|
* S_IFSOCK, S_IFBLK, S_IFCHR and S_IFIFO are valid types; S_IFLNK,
|
|
|
|
* S_IFREG and S_IFDIR aren't.
|
|
|
|
* @param dev
|
|
|
|
* device ID, equivalent to the st_rdev field in man 2 stat.
|
|
|
|
* @param special
|
|
|
|
* place where to store a pointer to the newly created special file. No
|
|
|
|
* extra ref is addded, so you will need to call iso_node_ref() if you
|
|
|
|
* really need it. You can pass NULL in this parameter if you don't need
|
|
|
|
* the pointer.
|
|
|
|
* @return
|
|
|
|
* number of nodes in parent if success, < 0 otherwise
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if parent, name or dest are NULL
|
|
|
|
* ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
|
|
|
|
* ISO_WRONG_ARG_VALUE if you select a incorrect mode
|
|
|
|
* ISO_MEM_ERROR
|
|
|
|
*/
|
|
|
|
int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode,
|
|
|
|
dev_t dev, IsoSpecial **special);
|
|
|
|
|
2007-12-07 02:02:46 +00:00
|
|
|
/**
|
|
|
|
* Add a new node to the image tree, from an existing file.
|
|
|
|
*
|
|
|
|
* TODO comment Builder and Filesystem related issues when exposing both
|
|
|
|
*
|
|
|
|
* All attributes will be taken from the source file. The appropriate file
|
|
|
|
* type will be created.
|
|
|
|
*
|
|
|
|
* @param image
|
|
|
|
* The image
|
|
|
|
* @param parent
|
|
|
|
* The directory in the image tree where the node will be added.
|
|
|
|
* @param path
|
|
|
|
* The path of the file to add in the filesystem.
|
|
|
|
* @param node
|
|
|
|
* place where to store a pointer to the newly added file. No
|
|
|
|
* extra ref is addded, so you will need to call iso_node_ref() if you
|
|
|
|
* really need it. You can pass NULL in this parameter if you don't need
|
|
|
|
* the pointer.
|
|
|
|
* @return
|
|
|
|
* number of nodes in parent if success, < 0 otherwise
|
|
|
|
* Possible errors:
|
|
|
|
* ISO_NULL_POINTER, if image, parent or path are NULL
|
|
|
|
* ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
|
|
|
|
* ISO_MEM_ERROR
|
|
|
|
*/
|
|
|
|
int iso_tree_add_node(IsoImage *image, IsoDir *parent, const char *path,
|
|
|
|
IsoNode **node);
|
|
|
|
|
2007-12-08 00:39:31 +00:00
|
|
|
/**
|
|
|
|
* Locate a node by its path on image.
|
|
|
|
*
|
|
|
|
* @param node
|
|
|
|
* Location for a pointer to the node, it will filled with NULL if the
|
|
|
|
* given path does not exists on image.
|
|
|
|
* The node will be owned by the image and shouldn't be unref(). Just call
|
|
|
|
* iso_node_ref() to get your own reference to the node.
|
|
|
|
* Note that you can pass NULL is the only thing you want to do is check
|
|
|
|
* if a node with such path really exists.
|
|
|
|
* @return
|
|
|
|
* 1 found, 0 not found, < 0 error
|
|
|
|
*/
|
|
|
|
int iso_tree_path_to_node(IsoImage *image, const char *path, IsoNode **node);
|
|
|
|
|
2007-12-02 19:11:44 +00:00
|
|
|
#define ISO_MSGS_MESSAGE_LEN 4096
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Control queueing and stderr printing of messages from a given IsoImage.
|
|
|
|
* Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT",
|
|
|
|
* "NOTE", "UPDATE", "DEBUG", "ALL".
|
|
|
|
*
|
|
|
|
* @param image The image
|
|
|
|
* @param queue_severity Gives the minimum limit for messages to be queued.
|
|
|
|
* Default: "NEVER". If you queue messages then you
|
|
|
|
* must consume them by iso_msgs_obtain().
|
|
|
|
* @param print_severity Does the same for messages to be printed directly
|
|
|
|
* to stderr.
|
|
|
|
* @param print_id A text prefix to be printed before the message.
|
|
|
|
* @return >0 for success, <=0 for error
|
|
|
|
*/
|
|
|
|
int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
|
|
|
char *print_severity, char *print_id);
|
|
|
|
/**
|
|
|
|
* Obtain the oldest pending message from a IsoImage message queue which has at
|
|
|
|
* least the given minimum_severity. This message and any older message of
|
|
|
|
* lower severity will get discarded from the queue and is then lost forever.
|
|
|
|
*
|
|
|
|
* Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT",
|
|
|
|
* "NOTE", "UPDATE", "DEBUG", "ALL". To call with minimum_severity "NEVER"
|
|
|
|
* will discard the whole queue.
|
|
|
|
*
|
|
|
|
* @param image The image whose messages we want to obtain
|
|
|
|
* @param error_code Will become a unique error code as listed in messages.h
|
|
|
|
* @param msg_text Must provide at least ISO_MSGS_MESSAGE_LEN bytes.
|
|
|
|
* @param os_errno Will become the eventual errno related to the message
|
|
|
|
* @param severity Will become the severity related to the message and
|
|
|
|
* should provide at least 80 bytes.
|
|
|
|
* @return 1 if a matching item was found, 0 if not, <0 for severe errors
|
|
|
|
*/
|
|
|
|
int iso_image_obtain_msgs(IsoImage *image, char *minimum_severity,
|
|
|
|
int *error_code, char msg_text[], int *os_errno,
|
|
|
|
char severity[]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the messenger object handle used by the given image. This handle
|
|
|
|
* may be used by related libraries to replace their own compatible
|
|
|
|
* messenger objects and thus to direct their messages to the libisofs
|
|
|
|
* message queue. See also: libburn, API function burn_set_messenger().
|
|
|
|
*
|
|
|
|
* @return the handle. Do only use with compatible
|
|
|
|
*/
|
|
|
|
void *iso_image_get_messenger(IsoImage *image);
|
|
|
|
|
2007-11-24 12:14:45 +00:00
|
|
|
#endif /*LIBISO_LIBISOFS_H_*/
|