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.
|
|
|
|
*/
|
2007-11-24 15:58:36 +00:00
|
|
|
#ifndef LIBISO_NODE_H_
|
|
|
|
#define LIBISO_NODE_H_
|
2007-11-24 12:14:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions for the public iso tree
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libisofs.h"
|
2007-12-02 16:59:36 +00:00
|
|
|
#include "stream.h"
|
2007-11-24 12:14:45 +00:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
2007-12-04 21:33:40 +00:00
|
|
|
#include <stdint.h>
|
2007-11-24 12:14:45 +00:00
|
|
|
|
2008-01-13 16:59:53 +00:00
|
|
|
/* #define LIBISO_EXTENDED_INFORMATION */
|
|
|
|
#ifdef LIBISO_EXTENDED_INFORMATION
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The extended information is a way to attach additional information to each
|
|
|
|
* IsoNode. External applications may want to use this extension system to
|
|
|
|
* store application speficic information related to each node. On the other
|
|
|
|
* side, libisofs may make use of this struct to attach information to nodes in
|
|
|
|
* some particular, uncommon, cases, without incrementing the size of the
|
|
|
|
* IsoNode struct.
|
|
|
|
*
|
|
|
|
* It is implemented like a chained list.
|
|
|
|
*/
|
|
|
|
typedef struct iso_extended_info IsoExtendedInfo;
|
|
|
|
|
|
|
|
struct iso_extended_info {
|
|
|
|
/**
|
|
|
|
* Next struct in the chain. NULL if it is the last item
|
|
|
|
*/
|
|
|
|
IsoExtendedInfo *next;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to handle this particular extended information. The function
|
|
|
|
* pointer acts as an identifier for the type of the information. Structs
|
|
|
|
* with same information type must use the same function.
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Attached data
|
|
|
|
* @param flag
|
|
|
|
* What to do with the data. At this time the following values are
|
|
|
|
* defined:
|
|
|
|
* -> 1 the data must be freed
|
|
|
|
* @return
|
|
|
|
* 1
|
|
|
|
*/
|
|
|
|
int (*process)(void *data, int flag);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pointer to information specific data.
|
|
|
|
*/
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-11-24 12:14:45 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2007-11-24 15:58:36 +00:00
|
|
|
struct Iso_Node
|
|
|
|
{
|
2007-11-24 12:14:45 +00:00
|
|
|
/*
|
|
|
|
* Initilized to 1, originally owned by user, until added to another node.
|
|
|
|
* Then it is owned by the parent node, so the user must take his own ref
|
|
|
|
* if needed. With the exception of the creation functions, none of the
|
2007-11-24 15:58:36 +00:00
|
|
|
* other libisofs functions that return an IsoNode increment its
|
2007-11-24 12:14:45 +00:00
|
|
|
* refcount. This is responsablity of the client, if (s)he needs it.
|
|
|
|
*/
|
|
|
|
int refcount;
|
|
|
|
|
2007-12-28 21:10:17 +00:00
|
|
|
/** Type of the IsoNode, do not confuse with mode */
|
2007-11-24 15:58:36 +00:00
|
|
|
enum IsoNodeType type;
|
2007-11-24 12:14:45 +00:00
|
|
|
|
2007-12-27 23:20:02 +00:00
|
|
|
char *name; /**< Real name, in default charset */
|
2007-11-24 12:14:45 +00:00
|
|
|
|
|
|
|
mode_t mode; /**< protection */
|
2007-12-28 21:10:17 +00:00
|
|
|
uid_t uid; /**< user ID of owner */
|
|
|
|
gid_t gid; /**< group ID of owner */
|
2007-11-24 12:14:45 +00:00
|
|
|
|
|
|
|
/* TODO #00001 : consider adding new timestamps */
|
|
|
|
time_t atime; /**< time of last access */
|
|
|
|
time_t mtime; /**< time of last modification */
|
|
|
|
time_t ctime; /**< time of last status change */
|
2007-12-28 21:10:17 +00:00
|
|
|
|
|
|
|
int hidden; /**< whether the node will be hidden, see IsoHideNodeFlag */
|
2007-11-24 12:14:45 +00:00
|
|
|
|
2007-12-01 00:42:21 +00:00
|
|
|
IsoDir *parent; /**< parent node, NULL for root */
|
2007-11-24 12:14:45 +00:00
|
|
|
|
|
|
|
/*
|
2007-12-02 17:54:55 +00:00
|
|
|
* Pointer to the linked list of children in a dir.
|
2007-11-24 12:14:45 +00:00
|
|
|
*/
|
2007-11-24 15:58:36 +00:00
|
|
|
IsoNode *next;
|
2008-01-13 16:59:53 +00:00
|
|
|
|
|
|
|
#ifdef LIBISO_EXTENDED_INFORMATION
|
|
|
|
/**
|
|
|
|
* Extended information for the node.
|
|
|
|
*/
|
|
|
|
IsoExtendedInfo *xinfo;
|
|
|
|
#endif
|
2007-11-24 12:14:45 +00:00
|
|
|
};
|
|
|
|
|
2007-11-24 15:58:36 +00:00
|
|
|
struct Iso_Dir
|
|
|
|
{
|
|
|
|
IsoNode node;
|
2007-11-24 12:14:45 +00:00
|
|
|
|
|
|
|
size_t nchildren; /**< The number of children of this directory. */
|
2007-12-01 00:42:21 +00:00
|
|
|
IsoNode *children; /**< list of children. ptr to first child */
|
2007-11-24 12:14:45 +00:00
|
|
|
};
|
|
|
|
|
2007-11-24 15:58:36 +00:00
|
|
|
struct Iso_File
|
|
|
|
{
|
|
|
|
IsoNode node;
|
2007-12-28 21:10:17 +00:00
|
|
|
|
2007-12-04 21:33:40 +00:00
|
|
|
/**
|
|
|
|
* Location of a file extent in a ms disc, 0 for newly added file
|
|
|
|
*/
|
|
|
|
uint32_t msblock;
|
2007-11-24 15:58:36 +00:00
|
|
|
|
2007-12-28 21:10:17 +00:00
|
|
|
/**
|
|
|
|
* It sorts the order in which the file data is written to the CD image.
|
|
|
|
* Higher weighting files are written at the beginning of image
|
|
|
|
*/
|
2007-11-24 15:58:36 +00:00
|
|
|
int sort_weight;
|
2007-12-02 16:59:36 +00:00
|
|
|
IsoStream *stream;
|
2007-11-24 15:58:36 +00:00
|
|
|
};
|
2007-11-24 12:14:45 +00:00
|
|
|
|
2007-11-27 19:41:09 +00:00
|
|
|
struct Iso_Symlink
|
|
|
|
{
|
|
|
|
IsoNode node;
|
2007-12-28 21:10:17 +00:00
|
|
|
|
2007-11-27 19:41:09 +00:00
|
|
|
char *dest;
|
|
|
|
};
|
2007-11-24 12:14:45 +00:00
|
|
|
|
2007-12-06 01:43:24 +00:00
|
|
|
struct Iso_Special
|
|
|
|
{
|
|
|
|
IsoNode node;
|
|
|
|
dev_t dev;
|
|
|
|
};
|
2007-12-01 01:22:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An iterator for directory children.
|
|
|
|
*/
|
|
|
|
struct Iso_Dir_Iter
|
|
|
|
{
|
|
|
|
const IsoDir *dir;
|
|
|
|
IsoNode *pos;
|
|
|
|
};
|
|
|
|
|
2007-12-02 17:54:55 +00:00
|
|
|
int iso_node_new_root(IsoDir **root);
|
|
|
|
|
2008-01-08 18:47:33 +00:00
|
|
|
/**
|
|
|
|
* Check if a given name is valid for an iso node.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 if yes, 0 if not
|
|
|
|
*/
|
|
|
|
int iso_node_is_valid_name(const char *name);
|
|
|
|
|
2008-01-08 19:05:01 +00:00
|
|
|
/**
|
|
|
|
* Check if a given path is valid for the destination of a link.
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* 1 if yes, 0 if not
|
|
|
|
*/
|
|
|
|
int iso_node_is_valid_link_dest(const char *dest);
|
|
|
|
|
2008-01-12 17:03:59 +00:00
|
|
|
/**
|
|
|
|
* Find the position where to insert a node
|
|
|
|
*
|
|
|
|
* @param dir
|
|
|
|
* A valid dir. It can't be NULL
|
|
|
|
* @param name
|
|
|
|
* The node name to search for. It can't be NULL
|
|
|
|
* @param pos
|
|
|
|
* Will be filled with the position where to insert. It can't be NULL
|
|
|
|
*/
|
|
|
|
void iso_dir_find(IsoDir *dir, const char *name, IsoNode ***pos);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a node with the given name exists in a dir.
|
|
|
|
*
|
|
|
|
* @param dir
|
|
|
|
* A valid dir. It can't be NULL
|
|
|
|
* @param name
|
|
|
|
* The node name to search for. It can't be NULL
|
|
|
|
* @param pos
|
|
|
|
* If not NULL, will be filled with the position where to insert. If the
|
|
|
|
* node exists, (**pos) will refer to the given node.
|
|
|
|
* @return
|
|
|
|
* 1 if node exists, 0 if not
|
|
|
|
*/
|
|
|
|
int iso_dir_exists(IsoDir *dir, const char *name, IsoNode ***pos);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inserts a given node in a dir, at the specified position.
|
|
|
|
*
|
|
|
|
* @param dir
|
|
|
|
* Dir where to insert. It can't be NULL
|
|
|
|
* @param node
|
|
|
|
* The node to insert. It can't be NULL
|
|
|
|
* @param pos
|
|
|
|
* Position where the node will be inserted. It is a pointer previously
|
|
|
|
* obtained with a call to iso_dir_exists() or iso_dir_find().
|
|
|
|
* It can't be NULL.
|
|
|
|
* @param replace
|
|
|
|
* Whether to replace an old node with the same name with the new node.
|
|
|
|
* @return
|
|
|
|
* If success, number of children in dir. < 0 on error
|
|
|
|
*/
|
|
|
|
int iso_dir_insert(IsoDir *dir, IsoNode *node, IsoNode **pos,
|
|
|
|
enum iso_replace_mode replace);
|
|
|
|
|
2007-11-24 15:58:36 +00:00
|
|
|
#endif /*LIBISO_NODE_H_*/
|