mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-01 04:17:02 -05:00
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:
parent
ef969263cd
commit
4eee6b9c4a
2 changed files with 9 additions and 14 deletions
2
scan.c
2
scan.c
|
|
@ -919,6 +919,8 @@ void state_scan(struct snapraid_state* state, int output)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sort the files before inserting them */
|
/* 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) {
|
switch (state->opt.force_order) {
|
||||||
case SORT_PHYSICAL :
|
case SORT_PHYSICAL :
|
||||||
tommy_list_sort(&scan->file_insert_list, file_physical_compare);
|
tommy_list_sort(&scan->file_insert_list, file_physical_compare);
|
||||||
|
|
|
||||||
21
unix.c
21
unix.c
|
|
@ -141,6 +141,7 @@ int filephy(const char* path, struct stat* st, uint64_t* physical)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first try with FIEMAP */
|
/* first try with FIEMAP */
|
||||||
|
/* if works for ext2, ext3, ext4, xfs */
|
||||||
memset(&fm, 0, sizeof(fm));
|
memset(&fm, 0, sizeof(fm));
|
||||||
fm.fiemap.fm_start = 0;
|
fm.fiemap.fm_start = 0;
|
||||||
fm.fiemap.fm_length = ~0ULL;
|
fm.fiemap.fm_length = ~0ULL;
|
||||||
|
|
@ -154,12 +155,6 @@ int filephy(const char* path, struct stat* st, uint64_t* physical)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if it's an unexpected error fails */
|
|
||||||
if (errno != ENOTSUP) {
|
|
||||||
close(f);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if empty, FIBMAP doesn't work */
|
/* if empty, FIBMAP doesn't work */
|
||||||
if (st->st_size == 0) {
|
if (st->st_size == 0) {
|
||||||
*physical = 0;
|
*physical = 0;
|
||||||
|
|
@ -169,6 +164,8 @@ int filephy(const char* path, struct stat* st, uint64_t* physical)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* then try with FIBMAP */
|
/* 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 */
|
blknum = 0; /* first block */
|
||||||
if (ioctl(f, FIBMAP, &blknum) == 0) {
|
if (ioctl(f, FIBMAP, &blknum) == 0) {
|
||||||
*physical = blknum;
|
*physical = blknum;
|
||||||
|
|
@ -177,14 +174,10 @@ int filephy(const char* path, struct stat* st, uint64_t* physical)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if it's an unexpected error fails */
|
/* otherwise don't use anything, and keep the existing order */
|
||||||
if (errno != ENOTSUP && errno != EPERM) {
|
/* at now this should happen only for vfat */
|
||||||
close(f);
|
/* and it's surely better than using fake inodes */
|
||||||
return -1;
|
*physical = 0;
|
||||||
}
|
|
||||||
|
|
||||||
/* otherwise uses the inode */
|
|
||||||
*physical = st->st_ino;
|
|
||||||
if (close(f) == -1)
|
if (close(f) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue