From af1a9f0d89f9d4428776238a561a6a5b6900f2d4 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 21 Aug 2013 20:20:05 -0500 Subject: [PATCH] Minor fixes --- clang-scan-build.sh | 1 + doc/imagex-apply.1.in | 63 ++++++++++++++++++++--------------------- doc/imagex-capture.1.in | 20 ++++++------- doc/imagex-export.1.in | 2 +- include/wimlib.h | 8 ++++-- src/dentry.c | 3 +- src/win32_apply.c | 1 + src/win32_common.c | 16 +++++------ 8 files changed, 56 insertions(+), 58 deletions(-) create mode 100644 clang-scan-build.sh diff --git a/clang-scan-build.sh b/clang-scan-build.sh new file mode 100644 index 00000000..32d41279 --- /dev/null +++ b/clang-scan-build.sh @@ -0,0 +1 @@ +scan-build --use-analyzer=/bin/clang clang src/*.c programs/imagex.c -o imagex -D_FILE_OFFSET_BITS=64 -std=gnu99 -lntfs-3g -lxml2 -lfuse -lpthread -lrt -Iinclude/ -I./ -I/usr/include/libxml2/ -D HAVE_CONFIG_H -Wno-pointer-sign -D_GNU_SOURCE -lcrypto diff --git a/doc/imagex-apply.1.in b/doc/imagex-apply.1.in index 0c536df2..5c6a842e 100644 --- a/doc/imagex-apply.1.in +++ b/doc/imagex-apply.1.in @@ -79,8 +79,7 @@ be extracted as uncompressed, while encrypted files will not be extracted at all. .SH NTFS VOLUME EXTRACTION (UNIX) This section documents how \fB@IMAGEX_PROGNAME@ apply\fR extracts a WIM image -directly to an NTFS volume image on UNIX-like systems. See \fBDIRECTORY EXTRACTION -(WINDOWS)\fR for the corresponding documentation for Windows. +directly to an NTFS volume image on UNIX-like systems. .PP As mentioned, \fB@IMAGEX_PROGNAME@\fR running on a UNIX-like system can apply a WIM image directly to an NTFS volume by specifying \fITARGET\fR as a regular file @@ -103,8 +102,8 @@ unmounted, and you must have permission to write to it). This NTFS volume extraction mode attempts to extract as much information as possible, including: .IP \[bu] 4 -All data streams of all files, including the unnamed data stream as well as all -named data streams. +All data streams of all files except encrypted files, including the unnamed data +stream as well as all named data streams. .IP \[bu] Reparse points, including symbolic links, junction points, and other reparse points. @@ -222,17 +221,17 @@ above not being supported by the target filesystem. .IP \[bu] Since encrypted files (with FILE_ATTRIBUTE_ENCRYPTED) are not stored in plaintext in the WIM image, \fB@IMAGEX_PROGNAME@\fR cannot restore encrypted -files to filesystems not supporting encryption. Therefore, such files are not -extracted. Furthermore, even if encrypted files are restored to a filesystem -that supports encryption, they will only be decryptable if the decryption key is -available. +files to filesystems not supporting encryption. Therefore, on such filesystems, +encrypted files will not be extracted. Furthermore, even if encrypted +files are restored to a filesystem that supports encryption, they will only be +decryptable if the decryption key is available. .IP \[bu] Files with names that cannot be represented on Windows will not be extracted by default; see \fB--include-invalid-names\fR. .IP \[bu] -Files with full paths over 260 characters (MAX_PATH) are extracted by using the -\\\\?\\-prefixed path hack. But beware that such files will be inaccessible to -most Windows software and may not be able to be deleted easily. +Files with full paths over 260 characters (the so-called MAX_PATH) will be +extracted, but beware that such files will be inaccessible to most Windows +software and may not be able to be deleted easily. .SH SPLIT WIMS You may use \fB@IMAGEX_PROGNAME@ apply\fR to apply images from a split WIM. The \fIWIMFILE\fR argument must specify the first part of the split WIM, while the @@ -267,8 +266,9 @@ As of wimlib 1.5.0, \fB@IMAGEX_PROGNAME@ apply\fR supports applying a WIM from a nonseekable file, such as a pipe, provided that the WIM was captured with \fB--pipable\fR (see \fB@IMAGEX_PROGNAME@ capture\fR(1)). To use standard input as the WIM, specify "-" as \fIWIMFILE\fR. A useful use of this ability is to -apply an image from a WIM while streaming it from a webserver; for example, to -apply the first image from a WIM file to an NTFS volume on /dev/sda1: +apply an image from a WIM while streaming it from a server. For example, to +apply the first image from a WIM file available on a HTTP server to an NTFS +volume on /dev/sda1, run something like: .PP .RS wget -O - http://myserver/mywim.wim | wimapply - 1 /dev/sda1 @@ -299,20 +299,17 @@ expansion. Set whether to fix targets of absolute symbolic links (reparse points in Windows terminology) or not. When enabled (\fB--rpfix\fR), extracted absolute symbolic links that are marked in the WIM image as being fixed are assumed to have -absolute targets relative to the image root, and therefore have the actual root -of extraction prepended to their targets. The intention is that you can apply -an image containing absolute symbolic links and still have them be valid after -it has been applied to any location. +absolute targets relative to the image root, and therefore \fB@IMAGEX_PROGNAME@ +apply\fR prepends the absolute path to the extraction target directory to their +targets. The intention is that you can apply an image containing absolute +symbolic links and still have them be valid after it has been applied to any +location. .IP "" The default behavior is \fB--rpfix\fR if any images in \fIWIMFILE\fR have been captured with reparse-point fixups done. Otherwise, it is \fB--norpfix\fR. .IP "" Reparse point fixups are never done in the NTFS volume extraction mode on UNIX-like systems. -.IP "" -\fB--verbose\fR -Print the path to of each file or directory within the WIM image as it is -extracted. .TP \fB--hardlink\fR When extracting a file from the WIM that is identical to a file that has already @@ -345,24 +342,26 @@ Do not restore security descriptors on extracted files and directories. .TP \fB--strict-acls\fR Fail immediately if the full security descriptor of any file or directory cannot -be set exactly as specified in the WIM file. On Windows, the default behavior -without this option is to fall back to setting a security descriptor with the -SACL omitted, then only the default inherited security descriptor, if -\fB@IMAGEX_PROGNAME@\fR does not have permission to set the desired one. Also, -on UNIX-like systems, this flag can also be combined with \fB--unix-data\fR to -cause \fB@IMAGEX_PROGNAME@\fR to fail immediately if the UNIX owner, group, or -mode on an extracted file cannot be set for any reason. +be set exactly as specified in the WIM file. If this option is not specified, +when \fB@IMAGEX_PROGNAME@\fR on Windows does not have permission to set a +security descriptor on an extracted file, it falls back to setting it only +partially (e.g. with SACL omitted), and in the worst case omits it entirely. +However, this should only be a problem when running \fB@IMAGEX_PROGNAME@\fR +without Administrator rights. Also, on UNIX-like systems, this flag can also be +combined with \fB--unix-data\fR to cause \fB@IMAGEX_PROGNAME@\fR to fail +immediately if the UNIX owner, group, or mode on an extracted file cannot be set +for any reason. .TP \fB--include-invalid-names\fR Extract files and directories with invalid names by replacing characters and -appending a suffix rather than ignoring them. The meaning of this is -platform-dependent. -.IP "" 6 +appending a suffix rather than ignoring them. Exactly what is considered an +"invalid" name is platform-dependent. +.IP "" On POSIX-compliant systems, filenames are case-sensitive and may contain any byte except '\\0' and \'/', so on a POSIX-compliant system this option will only have an effect in the unlikely case that the WIM image for some reason has a filename containing one of these characters. -.IP "" 6 +.IP "" On Windows, filenames are case-insensitive, cannot include the characters '/', \'\\0', '\\', ':', '*', '?', '"', '<', '>', or '|', and cannot end with a space or period. Ordinarily, files in WIM images should meet these conditions as diff --git a/doc/imagex-capture.1.in b/doc/imagex-capture.1.in index 940bae18..a25794c8 100644 --- a/doc/imagex-capture.1.in +++ b/doc/imagex-capture.1.in @@ -24,13 +24,13 @@ in the entire WIM, regardless of how many images the file appears in. \fISOURCE\fR specifies the location of the files to create the new WIM image from. If \fISOURCE\fR is a directory, the WIM image is captured from that directory (see \fBDIRECTORY CAPTURE (UNIX)\fR or \fBDIRECTORY CAPTURE -(WINDOWS)\fR. Alternatively, if the \fB--source-list\fR option is specified, +(WINDOWS)\fR). Alternatively, if the \fB--source-list\fR option is specified, \fISOURCE\fR is interpreted as a file that itself provides a list of files and directories to include in the new WIM image. Still alternatively, only on UNIX-like systems, if \fISOURCE\fR is a regular file or block device, it is interpreted as an NTFS volume from which a WIM image is to be captured using libntfs-3g (see \fBNTFS VOLUME CAPTURE -(UNIX)\fR. +(UNIX)\fR). .PP \fIIMAGE_NAME\fR and \fIIMAGE_DESCRIPTION\fR specify the name and description to give the new WIM image. If \fIIMAGE_NAME\fR is not specified, it defaults to @@ -60,14 +60,11 @@ will \fInot\fR be stored is: UNIX file owners, groups, and modes. (Exception: see the \fB--unix-data\fR option.) As a result, file permissions will not be stored, and files that are neither regular files, directories, nor symbolic links, such as device files and -FIFOs, cannot be captured. +FIFOs, cannot be captured and will be excluded by default. .IP \[bu] Extended attributes. This mainly includes extensions to the traditional UNIX security model, such as SELinux security labels, POSIX ACLs, and capabilities labels. -.IP \[bu] -Files that are neither regular files, directories, nor symbolic links, such as -device files and FIFOs. These will be excluded by default. .PP Notes: hard links and symbolic links are supported by the WIM format and \fIare\fR stored. (Symbolic links are turned into "native" Windows symbolic @@ -77,14 +74,13 @@ granularity and include last modification time (mtime) and last access time (atime), but not last status change time (ctime). .SH NTFS VOLUME CAPTURE (UNIX) This section documents how \fB@IMAGEX_PROGNAME@\fR captures files directly from -an NTFS volume image on UNIX-like systems. See \fBDIRECTORY CAPTURE -(WINDOWS)\fR for the corresponding documentation for Windows. +an NTFS volume image on UNIX-like systems. .PP On UNIX-like systems, a special image capture mode is entered when \fISOURCE\fR is a regular file or block device. In this mode, \fISOURCE\fR is assumed to be -an NTFS volume or volume image, and wimlib will capture a WIM image containing a -full contents of the NTFS volume, including NTFS-specific data. This is done -using libntfs-3g. +an NTFS volume or volume image, and \fB@IMAGEX_PROGNAME@\fR will capture a WIM +image containing the full contents of the NTFS volume, including NTFS-specific +data. This is done using libntfs-3g. .PP Please note that the NTFS volume capture mode is \fInot\fR entered if \fISOURCE\fR is a directory, even if an NTFS filesystem is mounted on @@ -164,7 +160,7 @@ Note: the capture process is reversible, since when \fB@IMAGEX_PROGNAME@ apply\fR (on Windows) extracts the captured WIM image, it will extract all of the above information, at least to the extent supported by the destination filesystem. One exception is that since encrypted files are stored as -unencrypted, their data will not be available if restored on a Windows system +encrypted, their data will not be available if restored on a Windows system that does not have the decryption key. .SH OPTIONS .TP 6 diff --git a/doc/imagex-export.1.in b/doc/imagex-export.1.in index f1d7e3e8..46dcb766 100644 --- a/doc/imagex-export.1.in +++ b/doc/imagex-export.1.in @@ -102,7 +102,7 @@ this option is to make \fIDEST_WIMFILE\fR pipable if and only if it already existed and was already pipable, or was "-" (standard output). .TP \fB--not-pipable\fR -Build, or rebuld, \fIDEST_WIMFILE\fR as a normal, non-pipable WIM. This is the +Build, or rebuild, \fIDEST_WIMFILE\fR as a normal, non-pipable WIM. This is the default behavior, unless \fIDEST_WIMFILE\fR already existed and was already pipable, or if \fIDEST_WIMFILE\fR was "-" (standard output). .SH SPLIT WIMS diff --git a/include/wimlib.h b/include/wimlib.h index 132233ff..acc9c0c6 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -1339,6 +1339,7 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour * @name Init flags * * The following flags can be passed to wimlib_global_init(). + * @{ */ /** Assume that strings are represented in UTF-8, even if this is not the @@ -1374,6 +1375,7 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour * * The following flags can be passed to wimlib_reference_resource_files() and * wimlib_reference_resources(). + * @{ */ /** wimlib_reference_resource_files() only: Enable shell-style filename @@ -2031,7 +2033,7 @@ wimlib_extract_image(WIMStruct *wim, int image, * wimlib_resolve_image() uses. However, unlike wimlib_extract_image(), * only a single image (not all images) can be specified. Alternatively, * specify @p NULL here to use the first image in the WIM if it contains - * exactly one image but otherwise return @p WIMLIB_ERR_INVALID_IMAGE. + * exactly one image but otherwise return ::WIMLIB_ERR_INVALID_IMAGE. * @param target * Same as the corresponding parameter to wimlib_extract_image(). * @param extract_flags @@ -2307,8 +2309,8 @@ wimlib_iterate_lookup_table(WIMStruct *wim, int flags, * Number of filenames in @p swms. * @param swm_open_flags * Open flags for the split WIM parts (e.g. - * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY). Note: WIMLIB_OPEN_FLAG_SPLIT_OK is - * automatically added to the value specified here. + * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY). Note: ::WIMLIB_OPEN_FLAG_SPLIT_OK + * is automatically added to the value specified here. * @param wim_write_flags * Bitwise OR of relevant flags prefixed with WIMLIB_WRITE_FLAG, which will * be used to write the joined WIM. diff --git a/src/dentry.c b/src/dentry.c index 7caab57f..7762e702 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -2550,7 +2550,6 @@ inode_metadata_consistent(const struct wim_inode *inode, } else if (template_lte && wim_resource_size(template_lte)) { return false; } - } /* All right, barring a full checksum and given that the inodes share a @@ -2565,7 +2564,7 @@ inode_metadata_consistent(const struct wim_inode *inode, * useful stream information (e.g. checksums) from @template_inode. * * This assumes that the streams for @inode have been resolved (to point - * directly to the appropriate `struct wim_lookup_table_entry') but do not + * directly to the appropriate `struct wim_lookup_table_entry's) but do not * necessarily have checksum information filled in. */ static int diff --git a/src/win32_apply.c b/src/win32_apply.c index 4c665752..55757233 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -531,6 +531,7 @@ win32_set_security_descriptor(const wchar_t *path, const u8 *desc, ctx->no_security_descriptors++; break; } + SetLastError(err); goto error; } ret = 0; diff --git a/src/win32_common.c b/src/win32_common.c index 26a4d75a..bcd5c550 100644 --- a/src/win32_common.c +++ b/src/win32_common.c @@ -502,14 +502,14 @@ win32_release_capture_and_apply_privileges(void) HANDLE win32_open_existing_file(const wchar_t *path, DWORD dwDesiredAccess) { - return CreateFileW(path, - dwDesiredAccess, - FILE_SHARE_READ, - NULL, /* lpSecurityAttributes */ - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | - FILE_FLAG_OPEN_REPARSE_POINT, - NULL /* hTemplateFile */); + return CreateFile(path, + dwDesiredAccess, + FILE_SHARE_READ, + NULL, /* lpSecurityAttributes */ + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS | + FILE_FLAG_OPEN_REPARSE_POINT, + NULL /* hTemplateFile */); } /* Pointers to functions that are not available on all targetted versions of -- 2.43.0