mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
New APIs: Implement stat calls that return nanosecond timestamps (RHBZ#1144891).
The existing APIs guestfs_stat, guestfs_lstat and guestfs_lstatlist return a stat structure that contains atime, mtime and ctime fields that store only the timestamp in seconds. Modern filesystems can store timestamps down to nanosecond granularity, and the ordinary glibc stat(2) wrapper will return these in "hidden" stat fields: struct timespec st_atim; /* Time of last access. */ struct timespec st_mtim; /* Time of last modification. */ struct timespec st_ctim; /* Time of last status change. */ with the following macros defined for backwards compatibility: #define st_atime st_atim.tv_sec #define st_mtime st_mtim.tv_sec #define st_ctime st_ctim.tv_sec It is not possible to redefine guestfs_stat to return a longer struct guestfs_stat with room for the extra nanosecond fields, because that would break the ABI of guestfs_lstatlist as it returns an array containing consecutive stat structs (not pointers). Changing the return type of guestfs_stat would break API. Changing the generator to support symbol versioning is judged to be too intrusive. Therefore this adds a new struct (guestfs_statns) and new APIs: guestfs_statns guestfs_lstatns guestfs_lstatnslist which return the new struct (or array of structs in the last case). The old APIs may of course still be used, forever, but are deprecated and shouldn't be used in new programs. Because virt tools are compiled with -DGUESTFS_WARN_DEPRECATED=1, I have updated all the places calling the deprecated functions. This has revealed some areas for improvement: in particular virt-diff and virt-ls could be changed to print the nanosecond fields. FUSE now returns nanoseconds in stat calls where available, fixing https://bugzilla.redhat.com/show_bug.cgi?id=1144891 Notes about the implementation: - guestfs_internal_lstatlist has been removed and replaced by guestfs_internal_lstatnslist. As the former was an internal API no one should have been calling it, or indeed can call it unless they start defining their own header files. - guestfs_stat and guestfs_lstat have been changed into library-side functions. They, along with guestfs_lstatlist, are now implemented as wrappers around the new functions which just throw away the nanosecond fields.
This commit is contained in:
@@ -34,6 +34,7 @@ java_built_sources = \
|
||||
com/redhat/et/libguestfs/PV.java \
|
||||
com/redhat/et/libguestfs/Partition.java \
|
||||
com/redhat/et/libguestfs/Stat.java \
|
||||
com/redhat/et/libguestfs/StatNS.java \
|
||||
com/redhat/et/libguestfs/StatVFS.java \
|
||||
com/redhat/et/libguestfs/UTSName.java \
|
||||
com/redhat/et/libguestfs/VG.java \
|
||||
|
||||
1
java/com/redhat/et/libguestfs/.gitignore
vendored
1
java/com/redhat/et/libguestfs/.gitignore
vendored
@@ -12,6 +12,7 @@ MDStat.java
|
||||
PV.java
|
||||
Partition.java
|
||||
Stat.java
|
||||
StatNS.java
|
||||
StatVFS.java
|
||||
UTSName.java
|
||||
VG.java
|
||||
|
||||
Reference in New Issue
Block a user