From 926133e7a8aa8b7d7c5998253ab4c5e6318c87ec Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Sun, 31 Aug 2025 10:54:14 +0100 Subject: [PATCH] Also support '\' in paths --- e2cp.c | 10 +++++----- e2md.c | 15 +++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/e2cp.c b/e2cp.c index bdea24f..28caf18 100644 --- a/e2cp.c +++ b/e2cp.c @@ -311,7 +311,7 @@ static unsigned long find_entry (struct filesystem *fs, unsigned long nod, const #define CB_SIZE (COPY_BLOCKS * BLOCKSIZE) -signed long read_cb (struct filesystem *fs, struct inode_pos *ipos, signed long size, void *data) { +static signed long read_cb (struct filesystem *fs, struct inode_pos *ipos, signed long size, void *data) { signed long remaining_size = size; @@ -362,7 +362,7 @@ static void write_file (struct filesystem *fs, struct inode *node, struct inode_ } -unsigned long mkfile_fs (struct filesystem *fs, unsigned long parent_nod, const char *name, void *data, unsigned long size, unsigned short uid, unsigned short gid, unsigned long ctime, unsigned long mtime) { +static unsigned long mkfile_fs (struct filesystem *fs, unsigned long parent_nod, const char *name, void *data, unsigned long size, unsigned short uid, unsigned short gid, unsigned long ctime, unsigned long mtime) { unsigned long nod; @@ -700,12 +700,12 @@ static int check_overwrite (const char *fn) { } -static void copy_file (struct filesystem *fs, FILE *fp, unsigned long parent_nod, char *fn) { +static void copy_file (struct filesystem *fs, FILE *fp, unsigned long parent_nod, char *target) { unsigned long bytes = 0, timestamp = time (0), nod; - char *basename = fn, *p; + char *basename = target, *p; - if ((p = strrchr (fn, '/')) || (p = strrchr (fn, '\\'))) { + if ((p = strrchr (target, '/')) || (p = strrchr (target, '\\'))) { basename = (p + 1); } diff --git a/e2md.c b/e2md.c index c2347b1..f24935a 100644 --- a/e2md.c +++ b/e2md.c @@ -297,19 +297,18 @@ static unsigned long find_entry (struct filesystem *fs, unsigned long nod, const static void walk_dir (struct filesystem *fs, char *dirname) { - unsigned long parent_nod = EXT2_ROOT_INO; - unsigned long timestamp = time (0); + unsigned long parent_nod = EXT2_ROOT_INO, timestamp = time (0); + char *p1 = dirname, *p2, saved_ch; - char *p1 = dirname, *p2; - - while (*p1 && *p1 == '/') { + while (*p1 && (*p1 == '/' || *p1 == '\\')) { p1++; } if (*p1) { - for (; (p2 = strchr (p1, '/')); p1 = p2 + 1) { + for (; (p2 = strchr (p1, '/')) || (p2 = strchr (p1, '\\')); p1 = p2 + 1) { + saved_ch = *p2; *p2 = '\0'; if (strlen (p1) >= 14) { @@ -320,12 +319,12 @@ static void walk_dir (struct filesystem *fs, char *dirname) { report_at (program_name, 0, REPORT_ERROR, "cannot access '%s'", dirname); - *p2 = '/'; + *p2 = saved_ch; return; } - *p2 = '/'; + *p2 = saved_ch; } -- 2.34.1