mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Introduce is_same_inode macro, now including a comparison of st_dev.
* lib/misc/lvm-file.h (is_same_inode): Define. * lib/filters/filter-persistent.c (persistent_filter_dump): Use is_same_inode in place of a direct st_ino-only comparison. * lib/locking/file_locking.c (_release_lock, _lock_file): Likewise.
This commit is contained in:
parent
57015b12e2
commit
c93e6b5f79
@ -1,5 +1,5 @@
|
||||
Version 2.02.28 -
|
||||
================================
|
||||
Introduce is_same_inode macro, now including a comparison of st_dev.
|
||||
Don't leak a file descriptor in _lock_file(), when flock fails.
|
||||
Add SUN's LDOM virtual block device to filters
|
||||
Split metadata-external.h out from metadata.h for the tools to use.
|
||||
|
@ -208,7 +208,7 @@ int persistent_filter_dump(struct dev_filter *f)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!memcmp(&info.st_ino, &info2.st_ino, sizeof(ino_t)))
|
||||
if (is_same_inode(info, info2))
|
||||
break;
|
||||
|
||||
fcntl_unlock_file(lockfd);
|
||||
|
@ -64,7 +64,7 @@ static int _release_lock(const char *file, int unlock)
|
||||
if (!flock(ll->lf, LOCK_NB | LOCK_EX) &&
|
||||
!stat(ll->res, &buf1) &&
|
||||
!fstat(ll->lf, &buf2) &&
|
||||
!memcmp(&buf1.st_ino, &buf2.st_ino, sizeof(ino_t)))
|
||||
is_same_inode(buf1, buf2))
|
||||
if (unlink(ll->res))
|
||||
log_sys_error("unlink", ll->res);
|
||||
|
||||
@ -190,7 +190,7 @@ static int _lock_file(const char *file, int flags)
|
||||
}
|
||||
|
||||
if (!stat(ll->res, &buf1) && !fstat(ll->lf, &buf2) &&
|
||||
!memcmp(&buf1.st_ino, &buf2.st_ino, sizeof(ino_t)))
|
||||
is_same_inode(buf1, buf2))
|
||||
break;
|
||||
} while (!(flags & LCK_NONBLOCK));
|
||||
|
||||
|
@ -52,4 +52,8 @@ void sync_dir(const char *file);
|
||||
int fcntl_lock_file(const char *file, short lock_type, int warn_if_read_only);
|
||||
void fcntl_unlock_file(int lockfd);
|
||||
|
||||
#define is_same_inode(buf1, buf2) \
|
||||
((buf1).st_ino == (buf2).st_ino && \
|
||||
(buf1).st_dev == (buf2).st_dev)
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user