mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-05 14:20:05 -05:00
Assumes ioctl() failed only if it returns -1.
This happens when dealing with btrfs.
This commit is contained in:
parent
4eee6b9c4a
commit
73c16ffd88
2 changed files with 4 additions and 5 deletions
3
HISTORY
3
HISTORY
|
|
@ -4,8 +4,7 @@ SnapRAID HISTORY
|
||||||
4.1 2013/9
|
4.1 2013/9
|
||||||
==========
|
==========
|
||||||
* If the underline filesystem doesn't support the FIEMAP command,
|
* If the underline filesystem doesn't support the FIEMAP command,
|
||||||
automatically fallback to use FIBMAP and then the inode number for sorting
|
automatically fallback to use FIBMAP for sorting files.
|
||||||
files.
|
|
||||||
* Fixes the import of content files from previous version of SnapRAID that
|
* Fixes the import of content files from previous version of SnapRAID that
|
||||||
are the result of an incomplete sync.
|
are the result of an incomplete sync.
|
||||||
* Added a new -C, --gen-conf option to generate a dummy configuration
|
* Added a new -C, --gen-conf option to generate a dummy configuration
|
||||||
|
|
|
||||||
6
unix.c
6
unix.c
|
|
@ -141,14 +141,14 @@ 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 */
|
/* if works for ext2, ext3, ext4, xfs, btrfs */
|
||||||
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;
|
||||||
fm.fiemap.fm_flags = FIEMAP_FLAG_SYNC; /* required to ensure that just created files report a valid address and not 0 */
|
fm.fiemap.fm_flags = FIEMAP_FLAG_SYNC; /* required to ensure that just created files report a valid address and not 0 */
|
||||||
fm.fiemap.fm_extent_count = 1; /* we are interested only at the first block */
|
fm.fiemap.fm_extent_count = 1; /* we are interested only at the first block */
|
||||||
|
|
||||||
if (ioctl(f, FS_IOC_FIEMAP, &fm) == 0) {
|
if (ioctl(f, FS_IOC_FIEMAP, &fm) != -1) {
|
||||||
*physical = fm.fiemap.fm_extents[0].fe_physical;
|
*physical = fm.fiemap.fm_extents[0].fe_physical;
|
||||||
if (close(f) == -1)
|
if (close(f) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -167,7 +167,7 @@ int filephy(const char* path, struct stat* st, uint64_t* physical)
|
||||||
/* it works for jfs, reiserfs, ntfs-3g */
|
/* it works for jfs, reiserfs, ntfs-3g */
|
||||||
/* in exfat it always returns 0, that it's anyway better than the fake inodes */
|
/* 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) != -1) {
|
||||||
*physical = blknum;
|
*physical = blknum;
|
||||||
if (close(f) == -1)
|
if (close(f) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue