xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

fs_local.c File Reference
#include "fsource.h"
#include "util.h"
#include "aaip_0_2.h"
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
#include <libgen.h>
#include <string.h>
Include dependency graph for fs_local.c:

Go to the source code of this file.

Data Structures

struct  _LocalFsFileSource
 

Macros

#define O_BINARY   0
 

Functions

static int iso_file_source_new_lfs (IsoFileSource *parent, const char *name, IsoFileSource **src)
 
static char * lfs_get_path (IsoFileSource *src)
 
static char * lfs_get_name (IsoFileSource *src)
 
static int lfs_lstat (IsoFileSource *src, struct stat *info)
 
static int lfs_stat (IsoFileSource *src, struct stat *info)
 
static int lfs_access (IsoFileSource *src)
 
static int lfs_open (IsoFileSource *src)
 
static int lfs_close (IsoFileSource *src)
 
static int lfs_read (IsoFileSource *src, void *buf, size_t count)
 
static off_t lfs_lseek (IsoFileSource *src, off_t offset, int flag)
 
static int lfs_readdir (IsoFileSource *src, IsoFileSource **child)
 
static int lfs_readlink (IsoFileSource *src, char *buf, size_t bufsiz)
 
static IsoFilesystemlfs_get_filesystem (IsoFileSource *src)
 
static void lfs_free (IsoFileSource *src)
 
static int lfs_get_aa_string (IsoFileSource *src, unsigned char **aa_string, int flag)
 
static int lfs_clone_src (IsoFileSource *old_source, IsoFileSource **new_source, int flag)
 
static int lfs_get_root (IsoFilesystem *fs, IsoFileSource **root)
 
static int lfs_get_by_path (IsoFilesystem *fs, const char *path, IsoFileSource **file)
 
static unsigned int lfs_get_id (IsoFilesystem *fs)
 
static int lfs_fs_open (IsoFilesystem *fs)
 
static int lfs_fs_close (IsoFilesystem *fs)
 
static void lfs_fs_free (IsoFilesystem *fs)
 
int iso_local_filesystem_new (IsoFilesystem **fs)
 
int iso_local_attr_support (int flag)
 
int iso_local_get_acl_text (char *disk_path, char **text, int flag)
 
int iso_local_set_acl_text (char *disk_path, char *text, int flag)
 
int iso_local_get_attrs (char *disk_path, size_t *num_attrs, char ***names, size_t **value_lengths, char ***values, int flag)
 
int iso_local_set_attrs_errno (char *disk_path, size_t num_attrs, char **names, size_t *value_lengths, char **values, int *errnos, int flag)
 
int iso_local_set_attrs (char *disk_path, size_t num_attrs, char **names, size_t *value_lengths, char **values, int flag)
 
int iso_local_get_perms_wo_acl (char *disk_path, mode_t *st_mode, int flag)
 

Variables

IsoFilesystemlfs = NULL
 
IsoFileSourceIface lfs_class
 

Macro Definition Documentation

◆ O_BINARY

#define O_BINARY   0

Definition at line 35 of file fs_local.c.

Function Documentation

◆ iso_file_source_new_lfs()

◆ iso_local_attr_support()

int iso_local_attr_support ( int  flag)

libisofs has an internal system dependent adapter to ACL and xattr operations. For the sake of completeness and simplicity it exposes this functionality to its applications which might want to get and set ACLs from local files. Inquire whether local filesystem operations with ACL or xattr are enabled inside libisofs. They may be disabled because of compile time decisions. E.g. because the operating system does not support these features or because libisofs has not yet an adapter to use them.

Parameters
flagBitfield for control purposes bit0= inquire availability of ACL bit1= inquire availability of xattr bit2 - bit7= Reserved for future types. It is permissibile to set them to 1 already now. bit8 and higher: reserved, submit 0
Returns
Bitfield corresponding to flag. bit0= ACL adapter is enabled bit1= xattr adapter is enabled bit2 - bit7= Reserved for future types. bit8 and higher: reserved, do not interpret these
Since
1.1.6

Definition at line 834 of file fs_local.c.

References aaip_local_attr_support().

Referenced by Xorriso_list_extras().

◆ iso_local_filesystem_new()

◆ iso_local_get_acl_text()

int iso_local_get_acl_text ( char *  disk_path,
char **  text,
int  flag 
)

Get an ACL of the given file in the local filesystem in long text form.

Parameters
disk_pathAbsolute path to the file
textWill return a pointer to the ACL text. If not NULL the text will be 0 terminated and finally has to be disposed by a call to this function with bit15 set.
flagBitfield for control purposes bit0= get "default" ACL rather than "access" ACL bit4= set *text = NULL and return 2 if the ACL matches st_mode permissions. bit5= in case of symbolic link: inquire link target bit15= free text and return 1
Returns
1 ok 2 ok, trivial ACL found while bit4 is set, *text is NULL 0 no ACL manipulation adapter available / ACL not supported on fs -1 failure of system ACL service (see errno) -2 attempt to inquire ACL of a symbolic link without bit4 or bit5 or with no suitable link target
Since
0.6.14

