]> wimlib.net Git - wimlib/blobdiff - src/wim.c
mount_image.c: add fallback definitions of RENAME_* constants
[wimlib] / src / wim.c
index e9a6c8eba1ca665d619272e82c9eb92c1ed2faf8..3a2a216a4c0db0c682be476484deacca754f438e 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -3,7 +3,7 @@
  */
 
 /*
- * Copyright (C) 2012-2016 Eric Biggers
+ * Copyright 2012-2023 Eric Biggers
  *
  * This file is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -16,7 +16,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public License
- * along with this file; if not, see http://www.gnu.org/licenses/.
+ * along with this file; if not, see https://www.gnu.org/licenses/.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -26,6 +26,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <stdlib.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
 #include "wimlib.h"
@@ -644,11 +645,17 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, int open_flags)
                filedes_init(&wim->in_fd, *(const int*)wim_filename_or_fd);
                wim->in_fd.is_pipe = 1;
        } else {
+               struct stat stbuf;
+
                wimfile = wim_filename_or_fd;
                ret = open_wim_file(wimfile, &wim->in_fd);
                if (ret)
                        return ret;
 
+               /* The file size is needed for enforcing some limits later. */
+               if (fstat(wim->in_fd.fd, &stbuf) == 0)
+                       wim->file_size = stbuf.st_size;
+
                /* The absolute path to the WIM is requested so that
                 * wimlib_overwrite() still works even if the process changes
                 * its working directory.  This actually happens if a WIM is
@@ -979,7 +986,6 @@ wimlib_global_init(int init_flags)
                goto out_unlock;
 
        init_cpu_features();
-       xml_global_init();
 #ifdef _WIN32
        ret = win32_global_init(init_flags);
        if (ret)
@@ -1010,7 +1016,6 @@ wimlib_global_cleanup(void)
        if (!lib_initialized)
                goto out_unlock;
 
-       xml_global_cleanup();
 #ifdef _WIN32
        win32_global_cleanup();
 #endif