Compare commits
53 Commits
release-1.
...
release-1.
Author | SHA1 | Date | |
---|---|---|---|
e7dd325ff6 | |||
0447496710 | |||
496b8051c5 | |||
63c074b0aa | |||
2be47f9af8 | |||
bf5678c6d4 | |||
9d64318502 | |||
866f647fad | |||
2f134dcdcb | |||
b14ee71d51 | |||
c5c9d4e7bf | |||
6321ed4d97 | |||
188e36178b | |||
cbfa9afcf1 | |||
cb519b3692 | |||
8407d9e936 | |||
d482eb4c96 | |||
1786ceb276 | |||
f51fc50356 | |||
02de4570d1 | |||
2a41b4817c | |||
9440e3061c | |||
122dfe7b87 | |||
03662f0832 | |||
eb09bcf9e5 | |||
5880636a50 | |||
b5fb98a2a3 | |||
b269557743 | |||
0fd7d4d7eb | |||
d8dca37d65 | |||
cd84f0927f | |||
477bbb89bb | |||
31fcdc0ba6 | |||
7c05d2a865 | |||
3d15642307 | |||
872b5c6c67 | |||
ec35bb21c0 | |||
93f3cb1823 | |||
fea7be5168 | |||
bd25db9283 | |||
97eec6162c | |||
17e8cb6697 | |||
9e01d3654e | |||
009ce1be8f | |||
c79299ba08 | |||
b3701f0b18 | |||
83b864efd2 | |||
cd0f57dd1a | |||
4c9cb6b96b | |||
9c334891cf | |||
2f6103b783 | |||
f32ee7da83 | |||
52972811f8 |
32
ChangeLog
32
ChangeLog
@ -1,3 +1,35 @@
|
||||
|
||||
libisofs-1.4.6.tar.gz Fri Sep 16 2016
|
||||
===============================================================================
|
||||
* Bug fix: SIGSEGV by NULL when a data file was larger than ISO level allows.
|
||||
* Bug fix: Interpretation of 17 digit timestamps was wrong.
|
||||
* New API calls iso_generate_gpt_guid() and iso_write_opts_set_gpt_guid().
|
||||
* Made several pseudo-random ids reproducible by overriding volume modification
|
||||
time.
|
||||
|
||||
libisofs-1.4.4.tar.gz Fri Jul 01 2016
|
||||
===============================================================================
|
||||
* Bug fix: HFS+ production could cause MBR partition of type 0xEE without GPT.
|
||||
* Bug fix: Protective MBR was not produced if no System Area data are given.
|
||||
* Bug fix: Protective MBR was not recognized if partition is appended.
|
||||
* Bug fix: The HFS+ filesystem was not marked in GPT of GRUB2 hybrid layout.
|
||||
* Bug fix: HFS+ directories could announce more children than they actually
|
||||
have.
|
||||
* Bug fix: At image loading time GRUB2 MBR was not recognized if the partition
|
||||
table is not the protective one as described by UEFI.
|
||||
* Bug fix: Oversized text in ISO_SYSAREA_REPORT_DOC_ALPHA.
|
||||
Thanks to Etienne Bergeron.
|
||||
* New pseudo path for El Torito boot images:
|
||||
--interval:appened_partition_N:all::
|
||||
* New bit15 with options of iso_write_opts_set_system_area() to enforce
|
||||
MBR bootable/active flag.
|
||||
* New API calls iso_write_opts_set_appended_as_apm(),
|
||||
iso_write_opts_set_part_like_isohybrid().
|
||||
* Introduced image size tolerance of 300 kB in order to recognize SUN Disk
|
||||
Label that was generated by genisoimage -B "...".
|
||||
* Added "extern C" to libisofs.h
|
||||
* Removed option --silent from libtool runs.
|
||||
|
||||
libisofs-1.4.2.tar.gz Sat Nov 28 2015
|
||||
===============================================================================
|
||||
* Bug fix: zisofs compression caused SIGSEGV (by reading) with files larger
|
||||
|
@ -13,7 +13,7 @@ ACLOCAL_AMFLAGS = -I ./
|
||||
# Build libraries
|
||||
|
||||
libisofs_libisofs_la_LDFLAGS = \
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
|
||||
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) $(LIBLDFLAGS)
|
||||
|
||||
# Eventually enabling system adapters for ACL and EA.
|
||||
# ts A90409: Eventually enabling use of zlib.
|
||||
|
4
README
4
README
@ -4,7 +4,7 @@
|
||||
|
||||
Released under GPL (see COPYING file for details).
|
||||
|
||||
Copyright (C) 2008 - 2015 Vreixo Formoso,
|
||||
Copyright (C) 2008 - 2016 Vreixo Formoso,
|
||||
Mario Danic,
|
||||
Vladimir Serbinenko,
|
||||
Thomas Schmitt
|
||||
@ -14,7 +14,7 @@ libisofs is part of the libburnia project (libburnia-project.org)
|
||||
|
||||
Download, Build and Installation
|
||||
|
||||
libisofs code is mantained in a Bazaar repository at Launchpad
|
||||
libisofs code is maintained in a Bazaar repository at Launchpad
|
||||
(https://launchpad.net/libisofs/). You can download it with:
|
||||
|
||||
$ bzr branch lp:libisofs/for-libisoburn
|
||||
|
12
acinclude.m4
12
acinclude.m4
@ -16,15 +16,21 @@ AC_DEFUN([TARGET_SHIZZLE],
|
||||
|
||||
AC_MSG_CHECKING([target operating system])
|
||||
|
||||
LIBBURNIA_SUPP_ACL=none
|
||||
LIBBURNIA_SUPP_FATTR=none
|
||||
LIBBURNIA_LDCONFIG_CMD="echo 'No ldconfig run performed. If needed, configure manually for:'"
|
||||
case $target in
|
||||
*-*-linux*)
|
||||
ARCH=linux
|
||||
LIBBURN_ARCH_LIBS=
|
||||
LIBBURNIA_SUPP_ACL=libacl
|
||||
LIBBURNIA_SUPP_FATTR=xattr
|
||||
LIBBURNIA_LDCONFIG_CMD=ldconfig
|
||||
;;
|
||||
*-*-freebsd*)
|
||||
ARCH=freebsd
|
||||
LIBBURNIA_SUPP_ACL=libacl
|
||||
LIBBURNIA_SUPP_FATTR=extattr
|
||||
LIBBURN_ARCH_LIBS=-lcam
|
||||
|
||||
# This may later be overridden by configure --enable-libdir-pkgconfig
|
||||
@ -141,10 +147,12 @@ AC_DEFUN([LIBISOFS_ASSERT_VERS_LIBS],
|
||||
LDFLAGS="$LDFLAGS -Wl,--version-script=libisofs/libisofs.ver"
|
||||
AC_TRY_LINK([#include <stdio.h>], [printf("Hello\n");],
|
||||
[vers_libs_test="yes"], [vers_libs_test="no"])
|
||||
if test x$vers_libs_test = xno
|
||||
if test x$vers_libs_test = xyes
|
||||
then
|
||||
LDFLAGS="$libburnia_save_LDFLAGS"
|
||||
LIBLDFLAGS="-Wl,--version-script=libisofs/libisofs.ver"
|
||||
fi
|
||||
LDFLAGS="$libburnia_save_LDFLAGS"
|
||||
AC_SUBST(LIBLDFLAGS)
|
||||
])
|
||||
|
||||
|
||||
|
83
configure.ac
83
configure.ac
@ -1,4 +1,4 @@
|
||||
AC_INIT([libisofs], [1.4.2], [http://libburnia-project.org])
|
||||
AC_INIT([libisofs], [1.4.6], [http://libburnia-project.org])
|
||||
AC_PREREQ([2.50])
|
||||
dnl AC_CONFIG_HEADER([config.h])
|
||||
|
||||
@ -26,8 +26,8 @@ dnl
|
||||
dnl LT_CURRENT, LT_REVISION and LT_AGE get set directly now.
|
||||
dnl
|
||||
dnl SONAME of the emerging library is LT_CURRENT - LT_AGE.
|
||||
dnl The linker will do no finer checks. Especially no age range check for
|
||||
dnl the cdrskin binary. If SONAME matches, then the couple starts.
|
||||
dnl The linker will do no finer checks. If SONAME matches, then the couple
|
||||
dnl starts.
|
||||
dnl
|
||||
dnl Therefore a run time check is provided by libisofs function
|
||||
dnl iso_lib_version(). It returns the major, minor and micro revision of the
|
||||
@ -41,7 +41,7 @@ dnl If LIBISOFS_*_VERSION changes, be sure to change AC_INIT above to match.
|
||||
dnl
|
||||
LIBISOFS_MAJOR_VERSION=1
|
||||
LIBISOFS_MINOR_VERSION=4
|
||||
LIBISOFS_MICRO_VERSION=2
|
||||
LIBISOFS_MICRO_VERSION=6
|
||||
LIBISOFS_VERSION=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION.$LIBISOFS_MICRO_VERSION
|
||||
|
||||
AC_SUBST(LIBISOFS_MAJOR_VERSION)
|
||||
@ -51,10 +51,10 @@ AC_SUBST(LIBISOFS_VERSION)
|
||||
|
||||
dnl Libtool versioning
|
||||
LT_RELEASE=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION
|
||||
# 2015.11.28 development jump has not yet happened
|
||||
# SONAME = 84 - 78 = 6 . Library name = libisofs.6.78.0
|
||||
LT_CURRENT=84
|
||||
LT_AGE=78
|
||||
# 2016.07.01 development jump has not yet happened
|
||||
# SONAME = 88 - 82 = 6 . Library name = libisofs.6.82.0
|
||||
LT_CURRENT=88
|
||||
LT_AGE=82
|
||||
LT_REVISION=0
|
||||
LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
|
||||
|
||||
@ -92,7 +92,7 @@ LIBBURNIA_ASSERT_ICONV
|
||||
|
||||
AC_PROG_LIBTOOL
|
||||
AC_SUBST(LIBTOOL_DEPS)
|
||||
LIBTOOL="$LIBTOOL --silent"
|
||||
# LIBTOOL="$LIBTOOL --silent"
|
||||
|
||||
AC_PROG_INSTALL
|
||||
|
||||
@ -172,39 +172,66 @@ dnl Add compiler-specific flags
|
||||
AC_ARG_ENABLE(libacl,
|
||||
[ --enable-libacl Enable use of ACL functions by libisofs, default=yes],
|
||||
, enable_libacl=yes)
|
||||
if test "x$enable_libacl" = xyes; then
|
||||
LIBACL_DEF=
|
||||
has_acl_h_but_no_func=0
|
||||
if test x$LIBBURNIA_SUPP_ACL = xlibacl
|
||||
then
|
||||
if test x$enable_libacl = xyes; then
|
||||
dnl Check whether there is libacl-devel and libacl-runtime.
|
||||
dnl If not, erase this macro which would enable use of acl_to_text and others
|
||||
LIBACL_DEF="-DLibisofs_with_aaip_acL"
|
||||
LIBACL_DEF="-DLibisofs_with_aaip_acL"
|
||||
dnl The empty yes case obviously causes -lacl to be linked
|
||||
has_acl_h_but_no_func=0
|
||||
AC_CHECK_HEADER(sys/acl.h, AC_CHECK_LIB(acl, acl_to_text, , has_acl_h_but_no_libacl=1 ), LIBACL_DEF= )
|
||||
if test "$has_acl_h_but_no_libacl" = 1
|
||||
AC_CHECK_HEADER(sys/acl.h, AC_CHECK_LIB(acl, acl_to_text, , has_acl_h_but_no_libacl=1 ), LIBACL_DEF= )
|
||||
if test "$has_acl_h_but_no_libacl" = 1
|
||||
then
|
||||
AC_CHECK_LIB(c, acl_to_text, X= , LIBACL_DEF= )
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test x$LIBACL_DEF = x-DLibisofs_with_aaip_acL
|
||||
then
|
||||
if test x$has_acl_h_but_no_libacl = x1
|
||||
then
|
||||
AC_CHECK_LIB(c, acl_to_text, X= , LIBACL_DEF= )
|
||||
fi
|
||||
echo "enabled local processing of ACL"
|
||||
else
|
||||
echo "enabled libacl, local processing of ACL"
|
||||
fi
|
||||
else
|
||||
LIBACL_DEF=
|
||||
echo "disabled local processing of ACL"
|
||||
fi
|
||||
AC_SUBST(LIBACL_DEF)
|
||||
|
||||
|
||||
dnl ts A90123
|
||||
dnl ts A90123 - B51212
|
||||
AC_ARG_ENABLE(xattr,
|
||||
[ --enable-xattr Enable use of xattr by libisofs, default=yes],
|
||||
, enable_xattr=yes)
|
||||
if test "x$enable_xattr" = xyes; then
|
||||
[ --enable-xattr Enable use of extended file attributes by libisofs, default=yes],
|
||||
, enable_xattr=yes)
|
||||
XATTR_DEF=
|
||||
if test x"$LIBBURNIA_SUPP_FATTR" = xxattr
|
||||
then
|
||||
if test "x$enable_xattr" = xyes; then
|
||||
dnl Check whether there is the header for Linux xattr.
|
||||
dnl If not, erase this macro which would enable use of listxattr and others
|
||||
XATTR_DEF="-DLibisofs_with_aaip_xattR"
|
||||
AC_CHECK_HEADER(attr/xattr.h, AC_CHECK_LIB(c, listxattr, X= , XATTR_DEF= ), XATTR_DEF= )
|
||||
if test "x$XATTR_DEF" = x
|
||||
then
|
||||
XATTR_DEF="-DLibisofs_with_freebsd_extattR"
|
||||
AC_CHECK_HEADER(sys/extattr.h, AC_CHECK_LIB(c, extattr_list_file, X=, XATTR_DEF= ), XATTR_DEF= )
|
||||
XATTR_DEF="-DLibisofs_with_aaip_xattR"
|
||||
AC_CHECK_HEADER(attr/xattr.h, AC_CHECK_LIB(c, listxattr, X= ,
|
||||
XATTR_DEF= ), XATTR_DEF= )
|
||||
fi
|
||||
elif test x"$LIBBURNIA_SUPP_FATTR" = xextattr
|
||||
then
|
||||
if test "x$enable_xattr" = xyes; then
|
||||
XATTR_DEF="-DLibisofs_with_freebsd_extattR"
|
||||
AC_CHECK_HEADER(sys/extattr.h, AC_CHECK_LIB(c, extattr_list_file, X=,
|
||||
XATTR_DEF= ), XATTR_DEF= )
|
||||
fi
|
||||
fi
|
||||
if test x$XATTR_DEF = x-DLibisofs_with_aaip_xattR
|
||||
then
|
||||
echo "enabled xattr, local processing of extended file attributes Linux style"
|
||||
elif test x$XATTR_DEF = x-DLibisofs_with_freebsd_extattR
|
||||
then
|
||||
echo "enabled extattr, local processing of extended file attributes FreeBSD style"
|
||||
else
|
||||
XATTR_DEF=
|
||||
echo "disabled local processing of extended file attributes"
|
||||
fi
|
||||
AC_SUBST(XATTR_DEF)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 - 2015 Vreixo Formoso, Thomas Schmitt
|
||||
* Copyright (c) 2007 - 2016 Vreixo Formoso, Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -375,7 +375,7 @@ int gesture_iso(int argc, char **argv)
|
||||
|
||||
result = iso_write_opts_new(&opts, 0);
|
||||
if (result < 0) {
|
||||
printf ("Cant create write opts, error %d\n", result);
|
||||
printf ("Cannot create write opts, error %d\n", result);
|
||||
goto ex;
|
||||
}
|
||||
iso_write_opts_set_iso_level(opts, level);
|
||||
@ -385,7 +385,7 @@ int gesture_iso(int argc, char **argv)
|
||||
|
||||
result = iso_image_create_burn_source(image, opts, &burn_src);
|
||||
if (result < 0) {
|
||||
printf ("Cant create image, error %d\n", result);
|
||||
printf ("Cannot create image, error %d\n", result);
|
||||
goto ex;
|
||||
}
|
||||
|
||||
@ -904,7 +904,7 @@ int gesture_iso_ms(int argc, char **argv)
|
||||
|
||||
result = iso_image_create_burn_source(image, opts, &burn_src);
|
||||
if (result < 0) {
|
||||
printf ("Cant create image, error %d\n", result);
|
||||
printf ("Cannot create image, error %d\n", result);
|
||||
goto ex;
|
||||
}
|
||||
iso_write_opts_free(opts);
|
||||
|
@ -68,9 +68,9 @@ intervals for:
|
||||
- Directory trees, tables, boot catalog, embedded partitions and filesystems.
|
||||
- Data file content, including content of El Torito boot images.
|
||||
|
||||
The Boot Record is an ECMA-119 Volume Descriptor which is eventually located
|
||||
at 2 kB block number 17 (decimal). Its content points to the location of the
|
||||
Boot Catalog.
|
||||
The Boot Record is an ECMA-119 Volume Descriptor which is located at 2 kB block
|
||||
number 17 (decimal), if present at all. Its content points to the location of
|
||||
the Boot Catalog.
|
||||
The format is described in part by ECMA-119 8.2 "Boot Record" and further
|
||||
specified by El Torito figure 7.
|
||||
|
||||
@ -177,7 +177,7 @@ Byte Range | Value | Meaning
|
||||
| |
|
||||
5 - 5 | 0 | Unused
|
||||
| |
|
||||
6 - 7 | sec_count | Sector Count.
|
||||
6 - 7 | sec_count | Sector Count. Sector size 512:
|
||||
| | "the number of virtual/emulated sectors the system
|
||||
| | will store at Load Segment during the initial boot
|
||||
| | procedure."
|
||||
@ -232,7 +232,7 @@ Byte Range | Value | Meaning
|
||||
| | 0 if not emulation == 4.
|
||||
5 - 5 | 0 | Unused
|
||||
| |
|
||||
6 - 7 | sec_count | Sector Count.
|
||||
6 - 7 | sec_count | Sector Count. Sector size 512.
|
||||
| | See above Initial/Default Entry
|
||||
| | libisofs stores 1 for emulated boot_media and a
|
||||
| | user defined value for boot_media == 0. Often: 4.
|
||||
|
@ -189,7 +189,7 @@ With tag type 2:
|
||||
|
||||
Keep the original MD5 context of the data blocks and clone one for obtaining
|
||||
the MD5 bytes.
|
||||
If the MD5s match, then compute the checksum block and all folowing ones into
|
||||
If the MD5s match, then compute the checksum block and all following ones into
|
||||
the kept MD5 context and go on with reading and computing for the tree checksum
|
||||
tag. This will be found at block address next_tag, verified and parsed by:
|
||||
iso_util_decode_md5_tag(block, &tag_type, &pos,
|
||||
@ -211,7 +211,7 @@ next_tag. Go on by looking for tag type 2 and follow above prescription.
|
||||
|
||||
Checking the Data Part of the Session
|
||||
|
||||
In order to check the trustworthyness of a whole session, continue reading
|
||||
In order to check the trustworthiness of a whole session, continue reading
|
||||
and checksumming after the tree was verified.
|
||||
|
||||
Read and checksum the blocks. When reaching block address next_tag (from the
|
||||
|
@ -394,12 +394,6 @@ MAX_INITIALIZER_LINES = 30
|
||||
|
||||
SHOW_USED_FILES = YES
|
||||
|
||||
# If the sources in your project are distributed over multiple directories
|
||||
# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
|
||||
# in the documentation. The default is NO.
|
||||
|
||||
SHOW_DIRECTORIES = NO
|
||||
|
||||
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
|
||||
# doxygen should invoke to get the current version for each file (typically from the
|
||||
# version control system). Doxygen will invoke the program by executing (via
|
||||
@ -527,7 +521,7 @@ EXCLUDE_SYMBOLS =
|
||||
# directories that contain example code fragments that are included (see
|
||||
# the \include command).
|
||||
|
||||
EXAMPLE_PATH = test
|
||||
EXAMPLE_PATH = demo/demo.c
|
||||
|
||||
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
|
||||
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
@ -698,12 +692,6 @@ HTML_FOOTER =
|
||||
|
||||
HTML_STYLESHEET =
|
||||
|
||||
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
|
||||
# files or namespaces will be aligned in HTML using tables. If set to
|
||||
# NO a bullet list will be used.
|
||||
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
|
||||
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
|
||||
# will be generated that can be used as input for tools like the
|
||||
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
|
||||
@ -938,18 +926,6 @@ GENERATE_XML = NO
|
||||
|
||||
XML_OUTPUT = xml
|
||||
|
||||
# The XML_SCHEMA tag can be used to specify an XML schema,
|
||||
# which can be used by a validating XML parser to check the
|
||||
# syntax of the XML files.
|
||||
|
||||
XML_SCHEMA =
|
||||
|
||||
# The XML_DTD tag can be used to specify an XML DTD,
|
||||
# which can be used by a validating XML parser to check the
|
||||
# syntax of the XML files.
|
||||
|
||||
XML_DTD =
|
||||
|
||||
# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
|
||||
# dump the program listings (including syntax highlighting
|
||||
# and cross-referencing information) to the XML output. Note that
|
||||
|
@ -235,7 +235,7 @@ An eventually needed qualifier is stored in one or more Qualifier Records.
|
||||
[b] "BP 2 - Qualifier Record Head" shall be present only if QUALIFIER is set
|
||||
to 1. It shall give the number of Qualifier Bytes and eventually
|
||||
indicate that the qualifier continues in a Qualifier Record which comes
|
||||
imediately after this record.
|
||||
immediately after this record.
|
||||
0 to 127 Q_LENGTH, the qualifier is complete by this record
|
||||
128 to 255 Q_LENGTH+128, the qualifier is continued by next record
|
||||
So a Qualifier Record can contain at most 127 Qualifier Bytes.
|
||||
|
@ -5,9 +5,9 @@
|
||||
Arbitrary Attribute Interchange Protocol , system adapter for getting and
|
||||
setting of ACLs and xattr.
|
||||
|
||||
To be included by aaip_0_2.c for FreeBSD and NetBSD
|
||||
To be included by aaip_0_2.c for FreeBSD, NetBSD, and OpenBSD
|
||||
|
||||
Copyright (c) 2009 - 2014 Thomas Schmitt, libburnia project, GPLv2+
|
||||
Copyright (c) 2009 - 2016 Thomas Schmitt, libburnia project, GPLv2+
|
||||
|
||||
*/
|
||||
|
||||
@ -342,7 +342,7 @@ int aaip_get_attr_list(char *path, size_t *num_attrs, char ***names,
|
||||
size_t **value_lengths, char ***values, int flag)
|
||||
{
|
||||
int ret;
|
||||
ssize_t i, num_names= 0, acl_names= 0;
|
||||
ssize_t i, num_names= 0;
|
||||
|
||||
#ifdef Libisofs_with_aaip_acL
|
||||
unsigned char *a_acl= NULL;
|
||||
@ -354,6 +354,7 @@ int aaip_get_attr_list(char *path, size_t *num_attrs, char ***names,
|
||||
ssize_t value_ret, retry= 0, list_size= 0, user_list_size= 0;
|
||||
ssize_t sys_list_size= 0;
|
||||
int attrnamespace;
|
||||
int acl_names= 0;
|
||||
#endif
|
||||
|
||||
if(flag & (1 << 15)) { /* Free memory */
|
||||
@ -408,7 +409,11 @@ int aaip_get_attr_list(char *path, size_t *num_attrs, char ***names,
|
||||
#ifdef Libisofs_with_aaip_acL
|
||||
if(flag & 1) {
|
||||
num_names++;
|
||||
|
||||
#ifdef Libisofs_with_freebsd_extattR
|
||||
acl_names= 1;
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
To be included by aaip_0_2.c for Linux
|
||||
|
||||
Copyright (c) 2009 - 2011 Thomas Schmitt, libburnia project, GPLv2+
|
||||
Copyright (c) 2009 - 2016 Thomas Schmitt, libburnia project, GPLv2+
|
||||
|
||||
*/
|
||||
|
||||
@ -443,7 +443,7 @@ ex:
|
||||
I.e. those with a name which does not begin
|
||||
by "user."
|
||||
bit5= in case of symbolic link: manipulate link target
|
||||
bit6= tolerate inappropriate presence or absense of
|
||||
bit6= tolerate inappropriate presence or absence of
|
||||
directory default ACL
|
||||
@return 1 success
|
||||
-1 error memory allocation
|
||||
|
@ -7,7 +7,7 @@
|
||||
See libisofs/aaip_0_2.h
|
||||
http://libburnia-project.org/wiki/AAIP
|
||||
|
||||
Copyright (c) 2009 - 2015 Thomas Schmitt, libburnia project, GPLv2+
|
||||
Copyright (c) 2009 - 2016 Thomas Schmitt, libburnia project, GPLv2+
|
||||
|
||||
*/
|
||||
|
||||
@ -648,7 +648,7 @@ ex:;
|
||||
mission bits.
|
||||
|
||||
*/
|
||||
/* Analyze occurence of ACL tag types in long text form. If not disabled by
|
||||
/* Analyze occurrence of ACL tag types in long text form. If not disabled by
|
||||
parameter flag remove the entries of type "user::" , "group::" , "other::" ,
|
||||
or "other:" from an ACL in long text form if they match the bits in st_mode
|
||||
as described by man 2 stat and man 5 acl.
|
||||
@ -2192,11 +2192,32 @@ ex:;
|
||||
|
||||
#include "aaip-os-freebsd.c"
|
||||
|
||||
#else
|
||||
#ifdef __FreeBSD_kernel__
|
||||
|
||||
#ifdef NIX
|
||||
#ifdef Libisofs_with_aaip_xattR
|
||||
/* ts B51213: xattr system library calls are only stubs */
|
||||
#include "aaip-os-linux.c"
|
||||
#else
|
||||
/* ts B51213: extattr system library calls are not even present */
|
||||
#include "aaip-os-freebsd.c"
|
||||
#endif /* ! Libisofs_with_aaip_xattR */
|
||||
#else /* NIX */
|
||||
/* ts B51213: so we still end up at the dummy */
|
||||
#include "aaip-os-dummy.c"
|
||||
#endif /* ! NIX */
|
||||
|
||||
#else
|
||||
#ifdef __NetBSD__
|
||||
|
||||
#include "aaip-os-freebsd.c"
|
||||
|
||||
#else
|
||||
#ifdef __OpenBSD__
|
||||
|
||||
#include "aaip-os-freebsd.c"
|
||||
|
||||
#else
|
||||
#ifdef __linux
|
||||
|
||||
@ -2214,6 +2235,8 @@ ex:;
|
||||
#include "aaip-os-dummy.c"
|
||||
|
||||
#endif /* ! __linux */
|
||||
#endif /* ! __OpenBSD__ */
|
||||
#endif /* ! __NetBSD__ */
|
||||
#endif /* ! __FreeBSD_kernel__ */
|
||||
#endif /* ! __FreeBSD__ */
|
||||
|
||||
|
@ -9,13 +9,16 @@
|
||||
|
||||
test/aaip_0_2.h - Public declarations
|
||||
|
||||
Copyright (c) 2009 Thomas Schmitt, libburnia project, GPLv2+
|
||||
Copyright (c) 2009 - 2016 Thomas Schmitt, libburnia project, GPLv2+
|
||||
|
||||
*/
|
||||
|
||||
#ifndef Aaip_h_is_includeD
|
||||
#define Aaip_h_is_includeD yes
|
||||
|
||||
/* For ssize_t */
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
/* --------------------------------- Encoder ---------------------------- */
|
||||
|
||||
@ -90,7 +93,7 @@ int aaip_encode_both_acl(char *a_acl_text, char *d_acl_text, mode_t st_mode,
|
||||
size_t *result_len, unsigned char **result, int flag);
|
||||
|
||||
|
||||
/* Analyze occurence of ACL tag types in long text form. If not disabled by
|
||||
/* Analyze occurrence of ACL tag types in long text form. If not disabled by
|
||||
parameter flag remove the entries of type "user::" , "group::" , "other::" ,
|
||||
or "other:" from an ACL in long text form if they match the bits in st_mode
|
||||
as described by man 2 stat and man 5 acl.
|
||||
|
@ -145,7 +145,7 @@ void ds_free_data(IsoDataSource *src)
|
||||
|
||||
/**
|
||||
* Create a new IsoDataSource from a local file. This is suitable for
|
||||
* accessing regular .iso images, or to acces drives via its block device
|
||||
* accessing regular .iso images, or to access drives via its block device
|
||||
* and standard POSIX I/O calls.
|
||||
*
|
||||
* @param path
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2007 Mario Danic
|
||||
* Copyright (c) 2009 - 2015 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -104,6 +104,12 @@ void ecma119_image_free(Ecma119Image *t)
|
||||
free(t->output_charset);
|
||||
if (t->bootsrc != NULL)
|
||||
free(t->bootsrc);
|
||||
if (t->boot_appended_idx != NULL)
|
||||
free(t->boot_appended_idx);
|
||||
if (t->boot_intvl_start != NULL)
|
||||
free(t->boot_intvl_start);
|
||||
if (t->boot_intvl_size != NULL)
|
||||
free(t->boot_intvl_size);
|
||||
if (t->system_area_data != NULL)
|
||||
free(t->system_area_data);
|
||||
if (t->checksum_ctx != NULL) { /* dispose checksum context */
|
||||
@ -187,7 +193,7 @@ size_t calc_dirent_len(Ecma119Image *t, Ecma119Node *n)
|
||||
|
||||
/**
|
||||
* Computes the total size of all directory entries of a single dir,
|
||||
* acording to ECMA-119 6.8.1.1
|
||||
* according to ECMA-119 6.8.1.1
|
||||
*
|
||||
* This also take into account the size needed for RR entries and
|
||||
* SUSP continuation areas (SUSP, 5.1).
|
||||
@ -567,8 +573,14 @@ int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
|
||||
vol.vol_desc_version[0] = 1;
|
||||
strncpy_pad((char*)vol.system_id, system_id, 32);
|
||||
strncpy_pad((char*)vol.volume_id, vol_id, 32);
|
||||
iso_bb(vol.vol_space_size, t->vol_space_size - t->eff_partition_offset,
|
||||
4);
|
||||
if (t->pvd_size_is_total_size) {
|
||||
iso_bb(vol.vol_space_size,
|
||||
t->total_size / 2048 + t->opts->ms_block - t->eff_partition_offset,
|
||||
4);
|
||||
} else {
|
||||
iso_bb(vol.vol_space_size,
|
||||
t->vol_space_size - t->eff_partition_offset, 4);
|
||||
}
|
||||
iso_bb(vol.vol_set_size, (uint32_t) 1, 2);
|
||||
iso_bb(vol.vol_seq_number, (uint32_t) 1, 2);
|
||||
iso_bb(vol.block_size, (uint32_t) BLOCK_SIZE, 2);
|
||||
@ -2308,6 +2320,73 @@ ex:;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Determine the alleged time of image production by predicting the volume
|
||||
creation and modification timestamps and taking the maximum of both.
|
||||
*/
|
||||
static
|
||||
void ecma119_determine_now_time(Ecma119Image *target)
|
||||
{
|
||||
IsoWriteOpts *o;
|
||||
time_t now = 0, t, t0;
|
||||
uint8_t time_text[18];
|
||||
int i;
|
||||
|
||||
t0 = time(NULL);
|
||||
o = target->opts;
|
||||
if (o->vol_uuid[0]) {
|
||||
for(i = 0; i < 16; i++)
|
||||
if(o->vol_uuid[i] < '0' || o->vol_uuid[i] > '9')
|
||||
break;
|
||||
else
|
||||
time_text[i] = o->vol_uuid[i];
|
||||
for(; i < 16; i++)
|
||||
time_text[i] = '1';
|
||||
time_text[16] = time_text[17] = 0;
|
||||
t = iso_datetime_read_17(time_text);
|
||||
if (t > now)
|
||||
now = t;
|
||||
} else {
|
||||
if (o->vol_creation_time > 0) {
|
||||
if (o->vol_creation_time > now)
|
||||
now = o->vol_creation_time;
|
||||
} else if (t0 > now) {
|
||||
now = t0;
|
||||
}
|
||||
if (o->vol_modification_time > 0) {
|
||||
if (o->vol_modification_time > now)
|
||||
now = o->vol_modification_time;
|
||||
} else if (t0 > now) {
|
||||
now = t0;
|
||||
}
|
||||
}
|
||||
target->now = now;
|
||||
}
|
||||
|
||||
static
|
||||
int gpt_disk_guid_setup(Ecma119Image *target)
|
||||
{
|
||||
if (target->opts->gpt_disk_guid_mode == 0) {
|
||||
/* Random UUID production delayed until really needed */
|
||||
return ISO_SUCCESS;
|
||||
} else if (target->opts->gpt_disk_guid_mode == 1) {
|
||||
memcpy(target->gpt_uuid_base, target->opts->gpt_disk_guid, 16);
|
||||
} else if (target->opts->gpt_disk_guid_mode == 2) {
|
||||
if (target->opts->vol_uuid[0] == 0)
|
||||
return ISO_GPT_NO_VOL_UUID;
|
||||
/* Move centi-seconds part to byte 9 and 10 */
|
||||
memcpy(target->gpt_uuid_base, target->opts->vol_uuid, 9);
|
||||
memcpy(target->gpt_uuid_base + 9, target->opts->vol_uuid + 14, 2);
|
||||
memcpy(target->gpt_uuid_base + 11, target->opts->vol_uuid + 9, 5);
|
||||
iso_mark_guid_version_4(target->gpt_uuid_base);
|
||||
} else {
|
||||
return ISO_BAD_GPT_GUID_MODE;
|
||||
}
|
||||
memcpy(target->gpt_disk_guid, target->gpt_uuid_base, 16);
|
||||
target->gpt_disk_guid_set = 1;
|
||||
target->gpt_uuid_counter = 1;
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
|
||||
{
|
||||
@ -2326,7 +2405,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
|
||||
if (target == NULL) {
|
||||
return ISO_OUT_OF_MEM;
|
||||
}
|
||||
/* This reference will be transfered to the burn_source and released by
|
||||
/* This reference will be transferred to the burn_source and released by
|
||||
bs_free_data.
|
||||
*/
|
||||
target->refcount = 1;
|
||||
@ -2363,7 +2442,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
|
||||
target->dir_mode = opts->replace_dir_mode == 2 ? opts->dir_mode : 0555;
|
||||
target->file_mode = opts->replace_file_mode == 2 ? opts->file_mode : 0444;
|
||||
|
||||
target->now = time(NULL);
|
||||
ecma119_determine_now_time(target);
|
||||
|
||||
target->replace_timestamps = opts->replace_timestamps ? 1 : 0;
|
||||
target->timestamp = opts->replace_timestamps == 2 ?
|
||||
@ -2376,12 +2455,34 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
|
||||
target->num_bootsrc = target->catalog->num_bootimages;
|
||||
target->bootsrc = calloc(target->num_bootsrc + 1,
|
||||
sizeof(IsoFileSrc *));
|
||||
if (target->bootsrc == NULL) {
|
||||
target->boot_appended_idx = calloc(target->num_bootsrc + 1,
|
||||
sizeof(int));
|
||||
target->boot_intvl_start = calloc(target->num_bootsrc + 1,
|
||||
sizeof(uint32_t));
|
||||
target->boot_intvl_size = calloc(target->num_bootsrc + 1,
|
||||
sizeof(uint32_t));
|
||||
if (target->bootsrc == NULL || target->boot_appended_idx == NULL ||
|
||||
target->boot_intvl_start == NULL ||
|
||||
target->boot_intvl_size == NULL) {
|
||||
ret = ISO_OUT_OF_MEM;
|
||||
goto target_cleanup;
|
||||
}
|
||||
for (i= 0; i < target->num_bootsrc; i++)
|
||||
for (i= 0; i < target->num_bootsrc; i++) {
|
||||
target->bootsrc[i] = NULL;
|
||||
target->boot_appended_idx[i] = -1;
|
||||
target->boot_intvl_start[i] = 0;
|
||||
target->boot_intvl_size[i] = 0;
|
||||
}
|
||||
/* It is not easy to predict when the node gets created and can be
|
||||
manipulated. So it is better for reproducibility to derive its
|
||||
timestamps from the well controllable now-time.
|
||||
*/
|
||||
if (target->catalog->node != NULL) {
|
||||
iso_node_set_mtime((IsoNode *) target->catalog->node, target->now);
|
||||
iso_node_set_atime((IsoNode *) target->catalog->node, target->now);
|
||||
iso_node_set_ctime((IsoNode *) target->catalog->node, target->now);
|
||||
}
|
||||
|
||||
} else {
|
||||
target->num_bootsrc = 0;
|
||||
target->bootsrc = NULL;
|
||||
@ -2394,7 +2495,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
|
||||
system_area = src->system_area_data;
|
||||
system_area_options = src->system_area_options;
|
||||
} else {
|
||||
system_area_options = opts->system_area_options & 0xfffffffc;
|
||||
system_area_options = opts->system_area_options & 0xfffffffd;
|
||||
}
|
||||
sa_type = (system_area_options >> 2) & 0x3f;
|
||||
if (sa_type != 0 && sa_type != 3)
|
||||
@ -2448,6 +2549,10 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
|
||||
goto target_cleanup;
|
||||
}
|
||||
|
||||
target->total_size = 0;
|
||||
target->vol_space_size = 0;
|
||||
target->pvd_size_is_total_size = 0;
|
||||
|
||||
target->checksum_idx_counter = 0;
|
||||
target->checksum_ctx = NULL;
|
||||
target->checksum_counter = 0;
|
||||
@ -2517,7 +2622,12 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
|
||||
target->gpt_req_count = 0;
|
||||
target->gpt_req_flags = 0;
|
||||
target->gpt_backup_outside = 0;
|
||||
memset(target->gpt_uuid_base, 0, 16);
|
||||
target->gpt_uuid_counter = 0;
|
||||
target->gpt_disk_guid_set = 0;
|
||||
ret = gpt_disk_guid_setup(target);
|
||||
if (ret < 0)
|
||||
goto target_cleanup;
|
||||
target->gpt_part_start = 0;
|
||||
target->gpt_backup_end = 0;
|
||||
target->gpt_backup_size = 0;
|
||||
@ -3350,7 +3460,7 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile)
|
||||
wopts->vol_modification_time = 0;
|
||||
wopts->vol_expiration_time = 0;
|
||||
wopts->vol_effective_time = 0;
|
||||
wopts->vol_uuid[0] = 0;
|
||||
memset(wopts->vol_uuid, 0, 17);
|
||||
wopts->partition_offset = 0;
|
||||
wopts->partition_secs_per_head = 0;
|
||||
wopts->partition_heads_per_cyl = 0;
|
||||
@ -3370,6 +3480,8 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile)
|
||||
wopts->appended_part_flags[i] = 0;
|
||||
}
|
||||
wopts->appended_as_gpt = 0;
|
||||
wopts->appended_as_apm = 0;
|
||||
wopts->part_like_isohybrid = 0;
|
||||
wopts->ascii_disc_label[0] = 0;
|
||||
wopts->will_cancel = 0;
|
||||
wopts->allow_dir_id_ext = 0;
|
||||
@ -3379,6 +3491,8 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile)
|
||||
wopts->hfsp_serial_number[i] = 0;
|
||||
wopts->apm_block_size = 0;
|
||||
wopts->hfsp_block_size = 0;
|
||||
memset(wopts->gpt_disk_guid, 0, 16);
|
||||
wopts->gpt_disk_guid_mode = 0;
|
||||
|
||||
*opts = wopts;
|
||||
return ISO_SUCCESS;
|
||||
@ -3975,7 +4089,7 @@ int iso_write_opts_set_system_area(IsoWriteOpts *opts, char data[32768],
|
||||
opts->system_area_size = 32768;
|
||||
}
|
||||
if (!(flag & 4))
|
||||
opts->system_area_options = options & 0x7fff;
|
||||
opts->system_area_options = options & 0xffff;
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
@ -4091,6 +4205,18 @@ int iso_write_opts_set_appended_as_gpt(IsoWriteOpts *opts, int gpt)
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
int iso_write_opts_set_appended_as_apm(IsoWriteOpts *opts, int apm)
|
||||
{
|
||||
opts->appended_as_apm = !!apm;
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
int iso_write_opts_set_part_like_isohybrid(IsoWriteOpts *opts, int alike)
|
||||
{
|
||||
opts->part_like_isohybrid = !!alike;
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
int iso_write_opts_set_disc_label(IsoWriteOpts *opts, char *label)
|
||||
{
|
||||
strncpy(opts->ascii_disc_label, label, ISO_DISC_LABEL_SIZE - 1);
|
||||
@ -4118,6 +4244,16 @@ int iso_write_opts_set_hfsp_block_size(IsoWriteOpts *opts,
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
int iso_write_opts_set_gpt_guid(IsoWriteOpts *opts, uint8_t guid[16], int mode)
|
||||
{
|
||||
if (mode < 0 || mode > 2)
|
||||
return ISO_BAD_GPT_GUID_MODE;
|
||||
opts->gpt_disk_guid_mode = mode;
|
||||
if (opts->gpt_disk_guid_mode == 1)
|
||||
memcpy(opts->gpt_disk_guid, guid, 16);
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param flag
|
||||
|
@ -59,7 +59,7 @@
|
||||
#define ISO_DISC_LABEL_SIZE 129
|
||||
|
||||
|
||||
/* The maximum lenght of an specs violating ECMA-119 file identifier.
|
||||
/* The maximum length of an specs violating ECMA-119 file identifier.
|
||||
The theoretical limit is 254 - 34 - 28 (len of SUSP CE entry) = 192
|
||||
Currently the practical limit is 254 - 34 - 96 (non-CE RR entries) - 28 (CE)
|
||||
*/
|
||||
@ -223,7 +223,7 @@ struct iso_write_opts {
|
||||
/**
|
||||
* Write AAIP as extension according to SUSP 1.10 rather than SUSP 1.12.
|
||||
* I.e. without announcing it by an ER field and thus without the need
|
||||
* to preceed the RRIP fields by an ES and to preceed the AA field by ES.
|
||||
* to precede the RRIP fields by an ES and to precede the AA field by ES.
|
||||
* This saves bytes and might avoid problems with readers which dislike
|
||||
* ER fields other than the ones for RRIP.
|
||||
* On the other hand, SUSP 1.12 frowns on such unannounced extensions
|
||||
@ -487,6 +487,15 @@ struct iso_write_opts {
|
||||
*/
|
||||
int appended_as_gpt;
|
||||
|
||||
/* If 1: With appended partitions: mark by APM partition
|
||||
*/
|
||||
int appended_as_apm;
|
||||
|
||||
/* If 1: Obey struct el_torito_boot_image.isolinux_options bit2-7 and bit8.
|
||||
I.e. mention boot image as partition in GPT and/or APM.
|
||||
*/
|
||||
int part_like_isohybrid;
|
||||
|
||||
/* Eventual name of the non-ISO aspect of the image. E.g. SUN ASCII label.
|
||||
*/
|
||||
char ascii_disc_label[ISO_DISC_LABEL_SIZE];
|
||||
@ -504,6 +513,13 @@ struct iso_write_opts {
|
||||
*/
|
||||
int apm_block_size;
|
||||
|
||||
/* User defined GUID for GPT header and base of reproducible partition
|
||||
GUIDs. (Not to be confused with volume "UUID", which is actually a
|
||||
timestamp.)
|
||||
See API call iso_write_opts_set_gpt_guid().
|
||||
*/
|
||||
uint8_t gpt_disk_guid[16];
|
||||
int gpt_disk_guid_mode;
|
||||
};
|
||||
|
||||
typedef struct ecma119_image Ecma119Image;
|
||||
@ -554,10 +570,19 @@ struct ecma119_image
|
||||
|
||||
time_t now; /**< Time at which writing began. */
|
||||
|
||||
/** Total size of the output. This only includes the current volume. */
|
||||
/* Total size of the output. Counted in bytes.
|
||||
* Includes ISO filesystem and appended data.
|
||||
*/
|
||||
off_t total_size;
|
||||
|
||||
/** Size actually governed by the ISO filesystem part of the output */
|
||||
uint32_t vol_space_size;
|
||||
|
||||
/* 1= write the total size into the PVD of the ISO,
|
||||
* 0= write vol_space_size
|
||||
*/
|
||||
int pvd_size_is_total_size;
|
||||
|
||||
/* Bytes already written to image output */
|
||||
off_t bytes_written;
|
||||
/* just for progress notification */
|
||||
@ -640,6 +665,11 @@ struct ecma119_image
|
||||
int num_bootsrc;
|
||||
IsoFileSrc **bootsrc; /* location of the boot images in the new image */
|
||||
|
||||
int *boot_appended_idx; /* Appended partition which serve as boot images */
|
||||
|
||||
uint32_t *boot_intvl_start; /* In blocks of 2048 bytes */
|
||||
uint32_t *boot_intvl_size; /* In blocks of 512 bytes */
|
||||
|
||||
/*
|
||||
* System Area related information
|
||||
*/
|
||||
@ -821,6 +851,11 @@ struct ecma119_image
|
||||
/* Whether the eventual backup GPT is not part of the ISO filesystem */
|
||||
int gpt_backup_outside;
|
||||
|
||||
/* The base UUID for the generated GPT UUIDs */
|
||||
uint8_t gpt_uuid_base[16];
|
||||
/* The counter which distinguishes the GPT UUIDs */
|
||||
uint32_t gpt_uuid_counter;
|
||||
|
||||
uint32_t efi_boot_part_size;
|
||||
IsoFileSrc *efi_boot_part_filesrc; /* Just a pointer. Do not free. */
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2009 - 2014 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -241,11 +241,11 @@ int create_file_src(Ecma119Image *img, IsoFile *iso, IsoFileSrc **src)
|
||||
size = iso_stream_get_size(iso->stream);
|
||||
if (size > (off_t)MAX_ISO_FILE_SECTION_SIZE && img->opts->iso_level != 3) {
|
||||
char *ipath = iso_tree_get_node_path(ISO_NODE(iso));
|
||||
ret = iso_msg_submit(img->image->id, ISO_FILE_TOO_BIG, 0,
|
||||
"File \"%s\" can't be added to image because "
|
||||
"is greater than 4GB", ipath);
|
||||
iso_msg_submit(img->image->id, ISO_FILE_TOO_BIG, 0,
|
||||
"File \"%s\" cannot be added to image because "
|
||||
"its size is 4 GiB or larger", ipath);
|
||||
free(ipath);
|
||||
return ret;
|
||||
return ISO_FILE_TOO_BIG;
|
||||
}
|
||||
ret = iso_file_src_create(img, iso, src);
|
||||
if (ret < 0) {
|
||||
@ -597,7 +597,7 @@ int cmp_node_name(const void *f1, const void *f2)
|
||||
|
||||
/**
|
||||
* Sorts a the children of each directory in the ECMA-119 tree represented
|
||||
* by \p root, acording to the order specified in ECMA-119, section 9.3.
|
||||
* by \p root, according to the order specified in ECMA-119, section 9.3.
|
||||
*/
|
||||
static
|
||||
void sort_tree(Ecma119Node *root)
|
||||
@ -1270,7 +1270,7 @@ int ecma119_tree_create(Ecma119Image *img)
|
||||
|
||||
if (img->opts->rockridge && !img->opts->allow_deep_paths) {
|
||||
|
||||
/* Relocate deep directories, acording to RRIP, 4.1.5 */
|
||||
/* Relocate deep directories, according to RRIP, 4.1.5 */
|
||||
ret = reorder_tree(img, root, 1, 0);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2010 - 2014 Thomas Schmitt
|
||||
* Copyright (c) 2010 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -19,6 +19,7 @@
|
||||
#include "image.h"
|
||||
#include "messages.h"
|
||||
#include "writer.h"
|
||||
#include "ecma119.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -289,7 +290,7 @@ int iso_tree_add_boot_node(IsoDir *parent, const char *name, IsoBoot **boot)
|
||||
node->size = 0;
|
||||
node->content = NULL;
|
||||
|
||||
/* atributes from parent */
|
||||
/* attributes from parent */
|
||||
node->node.mode = S_IFREG | (parent->node.mode & 0444);
|
||||
node->node.uid = parent->node.uid;
|
||||
node->node.gid = parent->node.gid;
|
||||
@ -312,6 +313,35 @@ int iso_tree_add_boot_node(IsoDir *parent, const char *name, IsoBoot **boot)
|
||||
return ++parent->nchildren;
|
||||
}
|
||||
|
||||
/* Get start and size from "%d_start_%lus_size_%lud" */
|
||||
static
|
||||
void iso_parse_start_size(char *text, unsigned long *part_start,
|
||||
unsigned long *part_size)
|
||||
{
|
||||
char *cpt;
|
||||
unsigned long start, size;
|
||||
|
||||
cpt = strchr(text, '_');
|
||||
if (cpt == NULL)
|
||||
return;
|
||||
if (strncmp(cpt, "_start_", 7) != 0)
|
||||
return;
|
||||
sscanf(cpt + 7, "%lu", &start);
|
||||
cpt = strchr(cpt + 7, '_');
|
||||
if (cpt == NULL)
|
||||
return;
|
||||
if (*(cpt - 1) != 's')
|
||||
return;
|
||||
if (strncmp(cpt, "_size_", 6) != 0)
|
||||
return;
|
||||
sscanf(cpt + 6, "%lu", &size);
|
||||
for (cpt = cpt + 6; *cpt >= '0' && *cpt <= '9'; cpt++);
|
||||
if (*cpt != 'd')
|
||||
return;
|
||||
|
||||
*part_start = start;
|
||||
*part_size = size;
|
||||
}
|
||||
|
||||
static
|
||||
int create_image(IsoImage *image, const char *image_path,
|
||||
@ -323,36 +353,64 @@ int create_image(IsoImage *image, const char *image_path,
|
||||
struct el_torito_boot_image *boot;
|
||||
int boot_media_type = 0;
|
||||
int load_sectors = 0; /* number of sector to load */
|
||||
int part_idx = -1;
|
||||
unsigned long part_start = 0, part_size = 0;
|
||||
unsigned char partition_type = 0;
|
||||
off_t size;
|
||||
IsoNode *imgfile;
|
||||
IsoStream *stream;
|
||||
IsoNode *imgfile = NULL;
|
||||
IsoStream *stream = NULL;
|
||||
|
||||
*bootnode = NULL;
|
||||
ret = iso_tree_path_to_node(image, image_path, &imgfile);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (ret == 0) {
|
||||
iso_msg_submit(image->id, ISO_NODE_DOESNT_EXIST, 0,
|
||||
|
||||
if (strncmp(image_path, "--interval:appended_partition_", 30) == 0) {
|
||||
/* --interval:appended_partition_N... */
|
||||
if (type != ELTORITO_NO_EMUL) {
|
||||
|
||||
/* >>> ??? lift this ban by making a temporary IsoStream from
|
||||
partition source, determine size,
|
||||
and read ELTORITO_HARD_DISC_EMUL MBR ?
|
||||
*/
|
||||
|
||||
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Appended partition cannot serve as El Torito boot image with FD/HD emulation");
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
sscanf(image_path + 30, "%d", &part_idx);
|
||||
if (part_idx < 1 || part_idx > ISO_MAX_PARTITIONS) {
|
||||
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Appended partition index for El Torito boot image is out of range");
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
iso_parse_start_size((char *) (image_path + 30),
|
||||
&part_start, &part_size);
|
||||
part_idx--;
|
||||
size = 1;
|
||||
} else {
|
||||
ret = iso_tree_path_to_node(image, image_path, &imgfile);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (ret == 0) {
|
||||
iso_msg_submit(image->id, ISO_NODE_DOESNT_EXIST, 0,
|
||||
"El Torito boot image file missing in ISO image: '%s'",
|
||||
image_path);
|
||||
return ISO_NODE_DOESNT_EXIST;
|
||||
return ISO_NODE_DOESNT_EXIST;
|
||||
}
|
||||
|
||||
if (imgfile->type != LIBISO_FILE) {
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
*bootnode = (IsoFile *) imgfile;
|
||||
|
||||
stream = ((IsoFile*)imgfile)->stream;
|
||||
|
||||
/* we need to read the image at least two times */
|
||||
if (!iso_stream_is_repeatable(stream)) {
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
|
||||
size = iso_stream_get_size(stream);
|
||||
}
|
||||
|
||||
if (imgfile->type != LIBISO_FILE) {
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
*bootnode = (IsoFile *) imgfile;
|
||||
|
||||
stream = ((IsoFile*)imgfile)->stream;
|
||||
|
||||
/* we need to read the image at least two times */
|
||||
if (!iso_stream_is_repeatable(stream)) {
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
|
||||
size = iso_stream_get_size(stream);
|
||||
if (size <= 0) {
|
||||
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Boot image file is empty");
|
||||
@ -441,7 +499,11 @@ int create_image(IsoImage *image, const char *image_path,
|
||||
return ISO_OUT_OF_MEM;
|
||||
}
|
||||
boot->image = (IsoFile*)imgfile;
|
||||
iso_node_ref(imgfile); /* get our ref */
|
||||
boot->appended_idx = part_idx;
|
||||
boot->appended_start = part_start;
|
||||
boot->appended_size = part_size;
|
||||
if (imgfile != NULL)
|
||||
iso_node_ref(imgfile); /* get our ref */
|
||||
boot->bootable = 1;
|
||||
boot->seems_boot_info_table = 0;
|
||||
boot->seems_grub2_boot_info = 0;
|
||||
@ -538,8 +600,9 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
|
||||
catalog->bootimages[i] = NULL;
|
||||
catalog->node = cat_node;
|
||||
catalog->sort_weight = 1000000000; /* very high */
|
||||
if (!(boot_node->explicit_weight || boot_node->from_old_session))
|
||||
boot_node->sort_weight = 2;
|
||||
if (boot_node != NULL)
|
||||
if (!(boot_node->explicit_weight || boot_node->from_old_session))
|
||||
boot_node->sort_weight = 2;
|
||||
iso_node_ref((IsoNode*)cat_node);
|
||||
image->bootcat = catalog;
|
||||
|
||||
@ -555,7 +618,8 @@ boot_image_cleanup:;
|
||||
iso_node_unref((IsoNode*)cat_node);
|
||||
}
|
||||
if (boot_image) {
|
||||
iso_node_unref((IsoNode*)boot_image->image);
|
||||
if (boot_image->image != NULL)
|
||||
iso_node_unref((IsoNode*)boot_image->image);
|
||||
free(boot_image);
|
||||
}
|
||||
return ret;
|
||||
@ -719,8 +783,9 @@ int iso_image_add_boot_image(IsoImage *image, const char *image_path,
|
||||
ret = create_image(image, image_path, type, &boot_img, &boot_node);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!(boot_node->explicit_weight || boot_node->from_old_session))
|
||||
boot_node->sort_weight = 2;
|
||||
if (boot_node != NULL)
|
||||
if (!(boot_node->explicit_weight || boot_node->from_old_session))
|
||||
boot_node->sort_weight = 2;
|
||||
catalog->bootimages[catalog->num_bootimages] = boot_img;
|
||||
catalog->num_bootimages++;
|
||||
if (boot != NULL)
|
||||
@ -827,12 +892,13 @@ write_section_header(uint8_t *buf, Ecma119Image *t, int idx, int num_entries)
|
||||
* Usable for the Default Entry
|
||||
* and for Section Entries with Selection criteria type == 0
|
||||
*/
|
||||
static void
|
||||
write_section_entry(uint8_t *buf, Ecma119Image *t, int idx)
|
||||
static
|
||||
int write_section_entry(uint8_t *buf, Ecma119Image *t, int idx)
|
||||
{
|
||||
struct el_torito_boot_image *img;
|
||||
struct el_torito_section_entry *se =
|
||||
(struct el_torito_section_entry*)buf;
|
||||
int app_idx, mode = 0;
|
||||
|
||||
img = t->catalog->bootimages[idx];
|
||||
|
||||
@ -840,16 +906,69 @@ write_section_entry(uint8_t *buf, Ecma119Image *t, int idx)
|
||||
se->boot_media_type[0] = img->type;
|
||||
iso_lsb(se->load_seg, img->load_seg, 2);
|
||||
se->system_type[0] = img->partition_type;
|
||||
iso_lsb(se->sec_count, img->load_size, 2);
|
||||
iso_lsb(se->block, t->bootsrc[idx]->sections[0].block, 4);
|
||||
|
||||
if (t->boot_appended_idx[idx] >= 0)
|
||||
if (t->appended_part_size[t->boot_appended_idx[idx]] > 0)
|
||||
mode = 2; /* appended partition */
|
||||
if (mode == 0 && t->opts->appendable &&
|
||||
(t->boot_intvl_start[idx] > 0 || t->boot_intvl_size[idx] > 0) &&
|
||||
t->boot_intvl_start[idx] + (t->boot_intvl_size[idx] + 3) / 4 <=
|
||||
t->opts->ms_block)
|
||||
mode = 1; /* image interval */
|
||||
if (mode == 0 && t->boot_appended_idx[idx] >= 0) {
|
||||
iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Appended partition which shall serve as boot image does not exist");
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
|
||||
if (mode == 1) {
|
||||
if (t->boot_intvl_start[idx] + (t->boot_intvl_size[idx] + 3) / 4 >
|
||||
t->total_size / 2048 + t->opts->ms_block - t->eff_partition_offset
|
||||
) {
|
||||
iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Block interval which shall serve as boot image is outside result range");
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
|
||||
if (t->boot_intvl_size[idx] > 65535) {
|
||||
if (img->platform_id == 0xef)
|
||||
iso_lsb(se->sec_count, 0, 2);
|
||||
else
|
||||
iso_lsb(se->sec_count, 65535, 2);
|
||||
} else {
|
||||
if (t->boot_intvl_size[idx] == 0) {
|
||||
iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Block interval which shall serve as boot image has zero size");
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
}
|
||||
iso_lsb(se->sec_count, t->boot_intvl_size[idx], 2);
|
||||
}
|
||||
iso_lsb(se->block, t->boot_intvl_start[idx], 4);
|
||||
} else if (mode == 2) {
|
||||
app_idx = t->boot_appended_idx[idx];
|
||||
if (t->appended_part_size[app_idx] * 4 > 65535) {
|
||||
if (img->platform_id == 0xef)
|
||||
iso_lsb(se->sec_count, 0, 2);
|
||||
else
|
||||
iso_lsb(se->sec_count, 65535, 2);
|
||||
} else {
|
||||
iso_lsb(se->sec_count, t->appended_part_size[app_idx] * 4, 2);
|
||||
}
|
||||
iso_lsb(se->block, t->appended_part_start[app_idx], 4);
|
||||
} else {
|
||||
iso_lsb(se->sec_count, img->load_size, 2);
|
||||
iso_lsb(se->block, t->bootsrc[idx]->sections[0].block, 4);
|
||||
}
|
||||
|
||||
se->selec_criteria[0] = img->selection_crit[0];
|
||||
memcpy(se->vendor_sc, img->selection_crit + 1, 19);
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
int catalog_open(IsoStream *stream)
|
||||
{
|
||||
int i, j, k, num_entries;
|
||||
int i, j, k, num_entries, ret;
|
||||
struct catalog_stream *data;
|
||||
uint8_t *wpt;
|
||||
struct el_torito_boot_catalog *cat;
|
||||
@ -873,7 +992,9 @@ int catalog_open(IsoStream *stream)
|
||||
boots[0]->platform_id, boots[0]->id_string);
|
||||
|
||||
/* write default entry = first boot image */
|
||||
write_section_entry(data->buffer + 32, data->target, 0);
|
||||
ret = write_section_entry(data->buffer + 32, data->target, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* IMPORTANT: The maximum number of boot images must fit into BLOCK_SIZE */
|
||||
wpt = data->buffer + 64;
|
||||
@ -894,7 +1015,9 @@ int catalog_open(IsoStream *stream)
|
||||
write_section_header(wpt, data->target, i, num_entries);
|
||||
wpt += 32;
|
||||
for (j = 0; j < num_entries; j++) {
|
||||
write_section_entry(wpt, data->target, i);
|
||||
ret = write_section_entry(wpt, data->target, i);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
wpt += 32;
|
||||
i++;
|
||||
}
|
||||
@ -1132,6 +1255,9 @@ int patch_boot_info_table(uint8_t *buf, Ecma119Image *t,
|
||||
return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, 0,
|
||||
"Isolinux image too small. We won't patch it.");
|
||||
}
|
||||
if (t->bootsrc[idx] == NULL)
|
||||
return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, 0,
|
||||
"Cannot apply ISOLINUX patching outside of ISO 9660 filesystem.");
|
||||
ret = make_boot_info_table(buf, t->opts->ms_block + (uint32_t) 16,
|
||||
t->bootsrc[idx]->sections[0].block,
|
||||
(uint32_t) imgsize);
|
||||
@ -1151,7 +1277,10 @@ int patch_grub2_boot_image(uint8_t *buf, Ecma119Image *t,
|
||||
|
||||
if (imgsize < pos + 8)
|
||||
return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, 0,
|
||||
"Isolinux image too small for GRUB2. Will not patch it.");
|
||||
"Boot image too small for GRUB2. Will not patch it.");
|
||||
if (t->bootsrc[idx] == NULL)
|
||||
return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, 0,
|
||||
"Cannot apply GRUB2 patching outside of ISO 9660 filesystem.");
|
||||
blk = ((uint64_t) t->bootsrc[idx]->sections[0].block) * 4 + offst;
|
||||
iso_lsb((buf + pos), blk & 0xffffffff, 4);
|
||||
iso_lsb((buf + pos + 4), blk >> 32, 4);
|
||||
@ -1174,6 +1303,10 @@ int iso_patch_eltoritos(Ecma119Image *t)
|
||||
for (idx = 0; idx < t->catalog->num_bootimages; idx++) {
|
||||
if (!(t->catalog->bootimages[idx]->isolinux_options & 0x201))
|
||||
continue;
|
||||
if (t->bootsrc[idx] == NULL)
|
||||
return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, 0,
|
||||
"Cannot apply boot image patching outside of ISO 9660 filesystem");
|
||||
|
||||
original = t->bootsrc[idx]->stream;
|
||||
size = (size_t) iso_stream_get_size(original);
|
||||
if (size > Libisofs_elto_max_patchablE)
|
||||
@ -1281,8 +1414,8 @@ int eltorito_writer_create(Ecma119Image *target)
|
||||
{
|
||||
int ret, idx, outsource_efi = 0;
|
||||
IsoImageWriter *writer;
|
||||
IsoFile *bootimg;
|
||||
IsoFileSrc *src;
|
||||
IsoFile *bootimg = NULL;
|
||||
IsoFileSrc *src = NULL;
|
||||
|
||||
writer = calloc(1, sizeof(IsoImageWriter));
|
||||
if (writer == NULL) {
|
||||
@ -1315,6 +1448,23 @@ int eltorito_writer_create(Ecma119Image *target)
|
||||
if (strcmp(target->opts->efi_boot_partition, "--efi-boot-image") == 0)
|
||||
outsource_efi = 1;
|
||||
for (idx = 0; idx < target->catalog->num_bootimages; idx++) {
|
||||
target->bootsrc[idx] = NULL;
|
||||
if (target->catalog->bootimages[idx]->appended_idx >= 0) {
|
||||
/* Use an appended partition as boot image rather than IsoFile */
|
||||
target->boot_appended_idx[idx] =
|
||||
target->catalog->bootimages[idx]->appended_idx;
|
||||
target->boot_intvl_start[idx] =
|
||||
target->catalog->bootimages[idx]->appended_start;
|
||||
target->boot_intvl_size[idx] =
|
||||
target->catalog->bootimages[idx]->appended_size;
|
||||
if (((target->system_area_options >> 2) & 0x3f) == 0 &&
|
||||
(target->system_area_options & 3) == 1) {
|
||||
/* ISO will not be a partition. It can span the whole image. */
|
||||
target->pvd_size_is_total_size = 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
bootimg = target->catalog->bootimages[idx]->image;
|
||||
ret = iso_file_src_create(target, bootimg, &src);
|
||||
if (ret < 0) {
|
||||
|
@ -53,6 +53,11 @@ struct el_torito_boot_catalog {
|
||||
struct el_torito_boot_image {
|
||||
IsoFile *image;
|
||||
|
||||
/* Overrides .image if >= 0 : array index of appended partition */
|
||||
int appended_idx;
|
||||
uint32_t appended_start; /* In blocks of 2048 bytes */
|
||||
uint32_t appended_size; /* In blocks of 512 bytes */
|
||||
|
||||
unsigned int bootable:1; /**< If the entry is bootable. */
|
||||
/**
|
||||
* Whether the boot image seems to contain a boot_info_table
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2009 - 2015 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -364,7 +364,7 @@ typedef struct
|
||||
*/
|
||||
int px_ino_status;
|
||||
|
||||
/* Which Rock Ridge error messages already have occured
|
||||
/* Which Rock Ridge error messages already have occurred
|
||||
bit0= Invalid PX entry
|
||||
bit1= Invalid TF entry
|
||||
bit2= New NM entry found without previous CONTINUE flag
|
||||
@ -3598,7 +3598,7 @@ int iso_image_eval_boot_info_table(IsoImage *image, struct iso_read_opts *opts,
|
||||
boot_pvd_found = iso_read_lsb(boot_info_found, 4);
|
||||
image_pvd = (uint32_t) (opts->block + 16);
|
||||
|
||||
/* Accomodate to eventually relocated superblock */
|
||||
/* Accommodate to eventually relocated superblock */
|
||||
if (image_pvd != boot_pvd_found &&
|
||||
image_pvd == 16 && boot_pvd_found < iso_image_size) {
|
||||
/* Check whether there is a PVD at boot_pvd_found
|
||||
@ -3940,6 +3940,7 @@ int iso_analyze_mbr(IsoImage *image, IsoDataSource *src, int flag)
|
||||
{
|
||||
int sub_type = 2, ret, is_isohybrid = 0, is_grub2_mbr = 0;
|
||||
int is_protective_label = 0;
|
||||
uint64_t part2_start;
|
||||
char *sad;
|
||||
struct iso_imported_sys_area *sai;
|
||||
struct iso_mbr_partition_request *part;
|
||||
@ -3963,34 +3964,11 @@ int iso_analyze_mbr(IsoImage *image, IsoDataSource *src, int flag)
|
||||
sub_type = 0;
|
||||
is_isohybrid = 1;
|
||||
} else if(ret == 2) {
|
||||
sub_type = 0;
|
||||
/* will become sub_type 0 if protective_label */
|
||||
is_grub2_mbr = 1;
|
||||
}
|
||||
|
||||
if (sai->mbr_req_count == 1 && !is_isohybrid) {
|
||||
part = sai->mbr_req[0];
|
||||
if (part->start_block == 1 &&
|
||||
part->block_count + 1 == ((uint64_t) sai->image_size) * 4) {
|
||||
/* libisofs protective msdos label for GRUB2 */
|
||||
is_protective_label = 1;
|
||||
sub_type = 0;
|
||||
} else if (part->start_block == 0 &&
|
||||
part->block_count <= ((uint64_t) sai->image_size) * 4 &&
|
||||
part->block_count + 600 >= ((uint64_t) sai->image_size) * 4 &&
|
||||
part->type_byte == 0x96) {
|
||||
/* CHRP (possibly without padding) */
|
||||
sub_type = 1;
|
||||
} else if (sai->mbr_req[0]->start_block > 0 &&
|
||||
(sai->mbr_req[0]->start_block % 4) == 0 &&
|
||||
(sai->mbr_req[0]->start_block +
|
||||
sai->mbr_req[0]->block_count) / 4 <= sai->image_size &&
|
||||
part->type_byte == 0x41) {
|
||||
/* mkisofs PReP partition */
|
||||
sai->prep_part_start = sai->mbr_req[0]->start_block / 4;
|
||||
sai->prep_part_size = (sai->mbr_req[0]->block_count + 3) / 4;
|
||||
sub_type = 0;
|
||||
}
|
||||
} else if (sai->mbr_req_count == 3 && !is_isohybrid) {
|
||||
if (sai->mbr_req_count == 3 && !is_isohybrid) {
|
||||
/* Check for libisofs PReP partitions :
|
||||
0xee or 0xcd from 0 to a-1
|
||||
0x41 from a to b
|
||||
@ -4013,6 +3991,42 @@ int iso_analyze_mbr(IsoImage *image, IsoDataSource *src, int flag)
|
||||
sub_type = 0;
|
||||
}
|
||||
}
|
||||
if (sai->mbr_req_count >= 1 &&
|
||||
(sai->mbr_req[0]->type_byte == 0xee || !is_isohybrid) &&
|
||||
!(sai->prep_part_start > 0)) {
|
||||
part = sai->mbr_req[0];
|
||||
part2_start = 0;
|
||||
if (sai->mbr_req_count >= 2)
|
||||
part2_start = sai->mbr_req[1]->start_block;
|
||||
if (part->start_block == 1 &&
|
||||
(part->block_count + 1 == ((uint64_t) sai->image_size) * 4 ||
|
||||
(part->type_byte == 0xee &&
|
||||
part->block_count + 1 >= ((uint64_t) sai->image_size) * 4 &&
|
||||
(sai->mbr_req_count == 1 ||
|
||||
(sai->mbr_req_count == 2 &&
|
||||
sai->mbr_req[1]->type_byte == 0x00))) ||
|
||||
part->block_count + 1 == part2_start)) {
|
||||
/* libisofs protective msdos label for GRUB2 */
|
||||
is_protective_label = 1;
|
||||
sub_type = 0;
|
||||
} else if (sai->mbr_req_count == 1 && part->start_block == 0 &&
|
||||
part->block_count <= ((uint64_t) sai->image_size) * 4 &&
|
||||
part->block_count + 600 >= ((uint64_t) sai->image_size) * 4 &&
|
||||
part->type_byte == 0x96) {
|
||||
/* CHRP (possibly without padding) */
|
||||
sub_type = 1;
|
||||
} else if (sai->mbr_req_count == 1 &&
|
||||
sai->mbr_req[0]->start_block > 0 &&
|
||||
(sai->mbr_req[0]->start_block % 4) == 0 &&
|
||||
(sai->mbr_req[0]->start_block +
|
||||
sai->mbr_req[0]->block_count) / 4 <= sai->image_size &&
|
||||
part->type_byte == 0x41) {
|
||||
/* mkisofs PReP partition */
|
||||
sai->prep_part_start = sai->mbr_req[0]->start_block / 4;
|
||||
sai->prep_part_size = (sai->mbr_req[0]->block_count + 3) / 4;
|
||||
sub_type = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for partition offset with extra set of meta data */
|
||||
if (sai->mbr_req_count > 0) {
|
||||
@ -4572,7 +4586,8 @@ int iso_analyze_sun(IsoImage *image, IsoDataSource *src, int flag)
|
||||
iso_read_msb(usad + 144, 2) != 0x10 ||
|
||||
iso_read_msb(usad + 444, 4) != 0 ||
|
||||
sai->image_size > 0x3fffffff ||
|
||||
iso_read_msb(usad + 448, 4) != sai->image_size * 4)
|
||||
iso_read_msb(usad + 448, 4) < ((int64_t) sai->image_size * 4) - 600 ||
|
||||
iso_read_msb(usad + 448, 4) > sai->image_size * 4)
|
||||
return 0;
|
||||
checksum[0] = checksum[1] = 0;
|
||||
for (i = 0; i < 510; i += 2) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2009 - 2015 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -28,7 +28,7 @@
|
||||
* Create a new IsoFilesystem to deal with local filesystem.
|
||||
*
|
||||
* @return
|
||||
* 1 sucess, < 0 error
|
||||
* 1 success, < 0 error
|
||||
*/
|
||||
int iso_local_filesystem_new(IsoFilesystem **fs);
|
||||
|
||||
|
@ -405,7 +405,8 @@ int create_tree(Ecma119Image *t, IsoNode *iso, uint32_t parent_id)
|
||||
if (cret < 0)
|
||||
return cret;
|
||||
pos = pos->next;
|
||||
t->hfsp_leafs[cleaf].nchildren++;
|
||||
if (cret > 0)
|
||||
t->hfsp_leafs[cleaf].nchildren++;
|
||||
}
|
||||
}
|
||||
return ISO_SUCCESS;
|
||||
@ -1667,7 +1668,8 @@ int hfsplus_writer_create(Ecma119Image *target)
|
||||
goto ex;
|
||||
}
|
||||
pos = pos->next;
|
||||
target->hfsp_leafs[0].nchildren++;
|
||||
if (cret > 0)
|
||||
target->hfsp_leafs[0].nchildren++;
|
||||
}
|
||||
|
||||
qsort(target->hfsp_leafs, target->hfsp_nleafs,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2009 - 2015 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -31,7 +31,7 @@
|
||||
* Global objects such as the message_queues must belogn to that
|
||||
* context. Thus we will have, for example, a msg queue per image,
|
||||
* so images are completelly independent and can be managed together.
|
||||
* (Usefull, for example, in Multiple-Document-Interface GUI apps.
|
||||
* (Useful, for example, in Multiple-Document-Interface GUI apps.
|
||||
* [The stuff we have in init belongs really to image!]
|
||||
*/
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* libiso_msgs (generated from libdax_msgs : Fri Feb 22 19:42:52 CET 2008)
|
||||
Message handling facility of libisofs.
|
||||
Copyright (C) 2006 - 2008 Thomas Schmitt <scdbackup@gmx.net>,
|
||||
Copyright (C) 2006 - 2016 Thomas Schmitt <scdbackup@gmx.net>,
|
||||
provided under GPL version 2 or later
|
||||
*/
|
||||
|
||||
@ -33,14 +33,13 @@ static int libiso_msgs_item_new(struct libiso_msgs_item **item,
|
||||
int ret;
|
||||
struct libiso_msgs_item *o;
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
(*item)= o=
|
||||
(struct libiso_msgs_item *) malloc(sizeof(struct libiso_msgs_item));
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
o->timestamp= 0.0;
|
||||
ret= gettimeofday(&tv,&tz);
|
||||
ret= gettimeofday(&tv, NULL);
|
||||
if(ret==0)
|
||||
o->timestamp= tv.tv_sec+0.000001*tv.tv_usec;
|
||||
o->process_id= getpid();
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/* libiso_msgs (generated from libdax_msgs : Fri Feb 22 19:42:52 CET 2008)
|
||||
Message handling facility of libisofs.
|
||||
Copyright (C) 2006-2008 Thomas Schmitt <scdbackup@gmx.net>,
|
||||
Copyright (C) 2006-2016 Thomas Schmitt <scdbackup@gmx.net>,
|
||||
provided under GPL version 2 or later
|
||||
*/
|
||||
|
||||
@ -266,8 +266,9 @@ int libiso_msgs_new(struct libiso_msgs **m, int flag);
|
||||
|
||||
/** Destroy a message handling facility and all its eventual messages.
|
||||
The submitted pointer gets set to NULL.
|
||||
Actually only the last destroy call of all offical references to the object
|
||||
will really dispose it. All others just decrement the reference counter.
|
||||
Actually only the last destroy call of all official references to the
|
||||
object will really dispose it. All others just decrement the reference
|
||||
counter.
|
||||
Call this function only with official reference pointers obtained by
|
||||
libiso_msgs_new() or libiso_msgs_refer(), and only once per such pointer.
|
||||
@param flag Bitfield for control purposes (unused yet, submit 0)
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2008 Vreixo Formoso, Mario Danic
|
||||
* Copyright (c) 2009-2015 Thomas Schmitt
|
||||
* Copyright (c) 2009-2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -16,6 +16,10 @@
|
||||
libisofs/libisofs.ver
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
* Applications must use 64 bit off_t.
|
||||
@ -90,7 +94,7 @@
|
||||
*/
|
||||
#define iso_lib_header_version_major 1
|
||||
#define iso_lib_header_version_minor 4
|
||||
#define iso_lib_header_version_micro 2
|
||||
#define iso_lib_header_version_micro 6
|
||||
|
||||
/**
|
||||
* Get version of the libisofs library at runtime.
|
||||
@ -163,7 +167,7 @@ typedef struct Iso_Image IsoImage;
|
||||
* A node in the iso tree, i.e. a file that will be written to image.
|
||||
*
|
||||
* It can represent any kind of files. When needed, you can get the type with
|
||||
* iso_node_get_type() and cast it to the appropiate subtype. Useful macros
|
||||
* iso_node_get_type() and cast it to the appropriate subtype. Useful macros
|
||||
* are provided, see below.
|
||||
*
|
||||
* @since 0.6.2
|
||||
@ -1253,7 +1257,7 @@ char *iso_get_local_charset(int flag);
|
||||
* @param image
|
||||
* Location where the image pointer will be stored.
|
||||
* @return
|
||||
* 1 sucess, < 0 error
|
||||
* 1 success, < 0 error
|
||||
*
|
||||
* @since 0.6.2
|
||||
*/
|
||||
@ -1372,7 +1376,7 @@ int iso_write_opts_set_iso_level(IsoWriteOpts *opts, int level);
|
||||
* resulting image will have long filenames (up to 255 characters), deeper
|
||||
* directory structure, POSIX permissions and owner info on files and
|
||||
* directories, support for symbolic links or special files... All that
|
||||
* attributes can be modified/setted with the appropiate function.
|
||||
* attributes can be modified/set with the appropriate function.
|
||||
*
|
||||
* @param opts
|
||||
* The option set to be manipulated.
|
||||
@ -1481,7 +1485,7 @@ int iso_write_opts_set_hfsp_serial_number(IsoWriteOpts *opts,
|
||||
* @param hfsp_block_size
|
||||
* The allocation block size to be used by the HFS+ fileystem.
|
||||
* 0, 512, or 2048
|
||||
* @param hfsp_block_size
|
||||
* @param apm_block_size
|
||||
* The block size to be used for and within the Apple Partition Map.
|
||||
* 0, 512, or 2048.
|
||||
* Size 512 is not compatible with options which produce GPT.
|
||||
@ -1666,7 +1670,7 @@ int iso_write_opts_set_allow_deep_paths(IsoWriteOpts *opts, int allow);
|
||||
* The name given by this call will be compared with iso_node_get_name()
|
||||
* of the directories in the root directory, not with the final ECMA-119
|
||||
* names of those directories.
|
||||
* @parm flags
|
||||
* @param flags
|
||||
* Bitfield for control purposes.
|
||||
* bit0= Mark the relocation directory by a Rock Ridge RE entry, if it
|
||||
* gets created during iso_image_create_burn_source(). This will
|
||||
@ -1808,7 +1812,7 @@ int iso_write_opts_set_rrip_1_10_px_ino(IsoWriteOpts *opts, int enable);
|
||||
/**
|
||||
* Write AAIP as extension according to SUSP 1.10 rather than SUSP 1.12.
|
||||
* I.e. without announcing it by an ER field and thus without the need
|
||||
* to preceed the RRIP fields and the AAIP field by ES fields.
|
||||
* to precede the RRIP fields and the AAIP field by ES fields.
|
||||
* This saves 5 to 10 bytes per file and might avoid problems with readers
|
||||
* which dislike ER fields other than the ones for RRIP.
|
||||
* On the other hand, SUSP 1.12 frowns on such unannounced extensions
|
||||
@ -2215,8 +2219,10 @@ int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size);
|
||||
* @since 1.2.6
|
||||
* bit10-13= System area sub type
|
||||
* @since 1.2.4
|
||||
* With type 0 = MBR:
|
||||
* Gets overridden by bit0 and bit1.
|
||||
* With type 0:
|
||||
* if options bit0 ... MBR with partition start at block 1
|
||||
* if options bit1 ... ISOLINUX isohybrid MBR
|
||||
* else:
|
||||
* 0 = no particular sub type, use unaltered
|
||||
* 1 = CHRP: A single MBR partition of type 0x96 covers the
|
||||
* ISO image. Not compatible with any other feature
|
||||
@ -2228,8 +2234,12 @@ int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size);
|
||||
* Patch system area at byte 0x1b0 to 0x1b7 with
|
||||
* (512-block address + 4) of the first boot image file.
|
||||
* Little-endian 8-byte.
|
||||
* Should be combined with options bit0.
|
||||
* Is normally combined with options bit0.
|
||||
* Will not be in effect if options bit1 is set.
|
||||
* bit15= Only with System area type MBR but not with CHRP
|
||||
* Enforce MBR "bootable/active" flag. In worst case by dummy
|
||||
* partition of type 0x00 which occupies block 0.
|
||||
* @since 1.4.4
|
||||
* @param flag
|
||||
* bit0 = invalidate any attached system area data. Same as data == NULL
|
||||
* (This re-activates eventually loaded image System Area data.
|
||||
@ -2348,7 +2358,7 @@ int iso_write_opts_set_part_offset(IsoWriteOpts *opts,
|
||||
#define iso_libjte_req_micro 0
|
||||
|
||||
/**
|
||||
* Associate a libjte environment object to the upcomming write run.
|
||||
* Associate a libjte environment object to the upcoming write run.
|
||||
* libjte implements Jigdo Template Extraction as of Steve McIntyre and
|
||||
* Richard Atterer.
|
||||
* The call will fail if no libjte support was enabled at compile time.
|
||||
@ -2488,6 +2498,8 @@ int iso_interval_reader_new(IsoImage *img, char *path,
|
||||
*
|
||||
* @param ivr
|
||||
* The reader object to be disposed. *ivr will be set to NULL.
|
||||
* @param flag
|
||||
* Unused yet. Submit 0.
|
||||
* @return
|
||||
* ISO_SUCCESS or error (which is < 0)
|
||||
*
|
||||
@ -2505,7 +2517,7 @@ int iso_interval_reader_destroy(struct iso_interval_reader **ivr, int flag);
|
||||
* Pointer to memory for filling in at least 2048 bytes.
|
||||
* @param buf_fill
|
||||
* Will in case of success return the number of valid bytes.
|
||||
* If this is smaller than 2048, then end-of-interval has occured.
|
||||
* If this is smaller than 2048, then end-of-interval has occurred.
|
||||
* @param flag
|
||||
* Unused yet. Submit 0.
|
||||
* @return
|
||||
@ -2585,6 +2597,52 @@ int iso_write_opts_set_prep_img(IsoWriteOpts *opts, char *image_path,
|
||||
int iso_write_opts_set_efi_bootp(IsoWriteOpts *opts, char *image_path,
|
||||
int flag);
|
||||
|
||||
/**
|
||||
* Control whether the emerging GPT gets a pseudo-randomly generated disk GUID
|
||||
* or whether it gets a user supplied GUID.
|
||||
* The partition GUIDs will be generated in a reproducible way by exoring the
|
||||
* little-endian 32 bit partion number with the disk GUID beginning at byte
|
||||
* offset 9.
|
||||
*
|
||||
* @param opts
|
||||
* The option set to be manipulated.
|
||||
* @param guid
|
||||
* 16 bytes of user supplied GUID. Readily byte-swapped as prescribed by
|
||||
* UEFI specs: 4 byte, 2 byte, 2 byte as little-endian. The rest as
|
||||
* big-endian.
|
||||
* The upper 4 bit of guid[7] should bear the value 4 to express the
|
||||
* RFC 4122 version 4. Bit 7 of byte[8] should be set to 1 and bit 6
|
||||
* be set to 0, in order to express the RFC 4122 variant of UUID,
|
||||
* where version 4 means "pseudo-random uuid".
|
||||
* @param mode
|
||||
* 0 = ignore parameter guid and produce the GPT disk GUID by a
|
||||
* pseudo-random algorithm. This is the default setting.
|
||||
* 1 = use parameter guid as GPT disk GUID
|
||||
* 2 = ignore parameter guid and derive the GPT disk GUID from
|
||||
* parameter vol_uuid of iso_write_opts_set_pvd_times().
|
||||
* The 16 bytes of vol_uuid get copied and bytes 7, 8 get their
|
||||
* upper bits changed to comply to RFC 4122 and UEFI.
|
||||
* Error ISO_GPT_NO_VOL_UUID will occur if image production begins
|
||||
* before vol_uuid was set.
|
||||
*
|
||||
* @return
|
||||
* ISO_SUCCESS or ISO_BAD_GPT_GUID_MODE
|
||||
*
|
||||
* @since 1.4.6
|
||||
*/
|
||||
int iso_write_opts_set_gpt_guid(IsoWriteOpts *opts, uint8_t guid[16],
|
||||
int mode);
|
||||
|
||||
/**
|
||||
* Generate a pseudo-random GUID suitable for iso_write_opts_set_gpt_guid().
|
||||
*
|
||||
* @param guid
|
||||
* Will be filled by 16 bytes of generated GUID.
|
||||
*
|
||||
* @since 1.4.6
|
||||
*/
|
||||
void iso_generate_gpt_guid(uint8_t guid[16]);
|
||||
|
||||
/**
|
||||
* Cause an arbitrary data file to be appended to the ISO image and to be
|
||||
* described by a partition table entry in an MBR or SUN Disk Label at the
|
||||
@ -2603,15 +2661,15 @@ int iso_write_opts_set_efi_bootp(IsoWriteOpts *opts, char *image_path,
|
||||
* Range with MBR: 1 to 4. 1 will cause the whole ISO image to be
|
||||
* unclaimable space before partition 1.
|
||||
* Range with SUN Disk Label: 2 to 8.
|
||||
* @param partition_type
|
||||
* The MBR partition type. E.g. FAT12 = 0x01 , FAT16 = 0x06,
|
||||
* Linux Native Partition = 0x83. See fdisk command L.
|
||||
* This parameter is ignored with SUN Disk Label.
|
||||
* @param image_path
|
||||
* File address in the local file system or instructions for interval
|
||||
* reader. See flag bit0.
|
||||
* With SUN Disk Label: an empty name causes the partition to become
|
||||
* a copy of the next lower partition.
|
||||
* @param image_type
|
||||
* The MBR partition type. E.g. FAT12 = 0x01 , FAT16 = 0x06,
|
||||
* Linux Native Partition = 0x83. See fdisk command L.
|
||||
* This parameter is ignored with SUN Disk Label.
|
||||
* @param flag
|
||||
* bit0= The path contains instructions for the interval reader
|
||||
* See above.
|
||||
@ -2644,6 +2702,54 @@ int iso_write_opts_set_partition_img(IsoWriteOpts *opts, int partition_number,
|
||||
*/
|
||||
int iso_write_opts_set_appended_as_gpt(IsoWriteOpts *opts, int gpt);
|
||||
|
||||
/**
|
||||
* Control whether partitions created by iso_write_opts_set_partition_img()
|
||||
* are to be represented in Apple Partition Map.
|
||||
*
|
||||
* @param opts
|
||||
* The option set to be manipulated.
|
||||
* @param apm
|
||||
* 0= do not represent appended partitions in APM
|
||||
* 1= represent in APM, even if not
|
||||
* iso_write_opts_set_part_like_isohybrid() enables it and no
|
||||
* other APM partitions emerge.
|
||||
* @return
|
||||
* ISO_SUCCESS or error
|
||||
*
|
||||
* @since 1.4.4
|
||||
*/
|
||||
int iso_write_opts_set_appended_as_apm(IsoWriteOpts *opts, int apm);
|
||||
|
||||
/**
|
||||
* Control whether bits 2 to 8 of el_torito_set_isolinux_options()
|
||||
* shall apply even if not isohybrid MBR patching is enabled (bit1 of
|
||||
* parameter options of iso_write_opts_set_system_area()):
|
||||
* - Mentioning of El Torito boot images in GPT.
|
||||
* - Mentioning of El Torito boot images in APM.
|
||||
*
|
||||
* In this case some other behavior from isohybrid processing will apply too:
|
||||
* - No MBR partition of type 0xee emerges, even if GPT gets produced.
|
||||
* - Gaps between GPT and APM partitions will not be filled by more partitions.
|
||||
*
|
||||
* An extra feature towards isohybrid is enabled:
|
||||
* - Appended partitions get mentioned in APM if other APM partitions emerge.
|
||||
*
|
||||
* @param opts
|
||||
* The option set to be manipulated.
|
||||
* @param alike
|
||||
* 0= Apply the described behavior only with ISOLINUX isohybrid.
|
||||
* Do not mention appended partitions in APM unless
|
||||
* iso_write_opts_set_appended_as_apm() is enabled.
|
||||
* 1= Apply the described behavior even without ISOLINUX isohybrid.
|
||||
*
|
||||
* @return
|
||||
* ISO_SUCCESS or error
|
||||
*
|
||||
* @since 1.4.4
|
||||
*/
|
||||
int iso_write_opts_set_part_like_isohybrid(IsoWriteOpts *opts, int alike);
|
||||
|
||||
|
||||
/**
|
||||
* Inquire the start address of the file data blocks after having used
|
||||
* IsoWriteOpts with iso_image_create_burn_source().
|
||||
@ -3118,7 +3224,7 @@ void *iso_image_get_attached_data(IsoImage *image);
|
||||
* effect if both, the truncate mode value from "isofs.nt" and the current
|
||||
* truncate mode of the IsoImage are 1, and the length is between 64 and 255.
|
||||
*
|
||||
* @param image
|
||||
* @param img
|
||||
* The image which shall be manipulated.
|
||||
* @param mode
|
||||
* 0= Do not truncate but throw error ISO_RR_NAME_TOO_LONG if a file name
|
||||
@ -3142,7 +3248,7 @@ int iso_image_set_truncate_mode(IsoImage *img, int mode, int length);
|
||||
/**
|
||||
* Inquire the current setting of iso_image_set_truncate_mode().
|
||||
*
|
||||
* @param image
|
||||
* @param img
|
||||
* The image which shall be inquired.
|
||||
* @param mode
|
||||
* Returns the mode value.
|
||||
@ -3371,16 +3477,16 @@ const char *iso_image_get_app_use(IsoImage *image);
|
||||
*
|
||||
* @param image
|
||||
* The image to be inquired.
|
||||
* @param vol_creation_time
|
||||
* @param creation_time
|
||||
* Returns a pointer to the Volume Creation time:
|
||||
* When "the information in the volume was created."
|
||||
* @param vol_modification_time
|
||||
* @param modification_time
|
||||
* Returns a pointer to Volume Modification time:
|
||||
* When "the information in the volume was last modified."
|
||||
* @param vol_expiration_time
|
||||
* @param expiration_time
|
||||
* Returns a pointer to Volume Expiration time:
|
||||
* When "the information in the volume may be regarded as obsolete."
|
||||
* @param vol_effective_time
|
||||
* @param effective_time
|
||||
* Returns a pointer to Volume Expiration time:
|
||||
* When "the information in the volume may be used."
|
||||
* @return
|
||||
@ -3401,14 +3507,22 @@ int iso_image_get_pvd_times(IsoImage *image,
|
||||
* The image to make bootable. If it was already bootable this function
|
||||
* returns an error and the image remains unmodified.
|
||||
* @param image_path
|
||||
* The absolute path of a IsoFile to be used as default boot image.
|
||||
* The absolute path of a IsoFile to be used as default boot image or
|
||||
* --interval:appended_partition_$number[_start_$start_size_$size]:...
|
||||
* if type is ELTORITO_NO_EMUL. $number gives the partition number.
|
||||
* If _start_$start_size_$size is present, then it overrides the 2 KiB
|
||||
* start block of the partition and the partition size counted in
|
||||
* blocks of 512 bytes.
|
||||
* @param type
|
||||
* The boot media type. This can be one of 3 types:
|
||||
* - Floppy emulation: Boot image file must be exactly
|
||||
* 1200 kB, 1440 kB or 2880 kB.
|
||||
* - Hard disc emulation: The image must begin with a master
|
||||
* - ELTORITO_FLOPPY_EMUL.
|
||||
* Floppy emulation: Boot image file must be exactly
|
||||
* 1200 KiB, 1440 KiB or 2880 KiB.
|
||||
* - ELTORITO_HARD_DISC_EMUL.
|
||||
* Hard disc emulation: The image must begin with a master
|
||||
* boot record with a single image.
|
||||
* - No emulation. You should specify load segment and load size
|
||||
* - ELTORITO_NO_EMUL.
|
||||
* No emulation. You should specify load segment and load size
|
||||
* of image.
|
||||
* @param catalog_path
|
||||
* The absolute path in the image tree where the catalog will be stored.
|
||||
@ -3443,9 +3557,11 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path,
|
||||
* The image to which the boot image shall be added.
|
||||
* returns an error and the image remains unmodified.
|
||||
* @param image_path
|
||||
* The absolute path of a IsoFile to be used as default boot image.
|
||||
* The absolute path of a IsoFile to be used as boot image or
|
||||
* --interval:appended_partition_$number[_start_$start_size_$size]:...
|
||||
* if type is ELTORITO_NO_EMUL. See iso_image_set_boot_image.
|
||||
* @param type
|
||||
* The boot media type. See iso_image_set_boot_image
|
||||
* The boot media type. See iso_image_set_boot_image.
|
||||
* @param flag
|
||||
* Bitfield for control purposes. Unused yet. Submit 0.
|
||||
* @param boot
|
||||
@ -3488,6 +3604,7 @@ int iso_image_add_boot_image(IsoImage *image, const char *image_path,
|
||||
* @param imgnode
|
||||
* When not NULL, it will be filled with the image tree node. No extra ref
|
||||
* is added, you can use iso_node_ref() to get one if you need it.
|
||||
* The returned value is NULL if the boot image source is no IsoFile.
|
||||
* @param catnode
|
||||
* When not NULL, it will be filled with the catnode tree node. No extra
|
||||
* ref is added, you can use iso_node_ref() to get one if you need it.
|
||||
@ -3545,6 +3662,10 @@ int iso_image_get_bootcat(IsoImage *image, IsoBoot **catnode, uint32_t *lba,
|
||||
* @param bootnodes
|
||||
* Returns NULL or an allocated array of pointers to the IsoFile nodes
|
||||
* which bear the content of the boot images in boots.
|
||||
* An array entry is NULL if the boot image source is no IsoFile.
|
||||
|
||||
>>> Need getter for partition index
|
||||
|
||||
* @param flag
|
||||
* Bitfield for control purposes. Unused yet. Submit 0.
|
||||
* @return
|
||||
@ -3796,7 +3917,7 @@ int el_torito_set_selection_crit(ElToritoBootImage *bootimg, uint8_t crit[20]);
|
||||
*
|
||||
* @param bootimg
|
||||
* The image to inquire
|
||||
* @param id_string
|
||||
* @param crit
|
||||
* Returns 20 bytes of type and data
|
||||
* @return
|
||||
* 1 = ok , <0 = error
|
||||
@ -4166,7 +4287,7 @@ int iso_image_get_system_area(IsoImage *img, char data[32768],
|
||||
#define ISO_SYSAREA_REPORT_DOC_ALPHA \
|
||||
"If a DEC Alpha SRM boot sector is present:", \
|
||||
" DEC Alpha ldr size : decimal", \
|
||||
" tells the number of 512-byte blocks in DEC Alpha Secondary Bootstrap" \
|
||||
" tells the number of 512-byte blocks in DEC Alpha Secondary Bootstrap", \
|
||||
" Loader file.", \
|
||||
" DEC Alpha ldr adr : decimal", \
|
||||
" tells the start of the loader file in units of 512-byte blocks.", \
|
||||
@ -4183,7 +4304,7 @@ int iso_image_get_system_area(IsoImage *img, char data[32768],
|
||||
* Else it will consist of lines as described in ISO_SYSAREA_REPORT_DOC above.
|
||||
*
|
||||
* File paths and other long texts are reported as "(too long to show here)"
|
||||
* if their length plus preceeding text plus trailing 0-byte exceeds the
|
||||
* if their length plus preceding text plus trailing 0-byte exceeds the
|
||||
* line length limit of ISO_MAX_SYSAREA_LINE_LENGTH bytes.
|
||||
* Texts which may contain whitespace or unprintable characters will start
|
||||
* at fixed positions and extend to the end of the line.
|
||||
@ -4339,7 +4460,7 @@ uint32_t iso_crc32_gpt(unsigned char *data, int count, int flag);
|
||||
* the first added file gets into effect with this system area type.
|
||||
* The data files which shall serve as MIPS boot files have to be brought into
|
||||
* the image by the normal means.
|
||||
* @param img
|
||||
* @param image
|
||||
* The image to be manipulated.
|
||||
* @param path
|
||||
* Absolute path of the boot file in the ISO 9660 Rock Ridge tree.
|
||||
@ -4354,7 +4475,7 @@ int iso_image_add_mips_boot_file(IsoImage *image, char *path, int flag);
|
||||
/**
|
||||
* Obtain the number of added MIPS Big Endian boot files and pointers to
|
||||
* their paths in the ISO 9660 Rock Ridge tree.
|
||||
* @param img
|
||||
* @param image
|
||||
* The image to be inquired.
|
||||
* @param paths
|
||||
* An array of pointers to be set to the registered boot file paths.
|
||||
@ -4370,7 +4491,7 @@ int iso_image_get_mips_boot_files(IsoImage *image, char *paths[15], int flag);
|
||||
|
||||
/**
|
||||
* Clear the list of MIPS Big Endian boot file paths.
|
||||
* @param img
|
||||
* @param image
|
||||
* The image to be manipulated.
|
||||
* @param flag
|
||||
* Bitfield for control purposes, unused yet, submit 0
|
||||
@ -4498,7 +4619,7 @@ int iso_image_set_alpha_boot(IsoImage *img, char *boot_loader_path, int flag);
|
||||
*
|
||||
* @param img
|
||||
* The image to be inquired.
|
||||
* @param cmdline
|
||||
* @param boot_loader_path
|
||||
* Will return the path. NULL if none is currently submitted.
|
||||
* @return
|
||||
* 1 is success , <0 means error
|
||||
@ -5165,7 +5286,7 @@ int iso_dir_iter_take(IsoDirIter *iter);
|
||||
* The node removed will be the one returned by the previous iteration.
|
||||
*
|
||||
* It is not allowed to call this function twice without calling
|
||||
* iso_dir_iter_next inbetween.
|
||||
* iso_dir_iter_next between the calls.
|
||||
*
|
||||
* @return
|
||||
* 1 on succes, < 0 error
|
||||
@ -5184,8 +5305,9 @@ int iso_dir_iter_remove(IsoDirIter *iter);
|
||||
*
|
||||
* @param node
|
||||
* The node to be removed.
|
||||
* @param iter
|
||||
* If not NULL, then the node will be removed by iso_dir_iter_remove(iter)
|
||||
* @param boss_iter
|
||||
* If not NULL, then the node will be removed by
|
||||
* iso_dir_iter_remove(boss_iter)
|
||||
* else it will be removed by iso_node_remove(node).
|
||||
* @return
|
||||
* 1 is success, <0 indicates error
|
||||
@ -5389,10 +5511,10 @@ int iso_dir_find_children(IsoDir* dir, IsoFindCondition *cond,
|
||||
const char *iso_symlink_get_dest(const IsoSymlink *link);
|
||||
|
||||
/**
|
||||
* Set the destination of a link.
|
||||
* Set the destination of a symbolic
|
||||
*
|
||||
* @param opts
|
||||
* The option set to be manipulated
|
||||
* @param link
|
||||
* The link node to be manipulated
|
||||
* @param dest
|
||||
* New destination for the link. It must be a non-empty string, otherwise
|
||||
* this function doesn't modify previous destination.
|
||||
@ -5413,7 +5535,7 @@ int iso_symlink_set_dest(IsoSymlink *link, const char *dest);
|
||||
* or regular files, this function has no effect.
|
||||
* @param w
|
||||
* The weight as a integer number, the greater this value is, the
|
||||
* closer from the begining of image the file will be written.
|
||||
* closer from the beginning of image the file will be written.
|
||||
* Default value at IsoNode creation is 0.
|
||||
*
|
||||
* @since 0.6.2
|
||||
@ -5646,7 +5768,7 @@ int iso_tree_add_new_file(IsoDir *parent, const char *name, IsoStream *stream,
|
||||
*
|
||||
* @param buf
|
||||
* The dynamically allocated memory buffer with the stream content.
|
||||
* @parm size
|
||||
* @param size
|
||||
* The number of bytes which may be read from buf.
|
||||
* @param stream
|
||||
* Will return a reference to the newly created stream.
|
||||
@ -6167,7 +6289,7 @@ int iso_tree_clone(IsoNode *node,
|
||||
* Add the contents of a dir to a given directory of the iso tree.
|
||||
*
|
||||
* There are several options to control what files are added or how they are
|
||||
* managed. Take a look at iso_tree_set_* functions to see diferent options
|
||||
* managed. Take a look at iso_tree_set_* functions to see different options
|
||||
* for recursive directory addition.
|
||||
*
|
||||
* TODO comment Builder and Filesystem related issues when exposing both
|
||||
@ -6360,7 +6482,7 @@ int iso_set_msgs_severities(char *queue_severity, char *print_severity,
|
||||
* will discard the whole queue.
|
||||
*
|
||||
* @param minimum_severity
|
||||
* Threshhold
|
||||
* Threshold
|
||||
* @param error_code
|
||||
* Will become a unique error code as listed at the end of this header
|
||||
* @param imgid
|
||||
@ -6810,7 +6932,7 @@ void iso_filesystem_unref(IsoFilesystem *fs);
|
||||
* @param fs
|
||||
* Will be filled with a pointer to the filesystem that can be used
|
||||
* to access image contents.
|
||||
* @param
|
||||
* @return
|
||||
* 1 on success, < 0 on error
|
||||
*
|
||||
* @since 0.6.2
|
||||
@ -7188,7 +7310,7 @@ mode_t iso_node_get_perms_wo_acl(const IsoNode *node);
|
||||
* @param names
|
||||
* Will return an array of pointers to 0-terminated names
|
||||
* @param value_lengths
|
||||
* Will return an arry with the lenghts of values
|
||||
* Will return an array with the lengths of values
|
||||
* @param values
|
||||
* Will return an array of pointers to strings of 8-bit bytes
|
||||
* @param flag
|
||||
@ -7214,7 +7336,7 @@ int iso_node_get_attrs(IsoNode *node, size_t *num_attrs,
|
||||
* @param name
|
||||
* The xattr name that shall be looked up.
|
||||
* @param value_length
|
||||
* Will return the lenght of value
|
||||
* Will return the length of value
|
||||
* @param value
|
||||
* Will return a string of 8-bit bytes. free() it when no longer needed.
|
||||
* @param flag
|
||||
@ -7397,7 +7519,7 @@ int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag);
|
||||
* @param names
|
||||
* Will return an array of pointers to 0-terminated names
|
||||
* @param value_lengths
|
||||
* Will return an arry with the lenghts of values
|
||||
* Will return an array with the lengths of values
|
||||
* @param values
|
||||
* Will return an array of pointers to 8-bit values
|
||||
* @param flag
|
||||
@ -8097,7 +8219,7 @@ enum IsoHfsplusBlessings {
|
||||
* Issue a blessing to a particular IsoNode. If the blessing is already issued
|
||||
* to some file, then it gets revoked from that one.
|
||||
*
|
||||
* @param image
|
||||
* @param img
|
||||
* The image to manipulate.
|
||||
* @param blessing
|
||||
* The kind of blessing to be issued.
|
||||
@ -8131,7 +8253,7 @@ int iso_image_hfsplus_bless(IsoImage *img, enum IsoHfsplusBlessings blessing,
|
||||
*
|
||||
* Several usage restrictions apply. See parameter blessed_nodes.
|
||||
*
|
||||
* @param image
|
||||
* @param img
|
||||
* The image to inquire.
|
||||
* @param blessed_nodes
|
||||
* Will return a pointer to an internal node array of image.
|
||||
@ -8326,8 +8448,8 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *name, size_t name_len,
|
||||
/** File not supported in ECMA-119 tree and thus ignored (WARNING,MEDIUM, -139) */
|
||||
#define ISO_FILE_IGNORED 0xD020FF75
|
||||
|
||||
/* A file is bigger than supported by used standard (WARNING,MEDIUM, -140) */
|
||||
#define ISO_FILE_TOO_BIG 0xD020FF74
|
||||
/* A file is bigger than supported by used standard (FAILURE,HIGH, -140) */
|
||||
#define ISO_FILE_TOO_BIG 0xE830FF74
|
||||
|
||||
/* File read error during image creation (MISHAP,HIGH, -141) */
|
||||
#define ISO_FILE_CANT_WRITE 0xE430FF73
|
||||
@ -8715,6 +8837,15 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *name, size_t name_len,
|
||||
/** Unrecognized file type of IsoFileSrc object (SORRY, HIGH, -415) */
|
||||
#define ISO_BAD_FSRC_FILETYPE 0xE030FE61
|
||||
|
||||
/** Cannot derive GPT GUID from undefined pseudo-UUID volume timestamp
|
||||
(FAILURE, HIGH, -416) */
|
||||
#define ISO_GPT_NO_VOL_UUID 0xE830FE60
|
||||
|
||||
/** Unrecognized GPT disk GUID setup mode
|
||||
(FAILURE, HIGH, -417) */
|
||||
#define ISO_BAD_GPT_GUID_MODE 0xE830FE5F
|
||||
|
||||
|
||||
/* Internal developer note:
|
||||
Place new error codes directly above this comment.
|
||||
Newly introduced errors must get a message entry in
|
||||
@ -8724,16 +8855,16 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *name, size_t name_len,
|
||||
/* ! PLACE NEW ERROR CODES ABOVE. NOT AFTER THIS LINE ! */
|
||||
|
||||
|
||||
/** Read error occured with IsoDataSource (SORRY,HIGH, -513) */
|
||||
/** Read error occurred with IsoDataSource (SORRY,HIGH, -513) */
|
||||
#define ISO_DATA_SOURCE_SORRY 0xE030FCFF
|
||||
|
||||
/** Read error occured with IsoDataSource (MISHAP,HIGH, -513) */
|
||||
/** Read error occurred with IsoDataSource (MISHAP,HIGH, -513) */
|
||||
#define ISO_DATA_SOURCE_MISHAP 0xE430FCFF
|
||||
|
||||
/** Read error occured with IsoDataSource (FAILURE,HIGH, -513) */
|
||||
/** Read error occurred with IsoDataSource (FAILURE,HIGH, -513) */
|
||||
#define ISO_DATA_SOURCE_FAILURE 0xE830FCFF
|
||||
|
||||
/** Read error occured with IsoDataSource (FATAL,HIGH, -513) */
|
||||
/** Read error occurred with IsoDataSource (FATAL,HIGH, -513) */
|
||||
#define ISO_DATA_SOURCE_FATAL 0xF030FCFF
|
||||
|
||||
|
||||
@ -8911,4 +9042,8 @@ struct burn_source {
|
||||
#define Libisofs_with_rrip_rR yes
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LIBISO_LIBISOFS_H_*/
|
||||
|
@ -68,6 +68,7 @@ iso_filesystem_ref;
|
||||
iso_filesystem_unref;
|
||||
iso_finish;
|
||||
iso_fs_global_id;
|
||||
iso_generate_gpt_guid;
|
||||
iso_get_local_charset;
|
||||
iso_get_messenger;
|
||||
iso_gzip_get_refcounts;
|
||||
@ -308,6 +309,7 @@ iso_write_opts_set_allow_longer_paths;
|
||||
iso_write_opts_set_allow_lowercase;
|
||||
iso_write_opts_set_always_gmt;
|
||||
iso_write_opts_set_appendable;
|
||||
iso_write_opts_set_appended_as_apm;
|
||||
iso_write_opts_set_appended_as_gpt;
|
||||
iso_write_opts_set_default_dir_mode;
|
||||
iso_write_opts_set_default_file_mode;
|
||||
@ -319,6 +321,7 @@ iso_write_opts_set_disc_label;
|
||||
iso_write_opts_set_efi_bootp;
|
||||
iso_write_opts_set_fat;
|
||||
iso_write_opts_set_fifo_size;
|
||||
iso_write_opts_set_gpt_guid;
|
||||
iso_write_opts_set_hardlinks;
|
||||
iso_write_opts_set_hfsp_block_size;
|
||||
iso_write_opts_set_hfsp_serial_number;
|
||||
@ -337,6 +340,7 @@ iso_write_opts_set_omit_version_numbers;
|
||||
iso_write_opts_set_output_charset;
|
||||
iso_write_opts_set_overwrite_buf;
|
||||
iso_write_opts_set_part_offset;
|
||||
iso_write_opts_set_part_like_isohybrid;
|
||||
iso_write_opts_set_partition_img;
|
||||
iso_write_opts_set_prep_img;
|
||||
iso_write_opts_set_pvd_times;
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "ecma119.h"
|
||||
#include "eltorito.h"
|
||||
#include "system_area.h"
|
||||
#include "image.h"
|
||||
#include "messages.h"
|
||||
|
||||
|
||||
/* This code stems from syslinux-3.72/utils/isohybrid, a perl script
|
||||
@ -60,7 +62,7 @@ license from above stem licenses, typically from LGPL.
|
||||
In case its generosity is needed, here is the 2-clause BSD license:
|
||||
|
||||
make_isohybrid_mbr.c is copyright 2002-2008 H. Peter Anvin
|
||||
and 2008-2014 Thomas Schmitt
|
||||
and 2008-2015 Thomas Schmitt
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
@ -156,7 +158,6 @@ int make_isohybrid_mbr(int bin_lba, int *img_blocks, char *mbr, int flag)
|
||||
|
||||
/* For generating a weak random number */
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
if (bin_lba < 0 || bin_lba >= (1 << 29))
|
||||
return (0); /* 1 TB limit of signed 32 bit addressing of 512 byte blocks */
|
||||
@ -211,7 +212,7 @@ int make_isohybrid_mbr(int bin_lba, int *img_blocks, char *mbr, int flag)
|
||||
from. An environment variable ?
|
||||
125: Whatever, i use some 32-bit random value with no crypto strength.
|
||||
*/
|
||||
gettimeofday(&tv, &tz);
|
||||
gettimeofday(&tv, NULL);
|
||||
id = 0xffffffff & (tv.tv_sec ^ (tv.tv_usec * 2000));
|
||||
|
||||
/*
|
||||
@ -400,12 +401,15 @@ int lba512chs_to_buf(char **wpt, off_t lba, int head_count, int sector_count)
|
||||
|
||||
/* Find out whether GPT and APM are desired
|
||||
flag bit0 = register APM and GPT requests in Ecma119Image
|
||||
bit1 = do not asses and register APM
|
||||
bit2 = do not register overall GPT partition
|
||||
*/
|
||||
int assess_isohybrid_gpt_apm(Ecma119Image *t, int *gpt_count, int gpt_idx[128],
|
||||
int *apm_count, int flag)
|
||||
{
|
||||
int i, ilx_opts, j, ret, num_img;
|
||||
uint32_t block_count;
|
||||
uint64_t start_block;
|
||||
uint8_t gpt_name[72];
|
||||
static uint8_t zero_uuid[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
static uint8_t basic_data_uuid[16] = {
|
||||
@ -428,11 +432,13 @@ int assess_isohybrid_gpt_apm(Ecma119Image *t, int *gpt_count, int gpt_idx[128],
|
||||
num_img = 0;
|
||||
for (i = 0; i < num_img; i++) {
|
||||
ilx_opts = t->catalog->bootimages[i]->isolinux_options;
|
||||
if (((ilx_opts >> 2) & 63) == 1 || ((ilx_opts >> 2) & 63) == 2) {
|
||||
if ((((ilx_opts >> 2) & 63) == 1 || ((ilx_opts >> 2) & 63) == 2) &&
|
||||
!(t->boot_appended_idx[i] >= 0 && t->opts->appended_as_gpt)) {
|
||||
if (*gpt_count < 128)
|
||||
gpt_idx[*gpt_count]= i;
|
||||
gpt_idx[*gpt_count] = i;
|
||||
(*gpt_count)++;
|
||||
if ((flag & 1) && t->bootsrc[i] != NULL) {
|
||||
if ((flag & 1) &&
|
||||
(t->bootsrc[i] != NULL || t->boot_appended_idx[i] >= 0)) {
|
||||
/* Register GPT entry */
|
||||
memset(gpt_name, 0, 72);
|
||||
sprintf((char *) gpt_name, "ISOHybrid%d", *gpt_count);
|
||||
@ -441,27 +447,44 @@ int assess_isohybrid_gpt_apm(Ecma119Image *t, int *gpt_count, int gpt_idx[128],
|
||||
uuid = hfs_uuid;
|
||||
else
|
||||
uuid = basic_data_uuid;
|
||||
block_count = 0;
|
||||
for (j = 0; j < t->bootsrc[i]->nsections; j++)
|
||||
block_count += t->bootsrc[i]->sections[j].size / 2048;
|
||||
if (t->boot_appended_idx[i] >= 0) {
|
||||
block_count = t->appended_part_size[
|
||||
t->boot_appended_idx[i]];
|
||||
start_block = ((uint64_t) t->appended_part_start[
|
||||
t->boot_appended_idx[i]]) * 4;
|
||||
} else {
|
||||
block_count = 0;
|
||||
for (j = 0; j < t->bootsrc[i]->nsections; j++)
|
||||
block_count += t->bootsrc[i]->sections[j].size / 2048;
|
||||
start_block = ((uint64_t) t->bootsrc[i]->sections[0].block)
|
||||
* 4;
|
||||
}
|
||||
ret = iso_quick_gpt_entry(
|
||||
t->gpt_req, &(t->gpt_req_count),
|
||||
((uint64_t) t->bootsrc[i]->sections[0].block) * 4,
|
||||
((uint64_t) block_count) * 4,
|
||||
start_block, ((uint64_t) block_count) * 4,
|
||||
uuid, zero_uuid, gpt_flags, (uint8_t *) gpt_name);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (ilx_opts & 256) {
|
||||
if ((ilx_opts & 256) && !(flag & 2)) {
|
||||
(*apm_count)++;
|
||||
if ((flag & 1) && t->bootsrc[i] != NULL) {
|
||||
if ((flag & 1) &&
|
||||
(t->bootsrc[i] != NULL || t->boot_appended_idx[i] >= 0)) {
|
||||
/* Register APM entry */
|
||||
block_count = 0;
|
||||
for (j = 0; j < t->bootsrc[i]->nsections; j++)
|
||||
block_count += t->bootsrc[i]->sections[j].size / 2048;
|
||||
if (t->boot_appended_idx[i] >= 0) {
|
||||
block_count = t->appended_part_size[
|
||||
t->boot_appended_idx[i]];
|
||||
start_block = t->appended_part_start[
|
||||
t->boot_appended_idx[i]];
|
||||
} else {
|
||||
block_count = 0;
|
||||
for (j = 0; j < t->bootsrc[i]->nsections; j++)
|
||||
block_count += t->bootsrc[i]->sections[j].size / 2048;
|
||||
start_block = t->bootsrc[i]->sections[0].block;
|
||||
}
|
||||
ret = iso_quick_apm_entry(t->apm_req, &(t->apm_req_count),
|
||||
t->bootsrc[i]->sections[0].block,
|
||||
(uint32_t) start_block,
|
||||
block_count, "EFI", "Apple_HFS");
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@ -471,7 +494,12 @@ int assess_isohybrid_gpt_apm(Ecma119Image *t, int *gpt_count, int gpt_idx[128],
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((flag & 1) && *gpt_count > 0) {
|
||||
if (*gpt_count > 0 && !(flag & 4)) {
|
||||
(*gpt_count)++;
|
||||
if (*gpt_count < 128)
|
||||
gpt_idx[*gpt_count] = -1;
|
||||
}
|
||||
if ((flag & 1) && *gpt_count > 0 && !(flag & 4)) {
|
||||
/* Register overall GPT partition */
|
||||
memset(gpt_name, 0, 72);
|
||||
sprintf((char *) gpt_name, "ISOHybrid");
|
||||
@ -536,19 +564,28 @@ static int insert_apm_head(uint8_t *buf, int apm_count)
|
||||
static int gpt_images_as_mbr_partitions(Ecma119Image *t, char *wpt,
|
||||
int gpt_idx[128], int *gpt_cursor)
|
||||
{
|
||||
int ilx_opts;
|
||||
int ilx_opts, skip = 0;
|
||||
off_t hd_blocks;
|
||||
static uint8_t dummy_chs[3] = {
|
||||
0xfe, 0xff, 0xff,
|
||||
};
|
||||
|
||||
if (gpt_idx[*gpt_cursor] < 0)
|
||||
skip = 1;
|
||||
else if (t->bootsrc[gpt_idx[*gpt_cursor]] == NULL)
|
||||
skip = 1;
|
||||
if (skip) {
|
||||
(*gpt_cursor)++;
|
||||
return 2;
|
||||
}
|
||||
|
||||
wpt[0] = 0;
|
||||
memcpy(wpt + 1, dummy_chs, 3);
|
||||
ilx_opts = t->catalog->bootimages[gpt_idx[*gpt_cursor]]->isolinux_options;
|
||||
if (((ilx_opts >> 2) & 63) == 2)
|
||||
wpt[4] = 0x00; /* HFS gets marked as "Empty" */
|
||||
else
|
||||
((unsigned char *) wpt)[4] = 0xef; /* "EFI (FAT-12/16/" */
|
||||
((unsigned char *) wpt)[4] = 0xef; /* "EFI (FAT-12/16)" */
|
||||
|
||||
memcpy(wpt + 5, dummy_chs, 3);
|
||||
|
||||
@ -567,8 +604,28 @@ static int gpt_images_as_mbr_partitions(Ecma119Image *t, char *wpt,
|
||||
}
|
||||
|
||||
|
||||
/* For generating a weak random number */
|
||||
static uint32_t iso_make_mbr_id(Ecma119Image *t, int flag)
|
||||
{
|
||||
uint32_t id;
|
||||
struct timeval tv;
|
||||
|
||||
if(t->opts->vol_uuid[0]) {
|
||||
id = iso_crc32_gpt((unsigned char *) t->opts->vol_uuid, 16, 0);
|
||||
} else if(t->opts->vol_modification_time > 0) {
|
||||
id = iso_crc32_gpt((unsigned char *) &(t->opts->vol_modification_time),
|
||||
sizeof(time_t), 0);
|
||||
} else {
|
||||
gettimeofday(&tv, NULL);
|
||||
id = 0xffffffff & (tv.tv_sec ^ (tv.tv_usec * 2000));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param flag bit0= make own random MBR Id from current time
|
||||
* >>> or from overridden modification time
|
||||
* bit1= create protective MBR as of UEFI/GPT specs
|
||||
*/
|
||||
int make_isolinux_mbr(uint32_t *img_blocks, Ecma119Image *t,
|
||||
@ -580,10 +637,14 @@ int make_isolinux_mbr(uint32_t *img_blocks, Ecma119Image *t,
|
||||
char *wpt;
|
||||
uint32_t boot_lba;
|
||||
int head_count, sector_count, ret;
|
||||
int gpt_count = 0, gpt_idx[128], apm_count = 0, gpt_cursor;
|
||||
/* For generating a weak random number */
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
int gpt_count = 0, gpt_idx[128], apm_count = 0, gpt_cursor, i;
|
||||
|
||||
if (t->bootsrc[0] == NULL)
|
||||
return iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Cannot refer by isohybrid MBR to data outside of ISO 9660 filesystem.");
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
gpt_idx[i] = -1;
|
||||
|
||||
if (flag & 2) {
|
||||
part_number = 1;
|
||||
@ -625,8 +686,7 @@ int make_isolinux_mbr(uint32_t *img_blocks, Ecma119Image *t,
|
||||
(here some 32-bit random value with no crypto strength)
|
||||
*/
|
||||
if (flag & 1) {
|
||||
gettimeofday(&tv, &tz);
|
||||
id = 0xffffffff & (tv.tv_sec ^ (tv.tv_usec * 2000));
|
||||
id = iso_make_mbr_id(t, 0);
|
||||
lsb_to_buf(&wpt, id, 32, 0);
|
||||
} else {
|
||||
wpt+= 4;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2009 - 2015 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -157,7 +157,7 @@ int iso_init_with_flag(int flag)
|
||||
#ifdef Libisofs_with_libjtE
|
||||
|
||||
/* Ugly compile time check for header version compatibility.
|
||||
If everthing matches, then it produces no C code. In case of mismatch,
|
||||
If everything matches, then it produces no C code. In case of mismatch,
|
||||
intentionally faulty C code will be inserted.
|
||||
*/
|
||||
/* The indendation is an advise of man gcc to help old compilers ignoring */
|
||||
@ -380,7 +380,7 @@ const char *iso_error_to_msg(int errcode)
|
||||
case ISO_DATA_SOURCE_MISHAP:
|
||||
case ISO_DATA_SOURCE_FAILURE:
|
||||
case ISO_DATA_SOURCE_FATAL:
|
||||
return "Read error occured with IsoDataSource";
|
||||
return "Read error occurred with IsoDataSource";
|
||||
case ISO_AAIP_IGNORED:
|
||||
return "AAIP info with ACL or xattr in ISO image will be ignored";
|
||||
case ISO_AAIP_BAD_ACL:
|
||||
@ -543,6 +543,10 @@ const char *iso_error_to_msg(int errcode)
|
||||
return "A general note message was issued";
|
||||
case ISO_BAD_FSRC_FILETYPE:
|
||||
return "Unrecognized file type of IsoFileSrc object";
|
||||
case ISO_GPT_NO_VOL_UUID:
|
||||
return "Cannot derive GPT GUID from undefined pseudo-UUID volume timestamp";
|
||||
case ISO_BAD_GPT_GUID_MODE:
|
||||
return "Unrecognized GPT disk GUID setup mode";
|
||||
default:
|
||||
return "Unknown error";
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2009 - 2015 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -1114,7 +1114,7 @@ int iso_symlink_set_dest(IsoSymlink *link, const char *dest)
|
||||
* or regular files, this function has no effect.
|
||||
* @param w
|
||||
* The weight as a integer number, the greater this value is, the
|
||||
* closer from the begining of image the file will be written.
|
||||
* closer from the beginning of image the file will be written.
|
||||
*/
|
||||
void iso_node_set_sort_weight(IsoNode *node, int w)
|
||||
{
|
||||
@ -1818,7 +1818,7 @@ int attr_enlarge_list(char ***names, size_t **value_lengths, char ***values,
|
||||
|
||||
/* Merge attribute list of node and given new attribute list into
|
||||
attribute list returned by m_* parameters.
|
||||
The m_* paramters have finally to be freed by a call with bit15 set.
|
||||
The m_* parameters have finally to be freed by a call with bit15 set.
|
||||
@param flag Bitfield for control purposes
|
||||
bit0= delete all old names which begin by "user."
|
||||
(but not if bit2 is set)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2009 - 2011 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -487,7 +487,7 @@ int iso_node_cmp_flag(IsoNode *n1, IsoNode *n2, int flag);
|
||||
|
||||
|
||||
/**
|
||||
* Set the checksum index (typically comming from IsoFileSrc.checksum_index)
|
||||
* Set the checksum index (typically coming from IsoFileSrc.checksum_index)
|
||||
* of a regular file node. The index is encoded as xattr "isofs.cx" with
|
||||
* four bytes of value.
|
||||
*/
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Vreixo Formoso
|
||||
* Copyright (c) 2009 - 2011 Thomas Schmitt
|
||||
* Copyright (c) 2009 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -41,7 +41,7 @@ void iso_stream_get_file_name(IsoStream *stream, char *name);
|
||||
* take an extra ref.
|
||||
*
|
||||
* @return
|
||||
* 1 sucess, < 0 error
|
||||
* 1 success, < 0 error
|
||||
* Possible errors:
|
||||
*
|
||||
*/
|
||||
@ -52,7 +52,7 @@ int iso_file_source_stream_new(IsoFileSource *src, IsoStream **stream);
|
||||
* The stream will add a ref. to the IsoFileSource.
|
||||
*
|
||||
* @return
|
||||
* 1 sucess, < 0 error
|
||||
* 1 success, < 0 error
|
||||
*/
|
||||
int iso_cut_out_stream_new(IsoFileSource *src, off_t offset, off_t size,
|
||||
IsoStream **stream);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Vreixo Formoso
|
||||
* Copyright (c) 2010 - 2015 Thomas Schmitt
|
||||
* Copyright (c) 2010 - 2016 Thomas Schmitt
|
||||
*
|
||||
* 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
|
||||
@ -993,6 +993,24 @@ int iso_quick_apm_entry(struct iso_apm_partition_request **req_array,
|
||||
}
|
||||
|
||||
|
||||
static int iso_find_gpt_entry(struct iso_gpt_partition_request **req_array,
|
||||
int gpt_req_count,
|
||||
uint64_t start_block, uint64_t block_count,
|
||||
int *index, int flag)
|
||||
{
|
||||
struct iso_gpt_partition_request *entry;
|
||||
|
||||
for (*index = 0; *index < gpt_req_count; (*index)++) {
|
||||
entry = req_array[*index];
|
||||
if (entry->start_block == start_block &&
|
||||
entry->block_count == block_count)
|
||||
return 1;
|
||||
}
|
||||
*index = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Convenience frontend for iso_register_gpt_entry().
|
||||
name has to be already encoded as UTF-16LE.
|
||||
*/
|
||||
@ -1187,6 +1205,9 @@ static int fill_apm_gaps(Ecma119Image *t, uint32_t img_blocks)
|
||||
qsort(t->apm_req, t->apm_req_count,
|
||||
sizeof(struct iso_apm_partition_request *), cmp_partition_request);
|
||||
|
||||
if (t->opts->part_like_isohybrid)
|
||||
return 1; /* No filling, only sorting */
|
||||
|
||||
/* t->apm_req_count will grow during the loop */
|
||||
up_to = t->apm_req_count + 1;
|
||||
for (i = 1; i < up_to; i++) {
|
||||
@ -1455,8 +1476,12 @@ static void iso_write_gpt_entry(Ecma119Image *t, uint8_t *buf,
|
||||
for (i = 0; i < 16; i++)
|
||||
if (part_uuid[i])
|
||||
break;
|
||||
if (i == 16)
|
||||
iso_random_uuid(t, part_uuid);
|
||||
if (i == 16) {
|
||||
if (!t->gpt_disk_guid_set)
|
||||
iso_gpt_uuid(t, t->gpt_disk_guid);
|
||||
t->gpt_disk_guid_set = 1;
|
||||
iso_gpt_uuid(t, part_uuid);
|
||||
}
|
||||
memcpy(wpt, part_uuid, 16);
|
||||
wpt += 16;
|
||||
iso_lsb_to_buf(&wpt, start_lba & 0xffffffff, 4, 0);
|
||||
@ -1517,9 +1542,8 @@ int iso_write_gpt_header_block(Ecma119Image *t, uint32_t img_blocks,
|
||||
(uint32_t) ((back_lba - max_entries / 4 - 1) >> 32), 4, 1);
|
||||
|
||||
/* Disk GUID */
|
||||
/* >>> Make adjustable */
|
||||
if (!t->gpt_disk_guid_set)
|
||||
iso_random_uuid(t, t->gpt_disk_guid);
|
||||
iso_gpt_uuid(t, t->gpt_disk_guid);
|
||||
t->gpt_disk_guid_set = 1;
|
||||
memcpy(wpt, t->gpt_disk_guid, 16);
|
||||
wpt += 16;
|
||||
@ -1567,6 +1591,69 @@ void iso_ascii_utf_16le(uint8_t gap_name[72])
|
||||
}
|
||||
|
||||
|
||||
static int intvl_overlap(uint64_t start1, uint64_t end1,
|
||||
uint64_t start2, uint64_t end2, int second)
|
||||
{
|
||||
if (start1 >= start2 && start1 <= end2)
|
||||
return 1;
|
||||
if (end1 >= start2 && end1 <= end2)
|
||||
return 1;
|
||||
if (!second)
|
||||
return intvl_overlap(start2, end2, start1, end1, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Check APM HFS+ partitions whether they would fit in gaps.
|
||||
If so, add them as GPT partitions, too.
|
||||
*/
|
||||
static int iso_copy_apmhfs_to_gpt(Ecma119Image *t, int flag)
|
||||
{
|
||||
int a, i, counter = 0, ret;
|
||||
uint64_t bfac = 4;
|
||||
static uint8_t hfs_plus_uuid[16] = {
|
||||
0x00, 0x53, 0x46, 0x48, 0x00, 0x00, 0xaa, 0x11,
|
||||
0xaa, 0x11, 0x00, 0x30, 0x65, 0x43, 0xec, 0xac
|
||||
};
|
||||
static uint8_t zero_uuid[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
uint8_t gpt_name[72];
|
||||
static uint64_t gpt_flags = (((uint64_t) 1) << 60) | 1;
|
||||
|
||||
if ((t->apm_req_flags & 4) && t->opts->apm_block_size / 512 > 0)
|
||||
bfac = t->opts->apm_block_size / 512;
|
||||
|
||||
for (a = 0; a < t->apm_req_count; a++) {
|
||||
if (strcmp((char *) t->apm_req[a]->type, "Apple_HFS") != 0)
|
||||
continue;
|
||||
for (i = 0; i < t->gpt_req_count; i++)
|
||||
if (intvl_overlap(t->apm_req[a]->start_block * bfac,
|
||||
(t->apm_req[a]->start_block +
|
||||
t->apm_req[a]->block_count - 1) * bfac,
|
||||
t->gpt_req[i]->start_block,
|
||||
t->gpt_req[i]->start_block +
|
||||
t->gpt_req[i]->block_count - 1, 0))
|
||||
break;
|
||||
if (i >= t->gpt_req_count) {
|
||||
memset(gpt_name, 0, 72);
|
||||
counter++;
|
||||
if (counter > 1)
|
||||
sprintf((char *) gpt_name, "HFSPLUS_%d", counter);
|
||||
else
|
||||
sprintf((char *) gpt_name, "HFSPLUS");
|
||||
iso_ascii_utf_16le(gpt_name);
|
||||
ret = iso_quick_gpt_entry(t->gpt_req, &(t->gpt_req_count),
|
||||
t->apm_req[a]->start_block * bfac,
|
||||
t->apm_req[a]->block_count * bfac,
|
||||
hfs_plus_uuid, zero_uuid,
|
||||
gpt_flags, gpt_name);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf)
|
||||
{
|
||||
static uint8_t basic_data_uuid[16] = {
|
||||
@ -1586,6 +1673,10 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf)
|
||||
return 2;
|
||||
backup_end_lba = ((uint64_t) t->gpt_backup_end - t->gpt_backup_size) * 4;
|
||||
|
||||
ret = iso_copy_apmhfs_to_gpt(t, 0);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
|
||||
/* Sort and fill gaps */
|
||||
qsort(t->gpt_req, t->gpt_req_count,
|
||||
sizeof(struct iso_gpt_partition_request *), cmp_partition_request);
|
||||
@ -1593,6 +1684,10 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf)
|
||||
up_to = t->gpt_req_count + 1;
|
||||
goal = 0;
|
||||
part_end = 0;
|
||||
|
||||
if (t->opts->part_like_isohybrid)
|
||||
up_to = 0; /* No gap filling */
|
||||
|
||||
for (i = 0; i < up_to; i++) {
|
||||
if (i < up_to - 1) {
|
||||
goal = t->gpt_req[i]->start_block;
|
||||
@ -1671,12 +1766,40 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf)
|
||||
}
|
||||
|
||||
|
||||
/* Add a dummy MBR partition of type 0 with boot flag */
|
||||
static void iso_dummy_mbr_partition(uint8_t *buf, int mode)
|
||||
{
|
||||
int i;
|
||||
/* bootable , start 0/0/1, type 0x00, end 0/0/1,
|
||||
start LBA 0, block count 1 */
|
||||
static uint8_t dummy_entry[16] = {
|
||||
0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (buf[446 + 16 * i + 4] == 0x00) {
|
||||
memcpy(buf + 446 + 16 * i, dummy_entry, 16);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Abundance of 0xee and 0xef partitions. No other one free. */
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (buf[446 + 16 * i + 4] != 0xef) {
|
||||
buf[446 + 16 * i] |= 0x80;
|
||||
return;
|
||||
}
|
||||
}
|
||||
i = 3;
|
||||
buf[446 + 16 * i] |= 0x80;
|
||||
}
|
||||
|
||||
|
||||
int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
{
|
||||
int ret, int_img_blocks, sa_type, i, will_append = 0, do_isohybrid = 0;
|
||||
int first_partition = 1, last_partition = 4, apm_flag, part_type = 0;
|
||||
int gpt_count = 0, gpt_idx[128], apm_count = 0, no_boot_mbr = 0;
|
||||
int offset_flag = 0;
|
||||
int offset_flag = 0, risk_of_ee = 0;
|
||||
uint32_t img_blocks, gpt_blocks, mbrp1_blocks, pml_blocks;
|
||||
uint64_t blk;
|
||||
uint8_t *wpt;
|
||||
@ -1709,6 +1832,9 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
/* Check for isolinux image with magic number of 3.72 and produce
|
||||
an MBR from our built-in template. (Deprecated since 31 Mar 2010)
|
||||
*/
|
||||
if (t->bootsrc[0] == NULL)
|
||||
return iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Cannot refer by isohybrid MBR to data outside of ISO 9660 filesystem.");
|
||||
if (img_blocks < 0x80000000) {
|
||||
int_img_blocks= img_blocks;
|
||||
} else {
|
||||
@ -1767,8 +1893,11 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
"Cannot set up MBR partition table");
|
||||
return ret;
|
||||
}
|
||||
if (t->mbr_req_count > 0 && sa_type != 0)
|
||||
return ISO_NON_MBR_SYS_AREA;
|
||||
if (t->mbr_req_count > 0) {
|
||||
if (sa_type != 0)
|
||||
return ISO_NON_MBR_SYS_AREA;
|
||||
risk_of_ee = 1;
|
||||
}
|
||||
|
||||
if (t->gpt_backup_outside)
|
||||
gpt_blocks = t->total_size / BLOCK_SIZE + t->opts->ms_block;
|
||||
@ -1784,7 +1913,7 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
if (t->mbr_req_count == 0){
|
||||
/* Write GRUB protective msdos label, i.e. a simple partition
|
||||
table */
|
||||
if (t->gpt_req_count > 0) {
|
||||
if (t->gpt_req_count > 0 && ! t->opts->part_like_isohybrid) {
|
||||
part_type = 0xee;
|
||||
pml_blocks = gpt_blocks;
|
||||
} else {
|
||||
@ -1796,6 +1925,11 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
(uint8_t) part_type, buf, 0);
|
||||
if (ret != ISO_SUCCESS) /* error should never happen */
|
||||
return ISO_ASSERT_FAILURE;
|
||||
risk_of_ee = 1;
|
||||
} else if (t->gpt_req_count > 0) {
|
||||
|
||||
/* >>> ??? change first partition type to 0xee */;
|
||||
|
||||
}
|
||||
} else if (do_isohybrid) {
|
||||
/* Patch externally provided system area as isohybrid MBR */
|
||||
@ -1813,6 +1947,7 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
|
||||
if (t->opts->appended_as_gpt && t->have_appended_partitions) {
|
||||
part_type = 0xee;
|
||||
risk_of_ee = 1;
|
||||
img_blocks = gpt_blocks;
|
||||
no_boot_mbr = 2;
|
||||
}
|
||||
@ -1855,9 +1990,14 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
(uint8_t) 0xcd, buf, 2);
|
||||
if (ret != ISO_SUCCESS) /* error should never happen */
|
||||
return ISO_ASSERT_FAILURE;
|
||||
risk_of_ee = 1;
|
||||
if (t->opts->appended_as_gpt && t->have_appended_partitions) {
|
||||
|
||||
/* >>> ??? Do this in any case of t->gpt_req_count > ? */;
|
||||
|
||||
/* Re-write partion entry 1 : protective MBR for GPT */
|
||||
part_type = 0xee;
|
||||
risk_of_ee = 1;
|
||||
ret = write_mbr_partition_entry(1, part_type,
|
||||
(uint64_t) 1, ((uint64_t) gpt_blocks) * 4 - 1,
|
||||
t->partition_secs_per_head, t->partition_heads_per_cyl,
|
||||
@ -1881,7 +2021,7 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
With t->mbr_req_count > 0 this has already been done,
|
||||
*/
|
||||
img_blocks = t->curblock; /* value might be altered */
|
||||
if (part_type == 0xee) {
|
||||
if (part_type == 0xee && t->gpt_req_count > 0) {
|
||||
mbrp1_blocks = t->total_size / BLOCK_SIZE + t->opts->ms_block;
|
||||
offset_flag |= 2 | 1; /* protective MBR, no other partitions */
|
||||
} else {
|
||||
@ -1926,6 +2066,9 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
|
||||
if (sa_type == 0 && (t->system_area_options & 0x4000) && !do_isohybrid) {
|
||||
/* Patch MBR for GRUB2 */
|
||||
if (t->bootsrc[0] == NULL)
|
||||
return iso_msg_submit(t->image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
|
||||
"Cannot refer by GRUB2 MBR to data outside of ISO 9660 filesystem.");
|
||||
blk = t->bootsrc[0]->sections[0].block * 4 +
|
||||
Libisofs_grub2_mbr_patch_offsT;
|
||||
wpt = buf + Libisofs_grub2_mbr_patch_poS;
|
||||
@ -1933,6 +2076,50 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
|
||||
wpt[i] = blk >> (i * 8);
|
||||
}
|
||||
|
||||
/* Prevent partition type 0xee if no GPT emerged */
|
||||
|
||||
/* >>> ??? check for GPT magic number at byte 512 ff. ? */;
|
||||
|
||||
if (sa_type == 0 && ((t->system_area_options & 3) || risk_of_ee) &&
|
||||
(t->opts->part_like_isohybrid || t->gpt_req_count == 0)) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (buf[446 + 16 * i + 4] == 0xee) {
|
||||
iso_msgs_submit(0,
|
||||
"Prevented partition type 0xEE in MBR without GPT",
|
||||
0, "WARNING", 0);
|
||||
buf[446 + 16 * i + 4] = 0xcd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sa_type == 0 && (
|
||||
(t->system_area_options & 3) ||
|
||||
(t->system_area_options & (1 << 14)) ||
|
||||
(((t->system_area_options >> 2) & 0x3f) == 2 &&
|
||||
(t->system_area_options & (1 << 15)))
|
||||
)) {
|
||||
/* This is an MBR which shall have a bootable/active flag
|
||||
protective-msdos-label, isohybrid, grub2-mbr, mbr-force-bootable
|
||||
*/
|
||||
for (i = 0; i < 4; i++)
|
||||
if (buf[446 + 16 * i] & 0x80)
|
||||
break;
|
||||
if (i >= 4) { /* no bootable/active flag set yet */
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (buf[446 + 16 * i + 4] != 0x00 &&
|
||||
buf[446 + 16 * i + 4] != 0xee &&
|
||||
buf[446 + 16 * i + 4] != 0xef) {
|
||||
buf[446 + 16 * i] |= 0x80;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= 4) { /* still no bootable/active flag set */
|
||||
if (t->system_area_options & (1 << 15)) /* Force it */
|
||||
iso_dummy_mbr_partition(buf, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
@ -2173,72 +2360,73 @@ uint32_t iso_crc32_gpt(unsigned char *data, int count, int flag)
|
||||
return result ^ 0xffffffff;
|
||||
}
|
||||
|
||||
|
||||
void iso_random_uuid(Ecma119Image *t, uint8_t uuid[16])
|
||||
void iso_mark_guid_version_4(uint8_t *u)
|
||||
{
|
||||
/* Mark as UUID version 4. RFC 4122 says u[6], but UEFI prescribes
|
||||
bytes 6 and 7 to be swapped.
|
||||
*/
|
||||
u[7] = (u[7] & 0x0f) | 0x40;
|
||||
|
||||
/* Variant is "1 0 x" as described in RFC 4122.
|
||||
*/
|
||||
u[8] = (u[8] & 0x3f) | 0x80;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void iso_generate_gpt_guid(uint8_t guid[16])
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_uuid_generatE
|
||||
|
||||
uuid_t u;
|
||||
|
||||
uuid_generate(u);
|
||||
swap_uuid((void *) u);
|
||||
memcpy(guid, u, 16);
|
||||
|
||||
#else
|
||||
uint8_t u[16];
|
||||
/* produced by uuid_generate() and byte-swapped to isohybrid.c habits */
|
||||
|
||||
uint8_t *u;
|
||||
/* produced by uuid_generate() and byte-swapped to UEFI specs */
|
||||
static uint8_t uuid_template[16] = {
|
||||
0xee, 0x29, 0x9d, 0xfc, 0x65, 0xcc, 0x7c, 0x40,
|
||||
0x92, 0x61, 0x5b, 0xcd, 0x6f, 0xed, 0x08, 0x34
|
||||
};
|
||||
static uint8_t uuid_urandom[16];
|
||||
uint32_t rnd, salt;
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
pid_t pid;
|
||||
static int counter = 0, use_urandom = 0;
|
||||
int i, ret, fd;
|
||||
#endif
|
||||
|
||||
#ifdef Libisofs_with_uuid_generatE
|
||||
u = guid;
|
||||
|
||||
uuid_generate(u);
|
||||
swap_uuid((void *) u);
|
||||
memcpy(uuid, u, 16);
|
||||
|
||||
#else
|
||||
|
||||
/* First try /dev/urandom.
|
||||
(Weakening the result by 8 bit saves a lot of pool entropy.)
|
||||
/* First try /dev/urandom
|
||||
*/
|
||||
if ((counter & 0xff) == 0) {
|
||||
fd = open("/dev/urandom", O_RDONLY | O_BINARY);
|
||||
if (fd == -1)
|
||||
goto fallback;
|
||||
ret = read(fd, uuid_urandom, 16);
|
||||
if (ret != 16) {
|
||||
close(fd);
|
||||
goto fallback;
|
||||
}
|
||||
/* Mark as UUID version 4 */
|
||||
uuid_urandom[7] = (uuid_urandom[7] & 0x0f) | 0x40;
|
||||
uuid_urandom[8] = (uuid_urandom[8] & 0x3f) | 0x80;
|
||||
close(fd);
|
||||
use_urandom = 1;
|
||||
}
|
||||
if (!use_urandom)
|
||||
fd = open("/dev/urandom", O_RDONLY | O_BINARY);
|
||||
if (fd == -1)
|
||||
goto fallback;
|
||||
memcpy(uuid, uuid_urandom, 16);
|
||||
uuid[9] ^= counter & 0xff;
|
||||
counter++;
|
||||
ret = read(fd, u, 16);
|
||||
if (ret != 16) {
|
||||
close(fd);
|
||||
goto fallback;
|
||||
}
|
||||
close(fd);
|
||||
iso_mark_guid_version_4(u);
|
||||
return;
|
||||
|
||||
|
||||
fallback:;
|
||||
pid = getpid();
|
||||
salt = iso_crc32_gpt((unsigned char *) t, sizeof(Ecma119Image), 0) ^ pid;
|
||||
salt = iso_crc32_gpt((unsigned char *) &guid, sizeof(uint8_t *), 0) ^ pid;
|
||||
|
||||
/* This relies on the uniqueness of the template and the rareness of
|
||||
bootable ISO image production via libisofs. Estimated 53 bits of
|
||||
bootable ISO image production via libisofs. Estimated 48 bits of
|
||||
entropy should influence the production of a single day.
|
||||
So first collisions are to be expected with about 100 million images
|
||||
So first collisions are to be expected with about 16 million images
|
||||
per day.
|
||||
*/
|
||||
memcpy(u, uuid_template, 16);
|
||||
gettimeofday(&tv, &tz);
|
||||
gettimeofday(&tv, NULL);
|
||||
for (i = 0; i < 4; i++)
|
||||
u[i] = (salt >> (8 * i)) & 0xff;
|
||||
for (i = 0; i < 2; i++)
|
||||
@ -2246,19 +2434,36 @@ fallback:;
|
||||
u[6] = ((salt >> 8) ^ (pid >> 16)) & 0xff;
|
||||
rnd = ((0xffffff & tv.tv_sec) << 8) |
|
||||
(((tv.tv_usec >> 16) ^ (salt & 0xf0)) & 0xff);
|
||||
u[9] ^= counter & 0xff;
|
||||
for (i = 0; i < 4; i++)
|
||||
u[10 + i] ^= (rnd >> (8 * i)) & 0xff;
|
||||
u[14] ^= (tv.tv_usec >> 8) & 0xff;
|
||||
u[15] ^= tv.tv_usec & 0xff;
|
||||
counter++;
|
||||
|
||||
memcpy(uuid, u, 16);
|
||||
iso_mark_guid_version_4(u);
|
||||
return;
|
||||
|
||||
#endif /* ! Libisofs_with_uuid_generatE */
|
||||
|
||||
}
|
||||
|
||||
void iso_gpt_uuid(Ecma119Image *t, uint8_t uuid[16])
|
||||
{
|
||||
if (t->gpt_uuid_counter == 0)
|
||||
iso_generate_gpt_guid(t->gpt_uuid_base);
|
||||
|
||||
memcpy(uuid, t->gpt_uuid_base, 16);
|
||||
|
||||
/* Previous implementation changed only byte 9. So i expand it by applying
|
||||
the counter in little-endian style.
|
||||
*/
|
||||
uuid[9] ^= t->gpt_uuid_counter & 0xff;
|
||||
uuid[10] ^= (t->gpt_uuid_counter >> 8) & 0xff;
|
||||
uuid[11] ^= (t->gpt_uuid_counter >> 16) & 0xff;
|
||||
uuid[12] ^= (t->gpt_uuid_counter >> 24) & 0xff;
|
||||
t->gpt_uuid_counter++;
|
||||
return;
|
||||
}
|
||||
|
||||
int assess_appended_gpt(Ecma119Image *t, int flag)
|
||||
{
|
||||
static uint8_t basic_data_uuid[16] = {
|
||||
@ -2270,7 +2475,7 @@ int assess_appended_gpt(Ecma119Image *t, int flag)
|
||||
0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b
|
||||
};
|
||||
static uint8_t zero_uuid[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
int i, ret;
|
||||
int i, ret, do_apm = 0, do_gpt = 0, index, already_in_gpt;
|
||||
uint8_t gpt_name[72], *type_uuid;
|
||||
|
||||
#ifndef Libisofs_appended_partitions_inlinE
|
||||
@ -2278,31 +2483,51 @@ int assess_appended_gpt(Ecma119Image *t, int flag)
|
||||
return 2;
|
||||
#endif
|
||||
|
||||
/* Represent in GPT only if other GPT partitions are already registered
|
||||
or if appended partitions are explicitely desired for GPT-only.
|
||||
*/
|
||||
if (t->gpt_req_count == 0 &&
|
||||
!(t->have_appended_partitions && t->opts->appended_as_gpt))
|
||||
return 2;
|
||||
if ((t->apm_req_count > 0 && t->opts->part_like_isohybrid) ||
|
||||
(t->have_appended_partitions && t->opts->appended_as_apm))
|
||||
do_apm = 1;
|
||||
if (t->gpt_req_count > 0 ||
|
||||
(t->have_appended_partitions && t->opts->appended_as_gpt))
|
||||
do_gpt = 1;
|
||||
|
||||
if (do_apm == 0 && do_gpt == 0)
|
||||
return 2;
|
||||
|
||||
/* Represent appended partitions */
|
||||
for (i = 0; i <= 3; i++) {
|
||||
if (t->opts->appended_partitions[i] == NULL)
|
||||
continue;
|
||||
memset(gpt_name, 0, 72);
|
||||
sprintf((char *) gpt_name, "Appended%d", i + 1);
|
||||
iso_ascii_utf_16le(gpt_name);
|
||||
if (t->opts->appended_part_types[i] == 0xef)
|
||||
type_uuid = efi_sys_uuid;
|
||||
else
|
||||
type_uuid = basic_data_uuid;
|
||||
ret = iso_quick_gpt_entry(t->gpt_req, &(t->gpt_req_count),
|
||||
if (do_apm) {
|
||||
memset(gpt_name, 0, 32);
|
||||
sprintf((char *) gpt_name, "Appended%d", i + 1);
|
||||
ret = iso_quick_apm_entry(t->apm_req, &(t->apm_req_count),
|
||||
t->appended_part_start[i] * t->hfsp_iso_block_fac,
|
||||
t->appended_part_size[i] * t->hfsp_iso_block_fac,
|
||||
(char *) gpt_name, "Data");
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
if (do_gpt)
|
||||
already_in_gpt = iso_find_gpt_entry(t->gpt_req, t->gpt_req_count,
|
||||
((uint64_t) t->appended_part_start[i]) * 4,
|
||||
((uint64_t) t->appended_part_size[i]) * 4,
|
||||
&index, 0);
|
||||
if (do_gpt && !already_in_gpt) {
|
||||
memset(gpt_name, 0, 72);
|
||||
sprintf((char *) gpt_name, "Appended%d", i + 1);
|
||||
iso_ascii_utf_16le(gpt_name);
|
||||
if (t->opts->appended_part_types[i] == 0xef)
|
||||
type_uuid = efi_sys_uuid;
|
||||
else
|
||||
type_uuid = basic_data_uuid;
|
||||
ret = iso_quick_gpt_entry(t->gpt_req, &(t->gpt_req_count),
|
||||
((uint64_t) t->appended_part_start[i]) * 4,
|
||||
((uint64_t) t->appended_part_size[i]) * 4,
|
||||
type_uuid, zero_uuid,
|
||||
(uint64_t) 0, gpt_name);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
@ -2341,6 +2566,23 @@ static int precompute_gpt(Ecma119Image *t)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* With part_like_isohybrid:
|
||||
If no GPT is registered yet, and MBR, but neither CHRP nor ISOLINUX
|
||||
isohybrid is desired, then try to apply the isohybrid GPT and APM flags
|
||||
nevertheless. Avoid an overall ISO image GPT partition.
|
||||
*/
|
||||
if (t->opts->part_like_isohybrid && t->gpt_req_count <= 0 &&
|
||||
((t->system_area_options >> 2) & 0x3f) == 0 &&
|
||||
((t->system_area_options >> 10) & 0xf) != 1 &&
|
||||
(!(t->system_area_options & 2))) {
|
||||
|
||||
ret = assess_isohybrid_gpt_apm(t, &gpt_count, gpt_idx, &apm_count,
|
||||
1 | ((t->apm_req_count > 0) << 1) | 4);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
t->apm_req_flags |= 2; /* Do not fill APM gaps,
|
||||
do not adjust final APM partition size */
|
||||
}
|
||||
|
||||
/* Rectify APM requests early in order to learn the size of GPT.
|
||||
iso_write_apm() relies on this being already done here.
|
||||
@ -2596,8 +2838,7 @@ static int partprepend_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
|
||||
with_chrp = ((t->system_area_options & 0x3cff) == 0x0400);
|
||||
if (t->opts->efi_boot_partition != NULL ||
|
||||
(t->opts->hfsplus && !with_chrp) ||
|
||||
t->gpt_req_count > 0)
|
||||
t->gpt_req_count > 0) /* Might not catch all cases with GPT */
|
||||
will_have_gpt = 1;
|
||||
|
||||
if (t->opts->efi_boot_partition != NULL) {
|
||||
|
@ -182,10 +182,15 @@ int iso_quick_apm_entry(struct iso_apm_partition_request **req_array,
|
||||
run on other machines with the same process number at the same time.
|
||||
*/
|
||||
|
||||
/* Produces a weakly random variation of a hardcoded real random uuid
|
||||
/* Produces a GPT disk or partition GUID.
|
||||
Pseudo-random by iso_generate_gpt_guid() if t->gpt_uuid_counter is 0.
|
||||
Else derived reproducibly by counter number from t->gpt_uuid_base.
|
||||
*/
|
||||
void iso_random_uuid(Ecma119Image *t, uint8_t uuid[16]);
|
||||
void iso_gpt_uuid(Ecma119Image *t, uint8_t uuid[16]);
|
||||
|
||||
/* Mark a given byte string as UUID version 4, RFC 4122.
|
||||
*/
|
||||
void iso_mark_guid_version_4(uint8_t *u);
|
||||
|
||||
/* The parameter struct for production of a single GPT entry.
|
||||
See also the partial GPT description in doc/boot_sectors.txt.
|
||||
|
@ -1823,7 +1823,7 @@ time_t iso_datetime_read_17(const uint8_t *buf)
|
||||
tm.tm_mon -= 1;
|
||||
tm.tm_isdst = 0;
|
||||
|
||||
return timegm(&tm) - ((int8_t)buf[6]) * 60 * 15;
|
||||
return timegm(&tm) - ((int8_t)buf[16]) * 60 * 15;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,13 +29,13 @@ struct Iso_Image_Writer
|
||||
};
|
||||
|
||||
/**
|
||||
* This is the function all Writers shoudl call to write data to image.
|
||||
* This is the function all Writers should call to write data to image.
|
||||
* Currently, it is just a wrapper for write(2) Unix system call.
|
||||
*
|
||||
* It is implemented in ecma119.c
|
||||
*
|
||||
* @return
|
||||
* 1 on sucess, < 0 error
|
||||
* 1 on success, < 0 error
|
||||
*/
|
||||
int iso_write(Ecma119Image *target, void *buf, size_t count);
|
||||
|
||||
|
Reference in New Issue
Block a user