Definition at line 843 of file fs_local.c.

References aaip_get_acl_text().

Referenced by iso_local_get_perms_wo_acl(), and Xorriso_local_getfacl().

◆ iso_local_get_attrs()

int iso_local_get_attrs ( char *  disk_path,
size_t *  num_attrs,
char ***  names,
size_t **  value_lengths,
char ***  values,
int  flag 
)

Get xattr and non-trivial ACLs of the given file in the local filesystem. The resulting data has finally to be disposed by a call to this function with flag bit15 set.

Eventual ACLs will get encoded as attribute pair with empty name if this is enabled by flag bit0. An ACL which simply replects stat(2) permissions will not be put into the result.

Parameters
disk_pathAbsolute path to the file
num_attrsWill return the number of name-value pairs
namesWill return an array of pointers to 0-terminated names
value_lengthsWill return an array with the lengths of values
valuesWill return an array of pointers to 8-bit values
flagBitfield for control purposes bit0= obtain eventual ACLs as attribute with empty name bit2= do not obtain attributes other than ACLs bit3= do not ignore eventual non-user attributes. I.e. those with a name which does not begin by "user." bit5= in case of symbolic link: inquire link target bit15= free memory
Returns
1 ok 2 ok, but it is possible that attributes exist in non-user namespaces which could not be explored due to lack of permission.
Since
1.5.0 < 0 failure
0.6.14

Definition at line 863 of file fs_local.c.

References aaip_get_attr_list(), and ISO_AAIP_NO_GET_LOCAL.

Referenced by Xorriso_get_attrs(), and Xorriso_transfer_properties().

◆ iso_local_get_perms_wo_acl()

int iso_local_get_perms_wo_acl ( char *  disk_path,
mode_t *  st_mode,
int  flag 
)

Obtain permissions of a file in the local filesystem which shall reflect ACL entry "group::" in S_IRWXG rather than ACL entry "mask::". This is necessary if the permissions of a disk file with ACL shall be copied to an object which has no ACL.

Parameters
disk_pathAbsolute path to the local file which may have an "access" ACL or not.
flagBitfield for control purposes bit5= in case of symbolic link: inquire link target
st_modeReturns permission bits as of stat(2)
Returns
1 success -1 failure of lstat() or stat() (see errno)
Since
0.6.14

Definition at line 922 of file fs_local.c.

References aaip_cleanout_st_mode(), and iso_local_get_acl_text().

Referenced by Xorriso_transfer_properties().

◆ iso_local_set_acl_text()

int iso_local_set_acl_text ( char *  disk_path,
char *  text,
int  flag 
)

Set the ACL of the given file in the local filesystem to a given list in long text form.

Parameters
disk_pathAbsolute path to the file
textThe input text (0 terminated, ACL long text form)
flagBitfield for control purposes bit0= set "default" ACL rather than "access" ACL bit5= in case of symbolic link: manipulate link target
Returns
> 0 ok 0 no ACL manipulation adapter available for desired ACL type -1 failure of system ACL service (see errno) -2 attempt to manipulate ACL of a symbolic link without bit5 or with no suitable link target
Since
0.6.14

Definition at line 852 of file fs_local.c.

References aaip_set_acl_text(), and ISO_AAIP_NO_SET_LOCAL.

◆ iso_local_set_attrs()

int iso_local_set_attrs ( char *  disk_path,
size_t  num_attrs,
char **  names,
size_t *  value_lengths,
char **  values,
int  flag 
)

Older version of iso_local_set_attrs_errno() without the errnos array. All other parameters and the return value have the same meaning.

Since
0.6.14

Definition at line 903 of file fs_local.c.

References iso_local_set_attrs_errno(), and ISO_OUT_OF_MEM.

◆ iso_local_set_attrs_errno()

int iso_local_set_attrs_errno ( char *  disk_path,
size_t  num_attrs,
char **  names,
size_t *  value_lengths,
char **  values,
int *  errnos,
int  flag 
)

Attach a list of xattr and ACLs to the given file in the local filesystem.

Eventual ACLs have to be encoded as attribute pair with empty name.

Parameters
disk_pathAbsolute path to the file
num_attrsNumber of attributes
namesArray of pointers to 0 terminated name strings
value_lengthsArray of byte lengths for each attribute payload
valuesArray of pointers to the attribute payload bytes
errnosArray of integers to return error numbers if encountered at the attempt to process the name-value pair at the given array index number: 0 = no error , -1 = unknown error >0 = errno as of local system calls to set xattr and ACLs
flagBitfield for control purposes bit0= do not attach ACLs from an eventual attribute with empty name bit3= do not ignore eventual non-user attributes. I.e. those with a name which does not begin by "user." bit5= in case of symbolic link: manipulate link target bit6=
Since
1.1.6 tolerate inappropriate presence or absence of directory "default" ACL bit7=
1.5.0 avoid setting a name value pair if it already exists and has the desired value.
Returns
1 = ok < 0 = error
Since
1.5.0

