From b2897d543df1dfbadcbf50d5c013c24866151de7 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Mon, 12 Nov 2012 16:56:51 -0600 Subject: [PATCH] wimlib_mount(): Disallow mounting newly added image --- src/mount.c | 9 ++++++++- src/wimlib.h | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mount.c b/src/mount.c index 4dc28f1f..27f6551a 100644 --- a/src/mount.c +++ b/src/mount.c @@ -1880,7 +1880,14 @@ WIMLIBAPI int wimlib_mount(WIMStruct *wim, int image, const char *dir, if (imd->root_dentry->refcnt != 1) { ERROR("Cannot mount image that was just exported with " - "wimlib_export()"); + "wimlib_export_image()"); + ret = WIMLIB_ERR_INVALID_PARAM; + goto out; + } + + if (imd->modified) { + ERROR("Cannot mount image that was added " + "with wimlib_add_image()"); ret = WIMLIB_ERR_INVALID_PARAM; goto out; } diff --git a/src/wimlib.h b/src/wimlib.h index 8c133a26..a8b07ac0 100644 --- a/src/wimlib.h +++ b/src/wimlib.h @@ -914,7 +914,10 @@ extern int wimlib_join(const char **swms, unsigned num_swms, * * wimlib_mount() cannot be used on an image that was exported with * wimlib_export_image() while the dentry trees for both images are still in - * memory. + * memory. In addition, wimlib_mount() may not be used to mount an image that + * has just been added with wimlib_add_image() or + * wimlib_add_image_from_ntfs_volume(), unless the WIM has been written and read + * into a new ::WIMStruct. * * @param wim * Pointer to the ::WIMStruct for the WIM file to be mounted. @@ -954,7 +957,8 @@ extern int wimlib_join(const char **swms, unsigned num_swms, * @a image does not specify an existing, single image in @a wim. * @retval ::WIMLIB_ERR_INVALID_PARAM * @a image is shared among multiple ::WIMStruct's as a result of a call to - * wimlib_export_image(). + * wimlib_export_image(), or @a image has been added with + * wimlib_add_image() or wimlib_add_image_from_ntfs_volume(). * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE * The metadata resource for @a image in @a wim is invalid. * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA -- 2.43.0