diff options
author | Karel Zak | 2010-03-17 14:49:14 +0100 |
---|---|---|
committer | Karel Zak | 2010-03-17 14:49:14 +0100 |
commit | 6c2f2b9d62b196296e827f8bb7336a39e80695a9 (patch) | |
tree | b4da6079a7a7af0080989e37782cc07465d5d760 /shlibs/blkid/src/save.c | |
parent | lib: fix blkdev_find_size() (diff) | |
download | kernel-qcow2-util-linux-6c2f2b9d62b196296e827f8bb7336a39e80695a9.tar.gz kernel-qcow2-util-linux-6c2f2b9d62b196296e827f8bb7336a39e80695a9.tar.xz kernel-qcow2-util-linux-6c2f2b9d62b196296e827f8bb7336a39e80695a9.zip |
libblkid: add microsecond resolution for cache entries
The libblkid library uses stat.st_mtine to detect changes on the
device. The last update time of of the device in the cache is stored
as TIME= tag in the /etc/blkid.tab file.
Linux since 2.5.48 supports nanosecond resolution and more precise
time is available in the stat.st_mtim timespec struct.
This patch add microsecond precision to TIME= tag in the cache file,
old format:
TIME="<sec>"
the new format:
TIME="<sec>.<usec>"
This change is backwardly compatible.
Now, the blkid_verify() function checks stat.st_mtime and
stat.st_mtim.tv_nsec/1000.
Test:
# e2label /dev/sdb1 AAAA
old version:
# blkid -s LABEL /dev/sdb1; e2label /dev/sdb1 BBBB; blkid -s LABEL /dev/sdb1
/dev/sdb1: LABEL="AAAA"
/dev/sdb1: LABEL="AAAA"
new version:
# blkid -s LABEL /dev/sdb1; e2label /dev/sdb1 BBBB; blkid -s LABEL /dev/sdb1
/dev/sdb1: LABEL="AAAA"
/dev/sdb1: LABEL="BBBB"
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/save.c')
-rw-r--r-- | shlibs/blkid/src/save.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/shlibs/blkid/src/save.c b/shlibs/blkid/src/save.c index a1583ecca..c04c22427 100644 --- a/shlibs/blkid/src/save.c +++ b/shlibs/blkid/src/save.c @@ -37,9 +37,11 @@ static int save_dev(blkid_dev dev, FILE *file) printf("device %s, type %s\n", dev->bid_name, dev->bid_type ? dev->bid_type : "(null)")); - fprintf(file, - "<device DEVNO=\"0x%04lx\" TIME=\"%ld\"", - (unsigned long) dev->bid_devno, (long) dev->bid_time); + fprintf(file, "<device DEVNO=\"0x%04lx\" TIME=\"%ld.%ld\"", + (unsigned long) dev->bid_devno, + (long) dev->bid_time, + (long) dev->bid_utime); + if (dev->bid_pri) fprintf(file, " PRI=\"%d\"", dev->bid_pri); list_for_each(p, &dev->bid_tags) { |