From 6e4743c73447b5337acb1fbd592359a09527dc1c Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 6 Nov 2005 00:39:37 +0000 Subject: [PATCH] Break out POSIX-like definitions to posix.h Add ISO9660 routines to convert to mode_t Record whether XA or not in iso9660_stat_t. And other definition shifting around. --- include/cdio/Makefile.am | 3 +- include/cdio/ecma_167.h | 14 +- include/cdio/iso9660.h | 234 +++++++++++++++++----------------- include/cdio/posix.h | 44 +++++++ include/cdio/rock.h | 10 +- include/cdio/types.h | 4 +- include/cdio/udf.h | 12 +- include/cdio/udf_file.h | 14 +- include/cdio/xa.h | 9 +- lib/iso9660/iso9660.c | 23 +++- lib/iso9660/iso9660_fs.c | 8 +- lib/iso9660/iso9660_private.h | 13 +- lib/iso9660/libiso9660.sym | 3 + lib/iso9660/rock.c | 13 +- lib/iso9660/xa.c | 29 ++++- 15 files changed, 279 insertions(+), 154 deletions(-) create mode 100644 include/cdio/posix.h diff --git a/include/cdio/Makefile.am b/include/cdio/Makefile.am index 178a3f47..a0055e40 100644 --- a/include/cdio/Makefile.am +++ b/include/cdio/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.27 2005/10/30 07:35:36 rocky Exp $ +# $Id: Makefile.am,v 1.28 2005/11/06 00:39:37 rocky Exp $ # # Copyright (C) 2003, 2004 Rocky Bernstein # @@ -41,6 +41,7 @@ libcdioinclude_HEADERS = \ iso9660.h \ logging.h \ mmc.h \ + posix.h \ read.h \ rock.h \ sector.h \ diff --git a/include/cdio/ecma_167.h b/include/cdio/ecma_167.h index 85ebb420..7e4aca6b 100644 --- a/include/cdio/ecma_167.h +++ b/include/cdio/ecma_167.h @@ -211,12 +211,14 @@ extern const char VSD_STD_ID_CDW01[sizeof("CDW02")-1]; extern const char VSD_STD_ID_NSR03[sizeof("NSR03")-1]; extern const char VSD_STD_ID_TEA01[sizeof("TEA01")-1]; -#define VSD_STD_ID_BEA01 "BEA01" /**< (2/9.2) */ -#define VSD_STD_ID_BOOT2 "BOOT2" /**< (2/9.4) */ -#define VSD_STD_ID_CD001 "CD001" /**< (ECMA-119) */ -#define VSD_STD_ID_CDW02 "CDW02" /**< (ECMA-168) */ -#define VSD_STD_ID_NSR03 "NSR03" /**< (3/9.1) */ -#define VSD_STD_ID_TEA01 "TEA01" /**< (2/9.3) */ +#define VSD_STD_ID_BEA01 "BEA01" /**< ECMA-167 2/9.2 */ +#define VSD_STD_ID_BOOT2 "BOOT2" /**< ECMA-167 2/9.4 */ +#define VSD_STD_ID_CD001 "CD001" /**< ECMA-119 */ +#define VSD_STD_ID_CDW02 "CDW02" /**< ECMA-168 */ +#define VSD_STD_ID_NSR02 "NSR02" /**< ECMA-167, 3/9.1 + NOTE: ECMA-167, 2nd edition */ +#define VSD_STD_ID_NSR03 "NSR03" /**< ECMA-167 3/9.1 */ +#define VSD_STD_ID_TEA01 "TEA01" /**< ECMA-168 2/9.3 */ /** Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */ struct beginning_extended_area_desc_s diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h index 6c295049..23a0f8b3 100644 --- a/include/cdio/iso9660.h +++ b/include/cdio/iso9660.h @@ -1,5 +1,5 @@ /* - $Id: iso9660.h,v 1.77 2005/10/21 11:51:42 rocky Exp $ + $Id: iso9660.h,v 1.78 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -41,6 +41,7 @@ #include #include +#include /** \brief ISO 9660 Integer and Character types @@ -225,11 +226,6 @@ typedef struct iso9660_ltime_s iso9660_ltime_t; typedef struct iso9660_dir_s iso9660_dir_t; typedef struct iso9660_stat_s iso9660_stat_t; -typedef uint32_t posix_mode_t; -typedef uint32_t posix_nlink_t; -typedef uint32_t posix_uid_t; -typedef uint32_t posix_gid_t; - #include /*! \brief Format of an ISO-9660 directory record @@ -503,6 +499,7 @@ struct iso9660_stat_s { /* big endian!! */ uint32_t secsize; /**< number of sectors allocated */ iso9660_xa_t xa; /**< XA attributes */ enum { _STAT_FILE = 1, _STAT_DIR = 2 } type; + bool b_xa; char filename[EMPTY_ARRAY_SIZE]; /**< filename */ }; @@ -864,129 +861,132 @@ uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr); lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr); #endif -/*! - Return the directory name stored in the iso9660_dir_t - - A string is allocated: the caller must deallocate. -*/ -char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir); + /*! + Return the directory name stored in the iso9660_dir_t + + A string is allocated: the caller must deallocate. + */ + char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir); -/*! - Return a string containing the preparer id with trailing - blanks removed. -*/ -char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd); + /*! + Returns a POSIX mode for a given p_udf_dirent. + */ + posix_mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent); + + /*! + Return a string containing the preparer id with trailing + blanks removed. + */ + char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd); -/*! - Get the preparer ID. psz_preparer_id is set to NULL if there - is some problem in getting this and false is returned. -*/ -bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso, - /*out*/ char **p_psz_preparer_id); + /*! + Get the preparer ID. psz_preparer_id is set to NULL if there + is some problem in getting this and false is returned. + */ + bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso, + /*out*/ char **p_psz_preparer_id); -/*! - Return a string containing the PVD's publisher id with trailing - blanks removed. -*/ -char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd); - -/*! - Get the publisher ID. psz_publisher_id is set to NULL if there - is some problem in getting this and false is returned. -*/ -bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso, - /*out*/ char **p_psz_publisher_id); - -uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd); - -const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd); - -int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd); - -int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ; - -/*! Return the primary volume id version number (of pvd). + /*! + Return a string containing the PVD's publisher id with trailing + blanks removed. + */ + char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd); + + /*! + Get the publisher ID. psz_publisher_id is set to NULL if there + is some problem in getting this and false is returned. + */ + bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso, + /*out*/ char **p_psz_publisher_id); + + uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd); + + const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd); + + int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd); + + int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ; + + /*! Return the primary volume id version number (of pvd). If there is an error 0 is returned. - */ -int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ; - -/*! - Return a string containing the PVD's system id with trailing - blanks removed. -*/ -char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd); + */ + int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ; -/*! - Get the system ID. psz_system_id is set to NULL if there - is some problem in getting this and false is returned. -*/ -bool iso9660_ifs_get_system_id(iso9660_t *p_iso, - /*out*/ char **p_psz_system_id); - - -/*! Return the LSN of the root directory for pvd. + /*! + Return a string containing the PVD's system id with trailing + blanks removed. + */ + char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd); + + /*! + Get the system ID. psz_system_id is set to NULL if there + is some problem in getting this and false is returned. + */ + bool iso9660_ifs_get_system_id(iso9660_t *p_iso, + /*out*/ char **p_psz_system_id); + + + /*! Return the LSN of the root directory for pvd. If there is an error CDIO_INVALID_LSN is returned. - */ -lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd); - -/*! - Return the PVD's volume ID. -*/ -char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd); - -/*! - Get the system ID. psz_system_id is set to NULL if there - is some problem in getting this and false is returned. -*/ -bool iso9660_ifs_get_volume_id(iso9660_t *p_iso, - /*out*/ char **p_psz_volume_id); - -/*! - Return the PVD's volumeset ID. - NULL is returned if there is some problem in getting this. -*/ -char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd); - -/*! - Get the systemset ID. psz_systemset_id is set to NULL if there - is some problem in getting this and false is returned. -*/ -bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso, - /*out*/ char **p_psz_volumeset_id); - -/* pathtable */ - -/*! Zero's out pathable. Do this first. */ -void iso9660_pathtable_init (void *pt); - -unsigned int iso9660_pathtable_get_size (const void *pt); - -uint16_t -iso9660_pathtable_l_add_entry (void *pt, const char name[], uint32_t extent, - uint16_t parent); - -uint16_t -iso9660_pathtable_m_add_entry (void *pt, const char name[], uint32_t extent, - uint16_t parent); - + */ + lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd); + + /*! + Return the PVD's volume ID. + */ + char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd); + + /*! + Get the system ID. psz_system_id is set to NULL if there + is some problem in getting this and false is returned. + */ + bool iso9660_ifs_get_volume_id(iso9660_t *p_iso, + /*out*/ char **p_psz_volume_id); + + /*! + Return the PVD's volumeset ID. + NULL is returned if there is some problem in getting this. + */ + char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd); + + /*! + Get the systemset ID. psz_systemset_id is set to NULL if there + is some problem in getting this and false is returned. + */ + bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso, + /*out*/ char **p_psz_volumeset_id); + + /* pathtable */ + + /*! Zero's out pathable. Do this first. */ + void iso9660_pathtable_init (void *pt); + + unsigned int iso9660_pathtable_get_size (const void *pt); + + uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[], + uint32_t extent, uint16_t parent); + + uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[], + uint32_t extent, uint16_t parent); + /**===================================================================== Volume Descriptors ======================================================================*/ -void -iso9660_set_pvd (void *pd, const char volume_id[], const char application_id[], - const char publisher_id[], const char preparer_id[], - uint32_t iso_size, const void *root_dir, - uint32_t path_table_l_extent, uint32_t path_table_m_extent, - uint32_t path_table_size, const time_t *pvd_time); + void iso9660_set_pvd (void *pd, const char volume_id[], + const char application_id[], + const char publisher_id[], const char preparer_id[], + uint32_t iso_size, const void *root_dir, + uint32_t path_table_l_extent, + uint32_t path_table_m_extent, + uint32_t path_table_size, const time_t *pvd_time); -void -iso9660_set_evd (void *pd); + void iso9660_set_evd (void *pd); -/*! - Return true if ISO 9660 image has extended attrributes (XA). -*/ -bool iso9660_ifs_is_xa (const iso9660_t * p_iso); + /*! + Return true if ISO 9660 image has extended attrributes (XA). + */ + bool iso9660_ifs_is_xa (const iso9660_t * p_iso); #ifdef __cplusplus diff --git a/include/cdio/posix.h b/include/cdio/posix.h new file mode 100644 index 00000000..e4e14076 --- /dev/null +++ b/include/cdio/posix.h @@ -0,0 +1,44 @@ +/* + $Id: posix.h,v 1.1 2005/11/06 00:39:37 rocky Exp $ + + Copyright (C) 2005 Rocky Bernstein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/*! + * \file posix.h + * + * \brief various POSIX definitions. +*/ + +#ifndef __CDIO_POSIX_H__ +#define __CDIO_POSIX_H__ + +typedef uint32_t posix_mode_t; +typedef uint32_t posix_nlink_t; +typedef uint32_t posix_uid_t; +typedef uint32_t posix_gid_t; +typedef uint16_t unicode16_t; + +#endif /* __CDIO_POSIX_H__ */ + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/cdio/rock.h b/include/cdio/rock.h index 7e99d48a..8bb5ca0b 100644 --- a/include/cdio/rock.h +++ b/include/cdio/rock.h @@ -1,5 +1,5 @@ /* - $Id: rock.h,v 1.11 2005/10/04 09:59:46 rocky Exp $ + $Id: rock.h,v 1.12 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -330,7 +330,13 @@ PRAGMA_END_PACKED int get_rock_ridge_filename(iso9660_dir_t * de, /*out*/ char * retname, /*out*/ iso9660_stat_t *p_stat); -int parse_rock_ridge_stat(iso9660_dir_t *de, /*out*/ iso9660_stat_t *p_stat); + int parse_rock_ridge_stat(iso9660_dir_t *de, /*out*/ iso9660_stat_t *p_stat); + + /*! + Returns POSIX mode bitstring for a given file. + */ + posix_mode_t + iso9660_get_posix_filemode_from_rock(const iso_rock_statbuf_t *rr); /*! Returns a string which interpreting the POSIX mode st_mode. diff --git a/include/cdio/types.h b/include/cdio/types.h index 3687ef6a..4936b5d9 100644 --- a/include/cdio/types.h +++ b/include/cdio/types.h @@ -1,5 +1,5 @@ /* - $Id: types.h,v 1.32 2005/09/17 20:57:19 rocky Exp $ + $Id: types.h,v 1.33 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein @@ -55,6 +55,8 @@ extern "C" { /* fixme */ #endif /* HAVE_STDINT_H */ +typedef uint8_t ubyte; + /* default HP/UX macros are broken */ #if defined(__hpux__) # undef UINT16_C diff --git a/include/cdio/udf.h b/include/cdio/udf.h index 9750f7e2..8133bbb4 100644 --- a/include/cdio/udf.h +++ b/include/cdio/udf.h @@ -1,5 +1,5 @@ /* - $Id: udf.h,v 1.17 2005/11/01 13:07:01 rocky Exp $ + $Id: udf.h,v 1.18 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2005 Rocky Bernstein This program is free software; you can redistribute it and/or modify @@ -30,16 +30,10 @@ #include #include - -#include +#include typedef uint16_t partition_num_t; -/* FIXME: these probably don't go here. */ -typedef uint16_t unicode16_t; -typedef uint8_t ubyte; - - /** Opaque structures. */ typedef struct udf_s udf_t; typedef struct udf_file_s udf_file_t; @@ -165,7 +159,7 @@ extern "C" { otherwise. 'T' if the file is sticky but not executable. */ - char *udf_mode_string (mode_t i_mode, char *psz_str); + char *udf_mode_string (posix_mode_t i_mode, char *psz_str); #ifdef __cplusplus } diff --git a/include/cdio/udf_file.h b/include/cdio/udf_file.h index 647ec836..92814f0d 100644 --- a/include/cdio/udf_file.h +++ b/include/cdio/udf_file.h @@ -1,5 +1,5 @@ /* - $Id: udf_file.h,v 1.5 2005/11/02 03:49:15 rocky Exp $ + $Id: udf_file.h,v 1.6 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2005 Rocky Bernstein This program is free software; you can redistribute it and/or modify @@ -61,13 +61,23 @@ extern "C" { /*! Returns a POSIX mode for a given p_udf_dirent. */ - mode_t udf_get_posix_filemode(const udf_dirent_t *p_udf_dirent); + posix_mode_t udf_get_posix_filemode(const udf_dirent_t *p_udf_dirent); /*! Return the next subdirectory. */ udf_dirent_t *udf_opendir(const udf_dirent_t *p_udf_dirent); + /*! + Attempts to read up to count bytes from file descriptor fd into + the buffer starting at buf. + + If count is zero, read() returns zero and has no other results. If + count is greater than SSIZE_MAX, the result is unspecified. + */ + driver_return_code_t udf_read_block(const udf_dirent_t *p_udf_dirent, + void * buf, size_t count); + /*! Advances p_udf_direct to the the next directory entry in the pointed to by p_udf_dir. It also returns this as the value. NULL diff --git a/include/cdio/xa.h b/include/cdio/xa.h index ebb4119e..b1257050 100644 --- a/include/cdio/xa.h +++ b/include/cdio/xa.h @@ -1,5 +1,5 @@ /* - $Id: xa.h,v 1.16 2005/08/27 14:25:58 rocky Exp $ + $Id: xa.h,v 1.17 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -140,7 +140,12 @@ typedef struct iso9660_xa_s uint8_t filenum; /**< file number, see also XA subheader */ uint8_t reserved[5]; /**< zero */ } GNUC_PACKED iso9660_xa_t; - + + + /*! + Returns POSIX mode bitstring for a given file. + */ + posix_mode_t iso9660_get_posix_filemode_from_xa(uint16_t i_perms); /*! Returns a string interpreting the extended attribute xa_attr. diff --git a/lib/iso9660/iso9660.c b/lib/iso9660/iso9660.c index 7ac93a3f..a5a2f042 100644 --- a/lib/iso9660/iso9660.c +++ b/lib/iso9660/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.14 2005/09/20 00:42:14 rocky Exp $ + $Id: iso9660.c,v 1.15 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -43,12 +43,15 @@ const char ISO_STANDARD_ID[] = {'C', 'D', '0', '0', '1'}; #ifdef HAVE_STDIO_H #include #endif +#ifdef HAVE_SYS_STAT_H +#include +#endif #ifdef HAVE_ERRNO_H #include #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.14 2005/09/20 00:42:14 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.15 2005/11/06 00:39:37 rocky Exp $"; /* Variables to hold debugger-helping enumerations */ enum iso_enum1_s iso_enums1; @@ -684,6 +687,22 @@ iso9660_pathtable_init (void *pt) memset (pt, 0, ISO_BLOCKSIZE); /* fixme */ } +/*! + Returns POSIX mode bitstring for a given file. +*/ +posix_mode_t +iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent) +{ + posix_mode_t mode = 0; + + if (yep == p_iso_dirent->rr.b3_rock) { + return iso9660_get_posix_filemode_from_rock(&p_iso_dirent->rr); + } else if (p_iso_dirent->b_xa) { + return iso9660_get_posix_filemode_from_xa(p_iso_dirent->xa.attributes); + } + return mode; +} + static const iso_path_table_t * pathtable_get_entry (const void *pt, unsigned int entrynum) { diff --git a/lib/iso9660/iso9660_fs.c b/lib/iso9660/iso9660_fs.c index 4c0ea813..819ef0b1 100644 --- a/lib/iso9660/iso9660_fs.c +++ b/lib/iso9660/iso9660_fs.c @@ -1,5 +1,5 @@ /* - $Id: iso9660_fs.c,v 1.31 2005/10/12 11:25:17 rocky Exp $ + $Id: iso9660_fs.c,v 1.32 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -52,7 +52,7 @@ #include -static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.31 2005/10/12 11:25:17 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.32 2005/11/06 00:39:37 rocky Exp $"; /* Implementation of iso9660_t type */ struct _iso9660_s { @@ -812,6 +812,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa, p_stat->size = from_733 (p_iso9660_dir->size); p_stat->secsize = _cdio_len2blocks (p_stat->size, ISO_BLOCKSIZE); p_stat->rr.b3_rock = dunno; /*FIXME should do based on mask */ + p_stat->b_xa = false; { char rr_fname[256] = ""; @@ -899,7 +900,8 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa, xa_data->signature[0], xa_data->signature[1]); return p_stat; } - p_stat->xa = *xa_data; + p_stat->b_xa = true; + p_stat->xa = *xa_data; } } return p_stat; diff --git a/lib/iso9660/iso9660_private.h b/lib/iso9660/iso9660_private.h index 4ccccd76..bbb367c8 100644 --- a/lib/iso9660/iso9660_private.h +++ b/lib/iso9660/iso9660_private.h @@ -1,5 +1,5 @@ /* - $Id: iso9660_private.h,v 1.3 2005/02/12 10:23:18 rocky Exp $ + $Id: iso9660_private.h,v 1.4 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -57,13 +57,12 @@ typedef struct iso_volume_descriptor_s { * See mkisofs.h */ -/* We use this to help us look up the parent inode numbers. */ - +/** We use this to help us look up the parent inode numbers. */ typedef struct iso_path_table_s { - uint8_t name_len; /* 7.1.1 */ - uint8_t xa_len; /* 7.1.1 */ - uint32_t extent; /* 7.3.1/7.3.2 */ - uint16_t parent; /* 7.2.1/7.2.2 */ + uint8_t name_len; /**< 7.1.1 */ + uint8_t xa_len; /**< 7.1.1 */ + uint32_t extent; /**< 7.3.1/7.3.2 */ + uint16_t parent; /**< 7.2.1/7.2.2 */ char name[EMPTY_ARRAY_SIZE]; } GNUC_PACKED iso_path_table_t; diff --git a/lib/iso9660/libiso9660.sym b/lib/iso9660/libiso9660.sym index 45e13d96..b48471a3 100644 --- a/lib/iso9660/libiso9660.sym +++ b/lib/iso9660/libiso9660.sym @@ -23,6 +23,9 @@ iso9660_get_application_id iso9660_get_dir_len iso9660_get_dtime iso9660_get_ltime +iso9660_get_posix_filemode +iso9660_get_posix_filemode_from_rock +iso9660_get_posix_filemode_from_xa iso9660_get_preparer_id iso9660_get_publisher_id iso9660_get_pvd_block_size diff --git a/lib/iso9660/rock.c b/lib/iso9660/rock.c index 55b201ce..7d8309a0 100644 --- a/lib/iso9660/rock.c +++ b/lib/iso9660/rock.c @@ -1,5 +1,5 @@ /* - $Id: rock.c,v 1.14 2005/10/04 09:59:46 rocky Exp $ + $Id: rock.c,v 1.15 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2005 Rocky Bernstein Adapted from GNU/Linux fs/isofs/rock.c (C) 1992, 1993 Eric Youngdale @@ -608,3 +608,14 @@ iso9660_get_rock_attr_str(posix_mode_t st_mode) return result; } + +/*! + Returns POSIX mode bitstring for a given file. +*/ +posix_mode_t +iso9660_get_posix_filemode_from_rock(const iso_rock_statbuf_t *rr) +{ + return rr->st_mode; +} + + diff --git a/lib/iso9660/xa.c b/lib/iso9660/xa.c index 78a1ac8a..a768464f 100644 --- a/lib/iso9660/xa.c +++ b/lib/iso9660/xa.c @@ -1,5 +1,5 @@ /* - $Id: xa.c,v 1.4 2005/02/20 10:21:01 rocky Exp $ + $Id: xa.c,v 1.5 2005/11/06 00:39:37 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2005 Rocky Bernstein @@ -28,6 +28,10 @@ #include #endif +#ifdef HAVE_SYS_STAT_H +#include +#endif + /*! String inside frame which identifies XA attributes. Note should come *before* public headers which does a #define of this name. @@ -143,3 +147,26 @@ iso9660_xa_init (iso9660_xa_t *_xa, uint16_t uid, uint16_t gid, uint16_t attr, return _xa; } + +/*! + Returns POSIX mode bitstring for a given file. +*/ +posix_mode_t +iso9660_get_posix_filemode_from_xa(uint16_t i_perms) +{ + posix_mode_t mode = 0; + + if (i_perms & XA_PERM_RUSR) mode |= S_IRUSR; + if (i_perms & XA_PERM_XUSR) mode |= S_IXUSR; + + if (i_perms & XA_PERM_RGRP) mode |= S_IRGRP; + if (i_perms & XA_PERM_XGRP) mode |= S_IXGRP; + + if (i_perms & XA_PERM_ROTH) mode |= S_IROTH; + if (i_perms & XA_PERM_XOTH) mode |= S_IXOTH; + + if (i_perms & XA_ATTR_DIRECTORY) mode |= S_IFDIR; + + return mode; +} +