From 3768ac329c95199d6bc05ced2466ae6d2fb48656 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 10 Jul 2013 18:33:19 +0200 Subject: [PATCH] Fixes root directory creation in Windows. --- HISTORY | 9 +++++++++ TODO | 2 ++ util.c | 13 +++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index 330f0ba3..22bc2e1a 100644 --- a/HISTORY +++ b/HISTORY @@ -22,6 +22,15 @@ SnapRAID HISTORY directory tree. * Changes the 'dup' output format to include the size of each duplicate file. +3.2 2013/7 +========== + * Fix a directory creation problem in Windows when the "disk" option points to + the root directory of a drive. Now SnapRAID won't complain about the + inability to create such directory. + If you encouter this problem when trying to recover your data, just upgrade + to this version, and you'll be able to complete the recovering process. + No need to upgrade for platforms different from Windows. + 3.1 2013/5 ========== * Direct use of Windows API for disk access to improve error reporting. diff --git a/TODO b/TODO index 6c198de8..533d5b77 100644 --- a/TODO +++ b/TODO @@ -5,6 +5,8 @@ This is the list of TODO items for SnapRAID. - v4.0 +* Don't enforce different disk in fix. It could allow to recover in spare space of a disk already used. + * In the import list, uses also all the blocks in the array. But we must cover the case of bad blocks. Likely we can just check the hash after reading, and in case, skip it, and retry with another copy. diff --git a/util.c b/util.c index 787567a6..583d9d15 100644 --- a/util.c +++ b/util.c @@ -687,9 +687,9 @@ int mkancestor(const char* file) { char dir[PATH_MAX]; char* c; - + pathcpy(dir, sizeof(dir), file); - + c = strrchr(dir, '/'); if (!c) { /* no ancestor */ @@ -699,11 +699,20 @@ int mkancestor(const char* file) /* clear the file */ *c = 0; + /* if it's the root dir */ if (*dir == 0) { /* nothing more to do */ return 0; } +#ifdef _WIN32 + /* if it's a drive specificaion like "C:" */ + if (isalpha(dir[0]) && dir[1] == ':' && dir[2] == 0) { + /* nothing more to do */ + return 0; + } +#endif + /* try creating it */ if (mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0) { /* just created */