2003-08-31 08:32:40 +00:00
|
|
|
|
/*
|
Patch from Peter Hartley to allow Cross-compiling to mingw32:
- MinGW doesn't have struct timespec, so udf_time.c doesn't compile
(changes lib/udf/udf_time.c, configure.ac, config.h.in)
- The configure test for bitfield ordering uses AC_TRY_RUN and thus
doesn't work when cross-compiling; use sneakiness to try and
determine it at compile time, falling back to the existing runtime
check if the sneakiness doesn't work
(changes configure.ac; tested on x86_64-linux-gnu and i586-mingw32
which are bf_lsbf=1, plus sparc64-linux-gnu which is bf_lsbf=0)
- The configure test for "extern long timezone" needlessly uses
AC_TRY_RUN when in fact AC_LINK_IFELSE is all we need to know, and
that latter works when cross-compiling
(changes configure.ac)
- MinGW sys/stat.h doesn't have the *GRP or *OTH macros, nor S_IFLNK
or S_IFSOCK, nor S_ISUID etc
(changes lib/udf/udf.c and lib/iso9660/xa.c)
- MinGW doesn't have <sys/wait.h>, so even the header-inclusion bit
of the Linux driver doesn't compile unless it's moved inside the
"ifdef HAVE_LINUX_CDROM"
(changes lib/driver/gnu_linux.c)
- Because the man pages cd-info.1 etc depend on the binaries themselves
(for help2man reasons), the configure options --without-cd-info etc
don't actually stop them being compiled. Fixed by only depending on
man pages for programs that are actually built, which also stops
the installation of man pages of programs which aren't themselves
installed
(changes src/Makefile.am)
2008-04-24 07:28:00 +00:00
|
|
|
|
$Id: xa.c,v 1.8 2008/04/24 07:28:00 rocky Exp $
|
2003-08-31 08:32:40 +00:00
|
|
|
|
|
2008-04-18 16:02:09 +00:00
|
|
|
|
Copyright (C) 2003, 2005, 2008 Rocky Bernstein <rocky@panix.com>
|
|
|
|
|
|
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
2003-08-31 08:32:40 +00:00
|
|
|
|
|
2008-04-18 16:02:09 +00:00
|
|
|
|
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 3 of the License, or
|
|
|
|
|
|
(at your option) any later version.
|
2003-08-31 08:32:40 +00:00
|
|
|
|
|
2008-04-18 16:02:09 +00:00
|
|
|
|
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.
|
2003-08-31 08:32:40 +00:00
|
|
|
|
|
2008-04-18 16:02:09 +00:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-08-31 08:32:40 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
|
# include "config.h"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2003-08-31 09:11:25 +00:00
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2005-11-06 00:39:37 +00:00
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2005-02-12 18:24:21 +00:00
|
|
|
|
/*! String inside frame which identifies XA attributes. Note should
|
|
|
|
|
|
come *before* public headers which does a #define of
|
|
|
|
|
|
this name.
|
|
|
|
|
|
*/
|
|
|
|
|
|
const char ISO_XA_MARKER_STRING[] = {'C', 'D', '-', 'X', 'A', '0', '0', '1'};
|
|
|
|
|
|
|
2003-08-31 08:32:40 +00:00
|
|
|
|
/* Public headers */
|
|
|
|
|
|
#include <cdio/iso9660.h>
|
|
|
|
|
|
#include <cdio/util.h>
|
2004-10-22 01:13:38 +00:00
|
|
|
|
#include <cdio/bytesex.h>
|
2003-08-31 08:32:40 +00:00
|
|
|
|
|
|
|
|
|
|
/* Private headers */
|
|
|
|
|
|
#include "cdio_assert.h"
|
|
|
|
|
|
|
2006-01-14 09:48:42 +00:00
|
|
|
|
/** The below variable is trickery to force enum symbol values to be
|
|
|
|
|
|
recorded in debug symbol tables. It is used to allow one to refer
|
|
|
|
|
|
to the enumeration value names in the typedefs above in a debugger
|
|
|
|
|
|
and debugger expressions.
|
|
|
|
|
|
*/
|
|
|
|
|
|
xa_misc_enum_t debugger_xa_misc_enum;
|
2005-02-05 17:29:01 +00:00
|
|
|
|
|
2005-02-20 10:21:01 +00:00
|
|
|
|
#define BUF_COUNT 16
|
|
|
|
|
|
#define BUF_SIZE 80
|
|
|
|
|
|
|
2003-08-31 09:11:25 +00:00
|
|
|
|
/* Return a pointer to a internal free buffer */
|
|
|
|
|
|
static char *
|
|
|
|
|
|
_getbuf (void)
|
|
|
|
|
|
{
|
|
|
|
|
|
static char _buf[BUF_COUNT][BUF_SIZE];
|
|
|
|
|
|
static int _num = -1;
|
|
|
|
|
|
|
|
|
|
|
|
_num++;
|
|
|
|
|
|
_num %= BUF_COUNT;
|
|
|
|
|
|
|
|
|
|
|
|
memset (_buf[_num], 0, BUF_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
return _buf[_num];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
Returns a string which interpreting the extended attribute xa_attr.
|
|
|
|
|
|
For example:
|
|
|
|
|
|
\verbatim
|
|
|
|
|
|
d---1xrxrxr
|
|
|
|
|
|
---2--r-r-r
|
|
|
|
|
|
-a--1xrxrxr
|
|
|
|
|
|
\endverbatim
|
|
|
|
|
|
|
|
|
|
|
|
A description of the characters in the string follows
|
|
|
|
|
|
The 1st character is either "d" if the entry is a directory, or "-" if not.
|
|
|
|
|
|
The 2nd character is either "a" if the entry is CDDA (audio), or "-" if not.
|
|
|
|
|
|
The 3rd character is either "i" if the entry is interleaved, or "-" if not.
|
|
|
|
|
|
The 4th character is either "2" if the entry is mode2 form2 or "-" if not.
|
|
|
|
|
|
The 5th character is either "1" if the entry is mode2 form1 or "-" if not.
|
|
|
|
|
|
Note that an entry will either be in mode2 form1 or mode form2. That
|
|
|
|
|
|
is you will either see "2-" or "-1" in the 4th & 5th positions.
|
|
|
|
|
|
|
2003-09-21 01:14:30 +00:00
|
|
|
|
The 6th and 7th characters refer to permissions for a user while the
|
2003-08-31 09:11:25 +00:00
|
|
|
|
the 8th and 9th characters refer to permissions for a group while, and
|
2003-09-21 01:14:30 +00:00
|
|
|
|
the 10th and 11th characters refer to permissions for a others.
|
2003-08-31 09:11:25 +00:00
|
|
|
|
|
|
|
|
|
|
In each of these pairs the first character (6, 8, 10) is "x" if the
|
|
|
|
|
|
entry is executable. For a directory this means the directory is
|
|
|
|
|
|
allowed to be listed or "searched".
|
|
|
|
|
|
The second character of a pair (7, 9, 11) is "r" if the entry is allowed
|
|
|
|
|
|
to be read.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
|
iso9660_get_xa_attr_str (uint16_t xa_attr)
|
|
|
|
|
|
{
|
|
|
|
|
|
char *result = _getbuf();
|
|
|
|
|
|
|
|
|
|
|
|
xa_attr = uint16_from_be (xa_attr);
|
|
|
|
|
|
|
2003-09-21 01:14:30 +00:00
|
|
|
|
result[ 0] = (xa_attr & XA_ATTR_DIRECTORY) ? 'd' : '-';
|
|
|
|
|
|
result[ 1] = (xa_attr & XA_ATTR_CDDA) ? 'a' : '-';
|
|
|
|
|
|
result[ 2] = (xa_attr & XA_ATTR_INTERLEAVED) ? 'i' : '-';
|
|
|
|
|
|
result[ 3] = (xa_attr & XA_ATTR_MODE2FORM2) ? '2' : '-';
|
|
|
|
|
|
result[ 4] = (xa_attr & XA_ATTR_MODE2FORM1) ? '1' : '-';
|
2003-08-31 09:11:25 +00:00
|
|
|
|
|
2003-09-21 01:14:30 +00:00
|
|
|
|
result[ 5] = (xa_attr & XA_PERM_XUSR) ? 'x' : '-';
|
|
|
|
|
|
result[ 6] = (xa_attr & XA_PERM_RUSR) ? 'r' : '-';
|
2003-08-31 09:11:25 +00:00
|
|
|
|
|
2003-09-21 01:14:30 +00:00
|
|
|
|
result[ 7] = (xa_attr & XA_PERM_XGRP) ? 'x' : '-';
|
|
|
|
|
|
result[ 8] = (xa_attr & XA_PERM_RGRP) ? 'r' : '-';
|
2003-08-31 09:11:25 +00:00
|
|
|
|
|
2003-09-21 01:14:30 +00:00
|
|
|
|
/* Hack alert: wonder if this should be ROTH and XOTH? */
|
|
|
|
|
|
result[ 9] = (xa_attr & XA_PERM_XSYS) ? 'x' : '-';
|
|
|
|
|
|
result[10] = (xa_attr & XA_PERM_RSYS) ? 'r' : '-';
|
2003-08-31 09:11:25 +00:00
|
|
|
|
|
|
|
|
|
|
result[11] = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-08-31 08:32:40 +00:00
|
|
|
|
iso9660_xa_t *
|
|
|
|
|
|
iso9660_xa_init (iso9660_xa_t *_xa, uint16_t uid, uint16_t gid, uint16_t attr,
|
|
|
|
|
|
uint8_t filenum)
|
|
|
|
|
|
{
|
|
|
|
|
|
cdio_assert (_xa != NULL);
|
|
|
|
|
|
|
|
|
|
|
|
_xa->user_id = uint16_to_be (uid);
|
|
|
|
|
|
_xa->group_id = uint16_to_be (gid);
|
|
|
|
|
|
_xa->attributes = uint16_to_be (attr);
|
|
|
|
|
|
|
|
|
|
|
|
_xa->signature[0] = 'X';
|
|
|
|
|
|
_xa->signature[1] = 'A';
|
|
|
|
|
|
|
|
|
|
|
|
_xa->filenum = filenum;
|
|
|
|
|
|
|
|
|
|
|
|
_xa->reserved[0]
|
|
|
|
|
|
= _xa->reserved[1]
|
|
|
|
|
|
= _xa->reserved[2]
|
|
|
|
|
|
= _xa->reserved[3]
|
|
|
|
|
|
= _xa->reserved[4] = 0x00;
|
|
|
|
|
|
|
|
|
|
|
|
return _xa;
|
|
|
|
|
|
}
|
2005-11-06 00:39:37 +00:00
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
Patch from Peter Hartley to allow Cross-compiling to mingw32:
- MinGW doesn't have struct timespec, so udf_time.c doesn't compile
(changes lib/udf/udf_time.c, configure.ac, config.h.in)
- The configure test for bitfield ordering uses AC_TRY_RUN and thus
doesn't work when cross-compiling; use sneakiness to try and
determine it at compile time, falling back to the existing runtime
check if the sneakiness doesn't work
(changes configure.ac; tested on x86_64-linux-gnu and i586-mingw32
which are bf_lsbf=1, plus sparc64-linux-gnu which is bf_lsbf=0)
- The configure test for "extern long timezone" needlessly uses
AC_TRY_RUN when in fact AC_LINK_IFELSE is all we need to know, and
that latter works when cross-compiling
(changes configure.ac)
- MinGW sys/stat.h doesn't have the *GRP or *OTH macros, nor S_IFLNK
or S_IFSOCK, nor S_ISUID etc
(changes lib/udf/udf.c and lib/iso9660/xa.c)
- MinGW doesn't have <sys/wait.h>, so even the header-inclusion bit
of the Linux driver doesn't compile unless it's moved inside the
"ifdef HAVE_LINUX_CDROM"
(changes lib/driver/gnu_linux.c)
- Because the man pages cd-info.1 etc depend on the binaries themselves
(for help2man reasons), the configure options --without-cd-info etc
don't actually stop them being compiled. Fixed by only depending on
man pages for programs that are actually built, which also stops
the installation of man pages of programs which aren't themselves
installed
(changes src/Makefile.am)
2008-04-24 07:28:00 +00:00
|
|
|
|
#ifdef S_IRGRP
|
2005-11-06 00:39:37 +00:00
|
|
|
|
if (i_perms & XA_PERM_RGRP) mode |= S_IRGRP;
|
Patch from Peter Hartley to allow Cross-compiling to mingw32:
- MinGW doesn't have struct timespec, so udf_time.c doesn't compile
(changes lib/udf/udf_time.c, configure.ac, config.h.in)
- The configure test for bitfield ordering uses AC_TRY_RUN and thus
doesn't work when cross-compiling; use sneakiness to try and
determine it at compile time, falling back to the existing runtime
check if the sneakiness doesn't work
(changes configure.ac; tested on x86_64-linux-gnu and i586-mingw32
which are bf_lsbf=1, plus sparc64-linux-gnu which is bf_lsbf=0)
- The configure test for "extern long timezone" needlessly uses
AC_TRY_RUN when in fact AC_LINK_IFELSE is all we need to know, and
that latter works when cross-compiling
(changes configure.ac)
- MinGW sys/stat.h doesn't have the *GRP or *OTH macros, nor S_IFLNK
or S_IFSOCK, nor S_ISUID etc
(changes lib/udf/udf.c and lib/iso9660/xa.c)
- MinGW doesn't have <sys/wait.h>, so even the header-inclusion bit
of the Linux driver doesn't compile unless it's moved inside the
"ifdef HAVE_LINUX_CDROM"
(changes lib/driver/gnu_linux.c)
- Because the man pages cd-info.1 etc depend on the binaries themselves
(for help2man reasons), the configure options --without-cd-info etc
don't actually stop them being compiled. Fixed by only depending on
man pages for programs that are actually built, which also stops
the installation of man pages of programs which aren't themselves
installed
(changes src/Makefile.am)
2008-04-24 07:28:00 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef S_IXGRP
|
2005-11-06 00:39:37 +00:00
|
|
|
|
if (i_perms & XA_PERM_XGRP) mode |= S_IXGRP;
|
Patch from Peter Hartley to allow Cross-compiling to mingw32:
- MinGW doesn't have struct timespec, so udf_time.c doesn't compile
(changes lib/udf/udf_time.c, configure.ac, config.h.in)
- The configure test for bitfield ordering uses AC_TRY_RUN and thus
doesn't work when cross-compiling; use sneakiness to try and
determine it at compile time, falling back to the existing runtime
check if the sneakiness doesn't work
(changes configure.ac; tested on x86_64-linux-gnu and i586-mingw32
which are bf_lsbf=1, plus sparc64-linux-gnu which is bf_lsbf=0)
- The configure test for "extern long timezone" needlessly uses
AC_TRY_RUN when in fact AC_LINK_IFELSE is all we need to know, and
that latter works when cross-compiling
(changes configure.ac)
- MinGW sys/stat.h doesn't have the *GRP or *OTH macros, nor S_IFLNK
or S_IFSOCK, nor S_ISUID etc
(changes lib/udf/udf.c and lib/iso9660/xa.c)
- MinGW doesn't have <sys/wait.h>, so even the header-inclusion bit
of the Linux driver doesn't compile unless it's moved inside the
"ifdef HAVE_LINUX_CDROM"
(changes lib/driver/gnu_linux.c)
- Because the man pages cd-info.1 etc depend on the binaries themselves
(for help2man reasons), the configure options --without-cd-info etc
don't actually stop them being compiled. Fixed by only depending on
man pages for programs that are actually built, which also stops
the installation of man pages of programs which aren't themselves
installed
(changes src/Makefile.am)
2008-04-24 07:28:00 +00:00
|
|
|
|
#endif
|
2005-11-06 00:39:37 +00:00
|
|
|
|
|
Patch from Peter Hartley to allow Cross-compiling to mingw32:
- MinGW doesn't have struct timespec, so udf_time.c doesn't compile
(changes lib/udf/udf_time.c, configure.ac, config.h.in)
- The configure test for bitfield ordering uses AC_TRY_RUN and thus
doesn't work when cross-compiling; use sneakiness to try and
determine it at compile time, falling back to the existing runtime
check if the sneakiness doesn't work
(changes configure.ac; tested on x86_64-linux-gnu and i586-mingw32
which are bf_lsbf=1, plus sparc64-linux-gnu which is bf_lsbf=0)
- The configure test for "extern long timezone" needlessly uses
AC_TRY_RUN when in fact AC_LINK_IFELSE is all we need to know, and
that latter works when cross-compiling
(changes configure.ac)
- MinGW sys/stat.h doesn't have the *GRP or *OTH macros, nor S_IFLNK
or S_IFSOCK, nor S_ISUID etc
(changes lib/udf/udf.c and lib/iso9660/xa.c)
- MinGW doesn't have <sys/wait.h>, so even the header-inclusion bit
of the Linux driver doesn't compile unless it's moved inside the
"ifdef HAVE_LINUX_CDROM"
(changes lib/driver/gnu_linux.c)
- Because the man pages cd-info.1 etc depend on the binaries themselves
(for help2man reasons), the configure options --without-cd-info etc
don't actually stop them being compiled. Fixed by only depending on
man pages for programs that are actually built, which also stops
the installation of man pages of programs which aren't themselves
installed
(changes src/Makefile.am)
2008-04-24 07:28:00 +00:00
|
|
|
|
#ifdef S_IROTH
|
2005-11-06 00:39:37 +00:00
|
|
|
|
if (i_perms & XA_PERM_ROTH) mode |= S_IROTH;
|
Patch from Peter Hartley to allow Cross-compiling to mingw32:
- MinGW doesn't have struct timespec, so udf_time.c doesn't compile
(changes lib/udf/udf_time.c, configure.ac, config.h.in)
- The configure test for bitfield ordering uses AC_TRY_RUN and thus
doesn't work when cross-compiling; use sneakiness to try and
determine it at compile time, falling back to the existing runtime
check if the sneakiness doesn't work
(changes configure.ac; tested on x86_64-linux-gnu and i586-mingw32
which are bf_lsbf=1, plus sparc64-linux-gnu which is bf_lsbf=0)
- The configure test for "extern long timezone" needlessly uses
AC_TRY_RUN when in fact AC_LINK_IFELSE is all we need to know, and
that latter works when cross-compiling
(changes configure.ac)
- MinGW sys/stat.h doesn't have the *GRP or *OTH macros, nor S_IFLNK
or S_IFSOCK, nor S_ISUID etc
(changes lib/udf/udf.c and lib/iso9660/xa.c)
- MinGW doesn't have <sys/wait.h>, so even the header-inclusion bit
of the Linux driver doesn't compile unless it's moved inside the
"ifdef HAVE_LINUX_CDROM"
(changes lib/driver/gnu_linux.c)
- Because the man pages cd-info.1 etc depend on the binaries themselves
(for help2man reasons), the configure options --without-cd-info etc
don't actually stop them being compiled. Fixed by only depending on
man pages for programs that are actually built, which also stops
the installation of man pages of programs which aren't themselves
installed
(changes src/Makefile.am)
2008-04-24 07:28:00 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef S_IXOTH
|
2005-11-06 00:39:37 +00:00
|
|
|
|
if (i_perms & XA_PERM_XOTH) mode |= S_IXOTH;
|
Patch from Peter Hartley to allow Cross-compiling to mingw32:
- MinGW doesn't have struct timespec, so udf_time.c doesn't compile
(changes lib/udf/udf_time.c, configure.ac, config.h.in)
- The configure test for bitfield ordering uses AC_TRY_RUN and thus
doesn't work when cross-compiling; use sneakiness to try and
determine it at compile time, falling back to the existing runtime
check if the sneakiness doesn't work
(changes configure.ac; tested on x86_64-linux-gnu and i586-mingw32
which are bf_lsbf=1, plus sparc64-linux-gnu which is bf_lsbf=0)
- The configure test for "extern long timezone" needlessly uses
AC_TRY_RUN when in fact AC_LINK_IFELSE is all we need to know, and
that latter works when cross-compiling
(changes configure.ac)
- MinGW sys/stat.h doesn't have the *GRP or *OTH macros, nor S_IFLNK
or S_IFSOCK, nor S_ISUID etc
(changes lib/udf/udf.c and lib/iso9660/xa.c)
- MinGW doesn't have <sys/wait.h>, so even the header-inclusion bit
of the Linux driver doesn't compile unless it's moved inside the
"ifdef HAVE_LINUX_CDROM"
(changes lib/driver/gnu_linux.c)
- Because the man pages cd-info.1 etc depend on the binaries themselves
(for help2man reasons), the configure options --without-cd-info etc
don't actually stop them being compiled. Fixed by only depending on
man pages for programs that are actually built, which also stops
the installation of man pages of programs which aren't themselves
installed
(changes src/Makefile.am)
2008-04-24 07:28:00 +00:00
|
|
|
|
#endif
|
2005-11-06 00:39:37 +00:00
|
|
|
|
|
|
|
|
|
|
if (i_perms & XA_ATTR_DIRECTORY) mode |= S_IFDIR;
|
|
|
|
|
|
|
|
|
|
|
|
return mode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|