Definition at line 877 of file fs_local.c.

References aaip_set_attr_list(), ISO_AAIP_BAD_AASTRING, ISO_AAIP_BAD_ATTR_NAME, ISO_AAIP_NO_SET_LOCAL, ISO_AAIP_NOT_ENABLED, and ISO_OUT_OF_MEM.

Referenced by iso_local_set_attrs(), and Xorriso_restore_properties().

◆ lfs_access()

static int lfs_access ( IsoFileSource src)
static

Definition at line 187 of file fs_local.c.

References iso_eaccess(), ISO_NULL_POINTER, and lfs_get_path().

◆ lfs_clone_src()

◆ lfs_close()

◆ lfs_free()

◆ lfs_fs_close()

static int lfs_fs_close ( IsoFilesystem fs)
static

Definition at line 789 of file fs_local.c.

References ISO_SUCCESS.

Referenced by iso_local_filesystem_new().

◆ lfs_fs_free()

static void lfs_fs_free ( IsoFilesystem fs)
static

Definition at line 796 of file fs_local.c.

References lfs.

Referenced by iso_local_filesystem_new().

◆ lfs_fs_open()

static int lfs_fs_open ( IsoFilesystem fs)
static

Definition at line 782 of file fs_local.c.

References ISO_SUCCESS.

Referenced by iso_local_filesystem_new().

◆ lfs_get_aa_string()

static int lfs_get_aa_string ( IsoFileSource src,
unsigned char **  aa_string,
int  flag 
)
static

◆ lfs_get_by_path()

◆ lfs_get_filesystem()

static IsoFilesystem* lfs_get_filesystem ( IsoFileSource src)
static

Definition at line 474 of file fs_local.c.

References lfs.

◆ lfs_get_id()

static unsigned int lfs_get_id ( IsoFilesystem fs)
static

Definition at line 776 of file fs_local.c.

References ISO_LOCAL_FS_ID.

Referenced by iso_local_filesystem_new().

◆ lfs_get_name()

static char* lfs_get_name ( IsoFileSource src)
static

Definition at line 93 of file fs_local.c.

References iso_file_source::data, and _LocalFsFileSource::name.

◆ lfs_get_path()

static char* lfs_get_path ( IsoFileSource src)
static

◆ lfs_get_root()

static int lfs_get_root ( IsoFilesystem fs,
IsoFileSource **  root 
)
static

Definition at line 680 of file fs_local.c.

References iso_file_source_new_lfs(), and ISO_NULL_POINTER.

Referenced by iso_local_filesystem_new(), and lfs_get_by_path().

◆ lfs_lseek()

◆ lfs_lstat()

static int lfs_lstat ( IsoFileSource src,
struct stat *  info 
)
static

◆ lfs_open()

◆ lfs_read()

◆ lfs_readdir()

◆ lfs_readlink()

static int lfs_readlink ( IsoFileSource src,
char *  buf,
size_t  bufsiz 
)
static

◆ lfs_stat()

static int lfs_stat ( IsoFileSource src,
struct stat *  info 
)
static

Variable Documentation

◆ lfs

◆ lfs_class

IsoFileSourceIface lfs_class
Initial value:
= {
2,
}
static void lfs_free(IsoFileSource *src)
Definition: fs_local.c:480
static int lfs_lstat(IsoFileSource *src, struct stat *info)
Definition: fs_local.c:101
static int lfs_access(IsoFileSource *src)
Definition: fs_local.c:187
static int lfs_readdir(IsoFileSource *src, IsoFileSource **child)
Definition: fs_local.c:380
static IsoFilesystem * lfs_get_filesystem(IsoFileSource *src)
Definition: fs_local.c:474
static int lfs_readlink(IsoFileSource *src, char *buf, size_t bufsiz)
Definition: fs_local.c:421
static int lfs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag)
Definition: fs_local.c:500
static char * lfs_get_path(IsoFileSource *src)
Definition: fs_local.c:62
static int lfs_stat(IsoFileSource *src, struct stat *info)
Definition: fs_local.c:144
static int lfs_close(IsoFileSource *src)
Definition: fs_local.c:259
static off_t lfs_lseek(IsoFileSource *src, off_t offset, int flag)
Definition: fs_local.c:334
static int lfs_read(IsoFileSource *src, void *buf, size_t count)
Definition: fs_local.c:287
static int lfs_open(IsoFileSource *src)
Definition: fs_local.c:203
static int lfs_clone_src(IsoFileSource *old_source, IsoFileSource **new_source, int flag)
Definition: fs_local.c:557
static char * lfs_get_name(IsoFileSource *src)
Definition: fs_local.c:93

Definition at line 603 of file fs_local.c.

Referenced by iso_file_source_new_lfs().