2007-11-24 13:14:45 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Vreixo Formoso
|
2023-01-22 16:03:44 +01:00
|
|
|
* Copyright (c) 2009 - 2023 Thomas Schmitt
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
|
|
|
* This file is part of the libisofs project; you can redistribute it and/or
|
2010-01-27 06:48:59 +01:00
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* or later as published by the Free Software Foundation.
|
|
|
|
* See COPYING file for details.
|
2007-11-24 13:14:45 +01:00
|
|
|
*/
|
2007-11-24 16:58:36 +01:00
|
|
|
#ifndef LIBISO_NODE_H_
|
|
|
|
#define LIBISO_NODE_H_
|
2007-11-24 13:14:45 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Definitions for the public iso tree
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libisofs.h"
|
2007-12-02 17:59:36 +01:00
|
|
|
#include "stream.h"
|
2007-11-24 13:14:45 +01:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
2011-01-18 16:18:09 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_STDINT_H
|
2007-12-04 22:33:40 +01:00
|
|
|
#include <stdint.h>
|
2011-01-18 16:18:09 +01:00
|
|
|
#else
|
|
|
|
#ifdef HAVE_INTTYPES_H
|
|
|
|
#include <inttypes.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2007-11-24 13:14:45 +01:00
|
|
|
|
2011-03-28 15:00:44 +02:00
|
|
|
/* Maximum length of a leaf name in the libisofs node tree. This is currently
|
|
|
|
restricted by the implemented maximum length of a Rock Ridge name.
|
|
|
|
This might later become larger and may then be limited to smaller values.
|
|
|
|
|
|
|
|
Rock Ridge specs do not impose an explicit limit on name length.
|
|
|
|
But 255 is also specified by
|
|
|
|
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
|
|
|
|
which says
|
|
|
|
NAME_MAX >= _XOPEN_NAME_MAX = 255
|
|
|
|
*/
|
|
|
|
#define LIBISOFS_NODE_NAME_MAX 255
|
|
|
|
|
|
|
|
|
|
|
|
/* Maximum length of a path in the libisofs node tree.
|
2011-04-03 11:02:15 +02:00
|
|
|
Rock Ridge specs do not impose an explicit limit on path length.
|
2011-03-28 15:00:44 +02:00
|
|
|
|
|
|
|
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
|
|
|
|
says
|
|
|
|
PATH_MAX >= _XOPEN_PATH_MAX = 1024
|
|
|
|
*/
|
|
|
|
#define LIBISOFS_NODE_PATH_MAX 1024
|
|
|
|
|
|
|
|
|
2008-01-13 17:59:53 +01:00
|
|
|
/**
|
|
|
|
* The extended information is a way to attach additional information to each
|
2008-08-19 02:45:20 +02:00
|
|
|
* IsoNode. External applications may want to use this extension system to
|
2009-08-10 13:56:06 +02:00
|
|
|
* store application specific information related to each node. On the other
|
2008-01-13 17:59:53 +01:00
|
|
|
* 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.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-13 17:59:53 +01:00
|
|
|
* 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;
|
2008-08-19 02:45:20 +02:00
|
|
|
|
2008-01-13 17:59:53 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-13 17:59:53 +01:00
|
|
|
* @param data
|
|
|
|
* Attached data
|
|
|
|
* @param flag
|
2008-08-19 02:45:20 +02:00
|
|
|
* What to do with the data. At this time the following values are
|
2008-01-13 17:59:53 +01:00
|
|
|
* defined:
|
|
|
|
* -> 1 the data must be freed
|
|
|
|
* @return
|
|
|
|
* 1
|
|
|
|
*/
|
2008-03-15 17:34:58 +01:00
|
|
|
iso_node_xinfo_func process;
|
2008-08-19 02:45:20 +02:00
|
|
|
|
2008-01-13 17:59:53 +01:00
|
|
|
/**
|
|
|
|
* Pointer to information specific data.
|
|
|
|
*/
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2007-11-24 13:14:45 +01:00
|
|
|
/**
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2007-11-24 13:14:45 +01:00
|
|
|
*/
|
2007-11-24 16:58:36 +01:00
|
|
|
struct Iso_Node
|
|
|
|
{
|
2007-11-24 13:14:45 +01:00
|
|
|
/*
|
2009-08-10 13:56:06 +02:00
|
|
|
* Initialized to 1, originally owned by user, until added to another node.
|
2008-08-19 02:45:20 +02:00
|
|
|
* Then it is owned by the parent node, so the user must take his own ref
|
2007-11-24 13:14:45 +01:00
|
|
|
* if needed. With the exception of the creation functions, none of the
|
2008-08-19 02:45:20 +02:00
|
|
|
* other libisofs functions that return an IsoNode increment its
|
2007-11-24 13:14:45 +01:00
|
|
|
* refcount. This is responsablity of the client, if (s)he needs it.
|
|
|
|
*/
|
|
|
|
int refcount;
|
|
|
|
|
2007-12-28 22:10:17 +01:00
|
|
|
/** Type of the IsoNode, do not confuse with mode */
|
2007-11-24 16:58:36 +01:00
|
|
|
enum IsoNodeType type;
|
2007-11-24 13:14:45 +01:00
|
|
|
|
2007-12-28 00:20:02 +01:00
|
|
|
char *name; /**< Real name, in default charset */
|
2007-11-24 13:14:45 +01:00
|
|
|
|
|
|
|
mode_t mode; /**< protection */
|
2007-12-28 22:10:17 +01:00
|
|
|
uid_t uid; /**< user ID of owner */
|
|
|
|
gid_t gid; /**< group ID of owner */
|
2007-11-24 13:14:45 +01: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 22:10:17 +01:00
|
|
|
|
|
|
|
int hidden; /**< whether the node will be hidden, see IsoHideNodeFlag */
|
2007-11-24 13:14:45 +01:00
|
|
|
|
2007-12-01 01:42:21 +01:00
|
|
|
IsoDir *parent; /**< parent node, NULL for root */
|
2007-11-24 13:14:45 +01:00
|
|
|
|
|
|
|
/*
|
2007-12-02 18:54:55 +01:00
|
|
|
* Pointer to the linked list of children in a dir.
|
2007-11-24 13:14:45 +01:00
|
|
|
*/
|
2007-11-24 16:58:36 +01:00
|
|
|
IsoNode *next;
|
2008-01-13 17:59:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extended information for the node.
|
|
|
|
*/
|
|
|
|
IsoExtendedInfo *xinfo;
|
2007-11-24 13:14:45 +01:00
|
|
|
};
|
|
|
|
|
2007-11-24 16:58:36 +01:00
|
|
|
struct Iso_Dir
|
|
|
|
{
|
|
|
|
IsoNode node;
|
2007-11-24 13:14:45 +01:00
|
|
|
|
|
|
|
size_t nchildren; /**< The number of children of this directory. */
|
2007-12-01 01:42:21 +01:00
|
|
|
IsoNode *children; /**< list of children. ptr to first child */
|
2007-11-24 13:14:45 +01:00
|
|
|
};
|
|
|
|
|
2011-01-25 10:50:37 +01:00
|
|
|
/* IMPORTANT: Any change must be reflected by iso_tree_clone_file. */
|
2007-11-24 16:58:36 +01:00
|
|
|
struct Iso_File
|
|
|
|
{
|
|
|
|
IsoNode node;
|
2007-12-28 22:10:17 +01:00
|
|
|
|
2013-09-07 21:37:27 +02:00
|
|
|
/* 1 = The node was loaded from an existing ISO image and still refers
|
|
|
|
to its data content there.
|
|
|
|
*/
|
2008-08-19 02:45:20 +02:00
|
|
|
unsigned int from_old_session : 1;
|
2007-11-24 16:58:36 +01:00
|
|
|
|
2013-09-07 21:37:27 +02:00
|
|
|
/* 1 = The node got attributed a weight by iso_node_set_sort_weight().
|
|
|
|
*/
|
|
|
|
unsigned int explicit_weight : 1;
|
|
|
|
|
2008-08-19 02:45:20 +02:00
|
|
|
/**
|
2007-12-28 22:10:17 +01:00
|
|
|
* It sorts the order in which the file data is written to the CD image.
|
2008-08-19 02:45:20 +02:00
|
|
|
* Higher weighting files are written at the beginning of image
|
2007-12-28 22:10:17 +01:00
|
|
|
*/
|
2007-11-24 16:58:36 +01:00
|
|
|
int sort_weight;
|
2009-05-03 19:21:21 +02:00
|
|
|
IsoStream *stream; /* Knows fs_id, st_dev, and st_ino */
|
2007-11-24 16:58:36 +01:00
|
|
|
};
|
2007-11-24 13:14:45 +01:00
|
|
|
|
2007-11-27 20:41:09 +01:00
|
|
|
struct Iso_Symlink
|
|
|
|
{
|
|
|
|
IsoNode node;
|
2007-12-28 22:10:17 +01:00
|
|
|
|
2007-11-27 20:41:09 +01:00
|
|
|
char *dest;
|
2009-05-03 19:21:21 +02:00
|
|
|
|
|
|
|
/* If the IsoNode represents an object in an existing filesystem then
|
|
|
|
the following three numbers should unique identify it.
|
|
|
|
(0,0,0) will always be taken as unique.
|
|
|
|
*/
|
|
|
|
unsigned int fs_id;
|
|
|
|
dev_t st_dev;
|
|
|
|
ino_t st_ino;
|
2007-11-27 20:41:09 +01:00
|
|
|
};
|
2007-11-24 13:14:45 +01:00
|
|
|
|
2007-12-06 02:43:24 +01:00
|
|
|
struct Iso_Special
|
|
|
|
{
|
|
|
|
IsoNode node;
|
|
|
|
dev_t dev;
|
2009-05-03 19:21:21 +02:00
|
|
|
|
|
|
|
/* If the IsoNode represents an object in an existing filesystem then
|
|
|
|
the following three numbers should unique identify it.
|
|
|
|
(0,0,0) will always be taken as unique.
|
|
|
|
*/
|
|
|
|
unsigned int fs_id;
|
|
|
|
dev_t st_dev;
|
|
|
|
ino_t st_ino;
|
2007-12-06 02:43:24 +01:00
|
|
|
};
|
2007-12-01 02:22:00 +01:00
|
|
|
|
2008-03-03 21:18:54 +01:00
|
|
|
struct iso_dir_iter_iface
|
|
|
|
{
|
2008-08-19 02:45:20 +02:00
|
|
|
|
2008-03-03 21:18:54 +01:00
|
|
|
int (*next)(IsoDirIter *iter, IsoNode **node);
|
|
|
|
|
|
|
|
int (*has_next)(IsoDirIter *iter);
|
|
|
|
|
|
|
|
void (*free)(IsoDirIter *iter);
|
2008-08-19 02:45:20 +02:00
|
|
|
|
2008-03-03 21:18:54 +01:00
|
|
|
int (*take)(IsoDirIter *iter);
|
|
|
|
|
|
|
|
int (*remove)(IsoDirIter *iter);
|
2008-08-19 02:45:20 +02:00
|
|
|
|
|
|
|
/**
|
2008-03-08 00:45:19 +01:00
|
|
|
* This is called just before remove a node from a directory. The iterator
|
|
|
|
* may want to update its internal state according to this.
|
|
|
|
*/
|
|
|
|
void (*notify_child_taken)(IsoDirIter *iter, IsoNode *node);
|
2008-03-03 21:18:54 +01:00
|
|
|
};
|
|
|
|
|
2007-12-01 02:22:00 +01:00
|
|
|
/**
|
|
|
|
* An iterator for directory children.
|
|
|
|
*/
|
|
|
|
struct Iso_Dir_Iter
|
|
|
|
{
|
2008-03-03 21:18:54 +01:00
|
|
|
struct iso_dir_iter_iface *class;
|
2008-08-19 02:45:20 +02:00
|
|
|
|
2008-03-03 21:18:54 +01:00
|
|
|
/* the directory this iterator iterates over */
|
|
|
|
IsoDir *dir;
|
2008-08-19 02:45:20 +02:00
|
|
|
|
2008-03-03 21:18:54 +01:00
|
|
|
void *data;
|
2007-12-01 02:22:00 +01:00
|
|
|
};
|
|
|
|
|
2007-12-02 18:54:55 +01:00
|
|
|
int iso_node_new_root(IsoDir **root);
|
|
|
|
|
2008-01-25 22:57:29 +01:00
|
|
|
/**
|
2008-08-19 02:45:20 +02:00
|
|
|
* Create a new IsoDir. Attributes, uid/gid, timestamps, etc are set to
|
2008-01-25 22:57:29 +01:00
|
|
|
* default (0) values. You must set them.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-25 22:57:29 +01:00
|
|
|
* @param name
|
2008-08-19 02:45:20 +02:00
|
|
|
* Name for the node. It is not strdup() so you shouldn't use this
|
|
|
|
* reference when this function returns successfully. NULL is not
|
2008-01-25 22:57:29 +01:00
|
|
|
* allowed.
|
|
|
|
* @param dir
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-25 22:57:29 +01:00
|
|
|
* @return
|
|
|
|
* 1 on success, < 0 on error.
|
|
|
|
*/
|
|
|
|
int iso_node_new_dir(char *name, IsoDir **dir);
|
|
|
|
|
|
|
|
/**
|
2008-08-19 02:45:20 +02:00
|
|
|
* Create a new file node. Attributes, uid/gid, timestamps, etc are set to
|
2008-01-25 22:57:29 +01:00
|
|
|
* default (0) values. You must set them.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-25 22:57:29 +01:00
|
|
|
* @param name
|
2008-08-19 02:45:20 +02:00
|
|
|
* Name for the node. It is not strdup() so you shouldn't use this
|
|
|
|
* reference when this function returns successfully. NULL is not
|
2008-01-25 22:57:29 +01:00
|
|
|
* allowed.
|
|
|
|
* @param stream
|
|
|
|
* Source for file contents. The reference is taken by the node,
|
|
|
|
* you must call iso_stream_ref() if you need your own ref.
|
|
|
|
* @return
|
|
|
|
* 1 on success, < 0 on error.
|
|
|
|
*/
|
|
|
|
int iso_node_new_file(char *name, IsoStream *stream, IsoFile **file);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new IsoSymlink node. Attributes, uid/gid, timestamps, etc are set
|
|
|
|
* to default (0) values. You must set them.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-25 22:57:29 +01:00
|
|
|
* @param name
|
2008-08-19 02:45:20 +02:00
|
|
|
* name for the new symlink. It is not strdup() so you shouldn't use this
|
|
|
|
* reference when this function returns successfully. NULL is not
|
2008-01-25 22:57:29 +01:00
|
|
|
* allowed.
|
|
|
|
* @param dest
|
2008-08-19 02:45:20 +02:00
|
|
|
* destination of the link. It is not strdup() so you shouldn't use this
|
|
|
|
* reference when this function returns successfully. NULL is not
|
2008-01-25 22:57:29 +01:00
|
|
|
* allowed.
|
|
|
|
* @param link
|
|
|
|
* place where to store a pointer to the newly created link.
|
|
|
|
* @return
|
|
|
|
* 1 on success, < 0 otherwise
|
|
|
|
*/
|
|
|
|
int iso_node_new_symlink(char *name, char *dest, IsoSymlink **link);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new special file node. 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
|
2019-10-28 15:56:58 +01:00
|
|
|
* by setting mode properly (see man 2 stat).
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
|
|
|
* Note that special files are only written to image when Rock Ridge
|
2008-01-25 22:57:29 +01:00
|
|
|
* extensions are enabled. Moreover, a special file is just a directory entry
|
|
|
|
* in the image tree, no data is written beyond that.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
|
|
|
* Owner and hidden atts are taken from parent. You can modify any of them
|
2008-01-25 22:57:29 +01:00
|
|
|
* later.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-25 22:57:29 +01:00
|
|
|
* @param name
|
2008-08-19 02:45:20 +02:00
|
|
|
* name for the new special file. It is not strdup() so you shouldn't use
|
|
|
|
* this reference when this function returns successfully. NULL is not
|
2008-01-25 22:57:29 +01:00
|
|
|
* allowed.
|
|
|
|
* @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,
|
2008-08-19 02:45:20 +02:00
|
|
|
* S_IFSOCK, S_IFBLK, S_IFCHR and S_IFIFO are valid types; S_IFLNK,
|
2008-01-25 22:57:29 +01:00
|
|
|
* 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.
|
|
|
|
* @return
|
|
|
|
* 1 on success, < 0 otherwise
|
|
|
|
*/
|
2008-08-19 02:45:20 +02:00
|
|
|
int iso_node_new_special(char *name, mode_t mode, dev_t dev,
|
2008-01-25 22:57:29 +01:00
|
|
|
IsoSpecial **special);
|
|
|
|
|
2008-01-08 19:47:33 +01:00
|
|
|
/**
|
|
|
|
* Check if a given name is valid for an iso node.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-08 19:47:33 +01:00
|
|
|
* @return
|
2011-03-26 20:54:20 +01:00
|
|
|
* 1 if yes, <0 if not. The value is a specific ISO_* error code.
|
2008-01-08 19:47:33 +01:00
|
|
|
*/
|
|
|
|
int iso_node_is_valid_name(const char *name);
|
|
|
|
|
2008-01-08 20:05:01 +01:00
|
|
|
/**
|
|
|
|
* Check if a given path is valid for the destination of a link.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-08 20:05:01 +01:00
|
|
|
* @return
|
|
|
|
* 1 if yes, 0 if not
|
|
|
|
*/
|
|
|
|
int iso_node_is_valid_link_dest(const char *dest);
|
|
|
|
|
2008-01-12 18:03:59 +01:00
|
|
|
/**
|
|
|
|
* Find the position where to insert a node
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-12 18:03:59 +01:00
|
|
|
* @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.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-12 18:03:59 +01:00
|
|
|
* @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.
|
2008-08-19 02:45:20 +02:00
|
|
|
*
|
2008-01-12 18:03:59 +01:00
|
|
|
* @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
|
2008-08-19 02:45:20 +02:00
|
|
|
* obtained with a call to iso_dir_exists() or iso_dir_find().
|
2008-01-12 18:03:59 +01:00
|
|
|
* It can't be NULL.
|
2008-08-19 02:45:20 +02:00
|
|
|
* @param replace
|
2008-01-12 18:03:59 +01:00
|
|
|
* Whether to replace an old node with the same name with the new node.
|
|
|
|
* @return
|
2008-08-19 02:45:20 +02:00
|
|
|
* If success, number of children in dir. < 0 on error
|
2008-01-12 18:03:59 +01:00
|
|
|
*/
|
2008-08-19 02:45:20 +02:00
|
|
|
int iso_dir_insert(IsoDir *dir, IsoNode *node, IsoNode **pos,
|
2008-01-12 18:03:59 +01:00
|
|
|
enum iso_replace_mode replace);
|
|
|
|
|
2008-03-06 23:59:32 +01:00
|
|
|
/**
|
|
|
|
* Add a new iterator to the registry. The iterator register keeps track of
|
2008-08-19 02:45:20 +02:00
|
|
|
* all iterators being used, and are notified when directory structure
|
2008-03-06 23:59:32 +01:00
|
|
|
* changes.
|
|
|
|
*/
|
|
|
|
int iso_dir_iter_register(IsoDirIter *iter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister a directory iterator.
|
|
|
|
*/
|
|
|
|
void iso_dir_iter_unregister(IsoDirIter *iter);
|
|
|
|
|
2008-03-08 00:45:19 +01:00
|
|
|
void iso_notify_dir_iters(IsoNode *node, int flag);
|
2008-03-06 23:59:32 +01:00
|
|
|
|
2009-02-07 21:00:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See API function iso_node_set_permissions()
|
|
|
|
*
|
|
|
|
* @param flag bit0= do not adjust ACL
|
|
|
|
* @return >0 success , <0 error
|
|
|
|
*/
|
|
|
|
int iso_node_set_perms_internal(IsoNode *node, mode_t mode, int flag);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Like iso_node_get_acl_text() with param node replaced by aa_string and
|
|
|
|
* st_mode from where to obtain the ACLs. All other parameter specs apply.
|
|
|
|
*/
|
|
|
|
int iso_aa_get_acl_text(unsigned char *aa_string, mode_t st_mode,
|
|
|
|
char **access_text, char **default_text, int flag);
|
|
|
|
|
2009-03-20 17:48:42 +01:00
|
|
|
/**
|
|
|
|
* Backend of iso_node_get_attrs() with parameter node replaced by the
|
2009-03-31 11:40:58 +02:00
|
|
|
* AAIP string from where to get the attribute list.
|
2009-03-20 17:48:42 +01:00
|
|
|
* All other parameter specs apply.
|
|
|
|
*/
|
|
|
|
int iso_aa_get_attrs(unsigned char *aa_string, size_t *num_attrs,
|
|
|
|
char ***names, size_t **value_lengths, char ***values, int flag);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search given name. Eventually calloc() and copy value. Add trailing 0 byte
|
|
|
|
* for caller convenience.
|
|
|
|
*
|
|
|
|
* @return 1= found , 0= not found , <0 error
|
|
|
|
*/
|
|
|
|
int iso_aa_lookup_attr(unsigned char *aa_string, char *name,
|
|
|
|
size_t *value_length, char **value, int flag);
|
|
|
|
|
2023-01-22 16:03:44 +01:00
|
|
|
/**
|
|
|
|
* Delete variables of all namespaces except isofs
|
|
|
|
*
|
|
|
|
* @param flag bit0= delete ACL, too
|
|
|
|
*/
|
|
|
|
int iso_node_remove_fattr(IsoNode *node, int flag);
|
2009-03-20 17:48:42 +01:00
|
|
|
|
2009-04-13 20:51:38 +02:00
|
|
|
/**
|
|
|
|
* Function to identify and manage ZF parameters which do not stem from ZF
|
|
|
|
* fields (those are known to the FileSource) and do not stem from filters
|
|
|
|
* ("ziso" knows them globally, "osiz" knows them individually) but rather
|
|
|
|
* from an inspection of the file content header for zisofs magic number and
|
|
|
|
* plausible parameters.
|
|
|
|
* The parameters get attached in struct zisofs_zf_info as xinfo to an IsoNode.
|
|
|
|
*/
|
|
|
|
int zisofs_zf_xinfo_func(void *data, int flag);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parameter structure which is to be managed by zisofs_zf_xinfo_func.
|
|
|
|
*/
|
|
|
|
struct zisofs_zf_info {
|
2020-10-14 20:19:11 +02:00
|
|
|
uint64_t uncompressed_size;
|
2009-04-13 20:51:38 +02:00
|
|
|
uint8_t header_size_div4;
|
|
|
|
uint8_t block_size_log2;
|
2020-10-14 20:19:11 +02:00
|
|
|
uint8_t zisofs_algo[2];
|
2009-04-13 20:51:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether a file effectively bears a zisofs file header and eventually
|
|
|
|
* marks this by a struct zisofs_zf_info as xinfo of the file node.
|
|
|
|
* @param flag bit0= inquire the most original stream of the file
|
|
|
|
* bit1= permission to overwrite existing zisofs_zf_info
|
|
|
|
* bit2= if no zisofs header is found:
|
|
|
|
create xinfo with parameters which indicate no zisofs
|
|
|
|
* @return 1= zf xinfo added, 0= no zisofs data found ,
|
|
|
|
* 2= found existing zf xinfo and flag bit1 was not set
|
|
|
|
* <0 means error
|
|
|
|
*/
|
|
|
|
int iso_file_zf_by_magic(IsoFile *file, int flag);
|
|
|
|
|
2009-04-28 22:40:15 +02:00
|
|
|
/*
|
|
|
|
* @param flag
|
|
|
|
* bit0= do only retrieve id if node is in imported ISO image
|
|
|
|
* or has an explicit xinfo inode number
|
|
|
|
* @return
|
|
|
|
* 1= reply is valid from stream, 2= reply is valid from xinfo
|
|
|
|
* 0= no id available, <0= error
|
2009-05-03 17:08:29 +02:00
|
|
|
* (fs_id, dev_id, ino_id) will be (0,0,0) in case of return <= 0
|
2009-04-28 22:40:15 +02:00
|
|
|
*/
|
|
|
|
int iso_node_get_id(IsoNode *node, unsigned int *fs_id, dev_t *dev_id,
|
|
|
|
ino_t *ino_id, int flag);
|
|
|
|
|
|
|
|
/* Set a new unique inode ISO image number to the given node.
|
|
|
|
* This number shall eventually persist during image generation.
|
|
|
|
*/
|
|
|
|
int iso_node_set_unique_id(IsoNode *node, IsoImage *image, int flag);
|
|
|
|
|
|
|
|
/* Use this with extreme care. Duplicate inode numbers will indicate hardlink
|
|
|
|
* relationship between the nodes.
|
|
|
|
*/
|
|
|
|
int iso_node_set_ino(IsoNode *node, ino_t ino, int flag);
|
|
|
|
|
2009-05-09 20:45:14 +02:00
|
|
|
/*
|
|
|
|
* @param flag
|
|
|
|
* bit0= compare stat properties and attributes
|
|
|
|
* bit1= treat all nodes with image ino == 0 as unique
|
|
|
|
* (those with 0,0,0 are treated as unique anyway)
|
|
|
|
*/
|
|
|
|
int iso_node_cmp_flag(IsoNode *n1, IsoNode *n2, int flag);
|
|
|
|
|
2009-08-10 13:56:06 +02:00
|
|
|
|
|
|
|
/**
|
2016-07-22 16:03:51 +02:00
|
|
|
* Set the checksum index (typically coming from IsoFileSrc.checksum_index)
|
2009-08-10 13:56:06 +02:00
|
|
|
* of a regular file node. The index is encoded as xattr "isofs.cx" with
|
|
|
|
* four bytes of value.
|
|
|
|
*/
|
|
|
|
int iso_file_set_isofscx(IsoFile *file, unsigned int checksum_index,
|
|
|
|
int flag);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the checksum area description. node should be the root node.
|
|
|
|
* It is encoded as xattr "isofs.ca".
|
|
|
|
*/
|
|
|
|
int iso_root_set_isofsca(IsoNode *node, uint32_t start_lba, uint32_t end_lba,
|
|
|
|
uint32_t count, uint32_t size, char *typetext,
|
|
|
|
int flag);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the checksum area description. node should be the root node.
|
|
|
|
* It is encoded as xattr "isofs.ca".
|
|
|
|
*/
|
|
|
|
int iso_root_get_isofsca(IsoNode *node, uint32_t *start_lba, uint32_t *end_lba,
|
|
|
|
uint32_t *count, uint32_t *size, char typetext[81],
|
|
|
|
int flag);
|
|
|
|
|
|
|
|
|
2015-09-25 19:07:53 +02:00
|
|
|
/**
|
2015-09-27 18:03:18 +02:00
|
|
|
* Record and get truncation parameters as of iso_image_set_truncate_mode() by
|
|
|
|
* "isofs.nt".
|
2015-09-25 19:07:53 +02:00
|
|
|
*/
|
|
|
|
int iso_root_set_isofsnt(IsoNode *node, uint32_t truncate_mode,
|
|
|
|
uint32_t truncate_length, int flag);
|
2015-09-27 18:03:18 +02:00
|
|
|
int iso_root_get_isofsnt(IsoNode *node, uint32_t *truncate_mode,
|
|
|
|
uint32_t *truncate_length, int flag);
|
2015-09-25 19:07:53 +02:00
|
|
|
|
|
|
|
|
2011-02-01 19:16:45 +01:00
|
|
|
/**
|
|
|
|
* Copy the xinfo list from one node to the another.
|
|
|
|
*/
|
|
|
|
int iso_node_clone_xinfo(IsoNode *from_node, IsoNode *to_node, int flag);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The iso_node_xinfo_func instance which governs the storing of the inode
|
|
|
|
* number from Rock Ridge field PX.
|
|
|
|
*/
|
|
|
|
int iso_px_ino_xinfo_func(void *data, int flag);
|
|
|
|
|
|
|
|
/* The iso_node_xinfo_cloner function which gets associated to
|
|
|
|
* iso_px_ino_xinfo_func by iso_init() resp. iso_init_with_flag() via
|
|
|
|
* iso_node_xinfo_make_clonable()
|
|
|
|
*/
|
|
|
|
int iso_px_ino_xinfo_cloner(void *old_data, void **new_data, int flag);
|
|
|
|
|
|
|
|
|
|
|
|
/* Function to identify and manage ZF parameters of zisofs compression.
|
|
|
|
* data is supposed to be a pointer to struct zisofs_zf_info
|
|
|
|
*/
|
|
|
|
int zisofs_zf_xinfo_func(void *data, int flag);
|
|
|
|
|
|
|
|
/* The iso_node_xinfo_cloner function which gets associated to
|
|
|
|
* zisofs_zf_xinfo_func by iso_init() resp. iso_init_with_flag() via
|
|
|
|
* iso_node_xinfo_make_clonable()
|
|
|
|
*/
|
|
|
|
int zisofs_zf_xinfo_cloner(void *old_data, void **new_data, int flag);
|
|
|
|
|
|
|
|
|
Rectified handling of oversized filenames by new API calls:
iso_image_set_truncate_mode, iso_image_get_truncate_mode,
iso_truncate_leaf_name, iso_image_set_node_name, iso_image_tree_clone,
iso_image_add_new_dir, iso_image_add_new_file, iso_image_add_new_special,
iso_image_add_new_symlink, iso_image_dir_get_node, iso_image_path_to_node,
2015-09-17 13:59:05 +02:00
|
|
|
/* Performing search for possibly truncated node name.
|
|
|
|
*/
|
|
|
|
int iso_dir_get_node_trunc(IsoDir *dir, int truncate_length,
|
|
|
|
const char *name, IsoNode **node);
|
|
|
|
|
|
|
|
|
2007-11-24 16:58:36 +01:00
|
|
|
#endif /*LIBISO_NODE_H_*/
|