aboutsummaryrefslogtreecommitdiff
path: root/bin/rdsquashfs/restore_fstree.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-02-09 16:14:27 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-02-09 16:17:23 +0100
commitf9ca81a4768e06e2a01b555640173b5ec09fc4c8 (patch)
tree8688aefe824788ef4859d1c73ee915a3603d176b /bin/rdsquashfs/restore_fstree.c
parentae048f7ac4a9ab6576ca6842aa13e5c9c31e35a7 (diff)
Fixup extaction paths for rdsquashfs on Windows
- If we generate a manifest file, use the fix-path function to produce a fixed up, actual name as the source path. - When unpacking, create files for the fixed up, actual name. There is no need to touch gensquashfs, if the manifest file is used to re-pack the stuff, the original paths are used and the files are source from the fixed-up paths. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/rdsquashfs/restore_fstree.c')
-rw-r--r--bin/rdsquashfs/restore_fstree.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/bin/rdsquashfs/restore_fstree.c b/bin/rdsquashfs/restore_fstree.c
index bfe5d86..0c68b3a 100644
--- a/bin/rdsquashfs/restore_fstree.c
+++ b/bin/rdsquashfs/restore_fstree.c
@@ -10,10 +10,18 @@
static int create_node(const sqfs_tree_node_t *n, const char *name, int flags)
{
WCHAR *wpath;
+ char *fixed;
HANDLE fh;
(void)flags;
- wpath = path_to_windows(name);
+ fixed = fix_win32_filename(name);
+ if (fixed == NULL) {
+ fputs("create_node: out of memory!\n", stderr);
+ return -1;
+ }
+
+ wpath = path_to_windows(fixed);
+ free(fixed);
if (wpath == NULL)
return -1;
@@ -243,6 +251,19 @@ static int set_attribs(sqfs_xattr_reader_t *xattr,
ret = canonicalize_name(path);
assert(ret == 0);
+#if defined(_WIN32) || defined(__WINDOWS__)
+ {
+ char *fixed = fix_win32_filename(path);
+ if (fixed == NULL) {
+ sqfs_perror(path, "fixing Windows path",
+ SQFS_ERROR_ALLOC);
+ sqfs_free(path);
+ return -1;
+ }
+ path = fixed;
+ }
+#endif
+
#ifdef HAVE_SYS_XATTR_H
if ((flags & UNPACK_SET_XATTR) && xattr != NULL) {
if (set_xattr(path, xattr, n))