Doesn't fail in filephy() after an unexpected error. There are too many filesystem to know that are expected errors.

This commit is contained in:
Andrea Mazzoleni 2013-09-24 21:45:07 +02:00
parent ef969263cd
commit 4eee6b9c4a
2 changed files with 9 additions and 14 deletions

2
scan.c
View file

@ -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);

21
unix.c
View file

@ -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