diff --git a/scan.c b/scan.c index 34c51eb2..8aa58abc 100644 --- a/scan.c +++ b/scan.c @@ -919,6 +919,8 @@ void state_scan(struct snapraid_state* state, int output) } /* sort the files before inserting them */ + /* we use a stable sort to ensure that if the reported physical offset/inode */ + /* are always 0, we keep at least the directory order */ switch (state->opt.force_order) { case SORT_PHYSICAL : tommy_list_sort(&scan->file_insert_list, file_physical_compare); diff --git a/unix.c b/unix.c index abda84b3..f60b9d07 100644 --- a/unix.c +++ b/unix.c @@ -141,6 +141,7 @@ int filephy(const char* path, struct stat* st, uint64_t* physical) } /* first try with FIEMAP */ + /* if works for ext2, ext3, ext4, xfs */ memset(&fm, 0, sizeof(fm)); fm.fiemap.fm_start = 0; fm.fiemap.fm_length = ~0ULL; @@ -154,12 +155,6 @@ int filephy(const char* path, struct stat* st, uint64_t* physical) return 0; } - /* if it's an unexpected error fails */ - if (errno != ENOTSUP) { - close(f); - return -1; - } - /* if empty, FIBMAP doesn't work */ if (st->st_size == 0) { *physical = 0; @@ -169,6 +164,8 @@ int filephy(const char* path, struct stat* st, uint64_t* physical) } /* then try with FIBMAP */ + /* it works for jfs, reiserfs, ntfs-3g */ + /* in exfat it always returns 0, that it's anyway better than the fake inodes */ blknum = 0; /* first block */ if (ioctl(f, FIBMAP, &blknum) == 0) { *physical = blknum; @@ -177,14 +174,10 @@ int filephy(const char* path, struct stat* st, uint64_t* physical) return 0; } - /* if it's an unexpected error fails */ - if (errno != ENOTSUP && errno != EPERM) { - close(f); - return -1; - } - - /* otherwise uses the inode */ - *physical = st->st_ino; + /* otherwise don't use anything, and keep the existing order */ + /* at now this should happen only for vfat */ + /* and it's surely better than using fake inodes */ + *physical = 0; if (close(f) == -1) return -1; #else