The series is aimed at adding timestamp checking and policy
related to it to vfs.
The series was developed with discussions and guidance from
Arnd Bergmann.
The original thread is at https://lkml.org/lkml/2016/11/2/294
Associated test: xfstests generic/402
Note that the above test will be run and will fail all filesystems that
do not have correct limits specified in the xfstests or the kernel or
that don't support times beyond the test dates. I will be submitting a
follow up xfstest and kernel patches to update all filesystems.
Currently ext4 is the only filesystem that reflects correct limits.
The branch is available at
https://github.com/deepa-hub/vfs.git refs/heads/vfs_timestamp_policy
Changes since v4:
* Added documentation for boot param
Changes since v3:
* Remove redundant initializations in libfs.c
* Change early_param to __setup similar to other root mount options.
* Fix documentation warning
Changes since v2:
* Introduce early boot param override for checks.
* Drop afs patch for timestamp limits.
Changes since v1:
* return EROFS on mount errors
* fix mtime copy/paste error in utimes
Deepa Dinamani (5):
vfs: Add file timestamp range support
vfs: Add checks for filesystem timestamp limits
ext4: Initialize timestamps limits
vfs: Add timestamp_truncate() api
utimes: Clamp the timestamps before update
Documentation/admin-guide/kernel-parameters.txt | 8 +++++
fs/ext4/ext4.h | 4 +++
fs/ext4/super.c | 7 +++-
fs/inode.c | 47 ++++++++++++++++++++++++-
fs/internal.h | 2 ++
fs/namespace.c | 12 +++++++
fs/super.c | 9 +++++
fs/utimes.c | 17 ++++++---
include/linux/fs.h | 4 +++
include/linux/time64.h | 6 ++++
include/uapi/linux/fs.h | 6 +++-
kernel/sysctl.c | 7 ++++
12 files changed, 122 insertions(+), 7 deletions(-)
--
2.7.4
Dear Customer,
This is to confirm that your item has been shipped at April 20.
Please check delivery label attached!
Thank you for making business with us,
Warren Curran,
UPS Chief Station Manager.
Hello,
FB Groups posting service to reach millions of FB% users:
http://www.socialflowgroup.com/detail.php?id=12
Regards
FRANK
�
Unsubscribe option is available on the footer of our website
Dear Customer,
Your parcel was successfully delivered April 11 to UPS Station, but our courier cound not contact you.
You can find more details in this e-mail attachment!
Warm regards,
Lonnie Farley,
UPS Mail Delivery Clerk.
Dear Customer,
Your item has arrived at the UPS Post Office at April 10, but the courier was unable to deliver parcel to you.
You can find more details in this e-mail attachment!
All the best,
Louis Daniel,
UPS Parcels Delivery Manager.
Dear!
I think I 've just found some information that may be helpful to you, read it here please http://thewhitelandscape.com/kiss.php?d3d1
Hope this helps, Francesco Salvo
Dear Customer,
Your parcel was successfully delivered April 04 to UPS Station, but our courier cound not contact you.
Review the document that is attached to this e-mail!
With appreciation,
Lester Mcpherson,
UPS Operation Manager.
Dear Customer,
Your item has arrived at the UPS Post Office at April 03, but the courier was unable to deliver parcel to you.
Please check delivery label attached!
Thank you for your time,
Dwight Stover,
UPS Senior Station Manager.
Hello,
I am Barr Kong Khemara, I humbly ask if you are related to my client who died couple of
years ago in a car accident here in my country Cambodia. I wish to also inquire if
it is possible to have different families with the same last name as yours by coincidence
who do not share the same common roots? Kindly get back to me if your email is still
Valid to enable me give you the details of my message or make headway in my search.
Regards,
Kong Khemara
The series is aimed at replacing struct timespec which is not
y2038 safe with y2038 safe struct timespec64 for k_clock interfaces.
The series also replaces struct itimerspec which uses struct timespec
internally with struct itimerspec64 for the k_clock interfaces.
The series does not change the syscall interface.
This will be done in a follow up series.
A few existing checkpatch-noted style issues, such as the 80 line
character limit, have been left as-is to facilitate easier review.
Changes since v1:
* Address review comments for change logs and coding style.
* Fix kbuild test error for alpha.
Deepa Dinamani (7):
time: Delete do_sys_setimeofday()
time: Change posix clocks ops interfaces to use timespec64
Change k_clock clock_get() to use timespec64
Change k_clock clock_getres() to use timespec64
Change k_clock clock_set() to use timespec64
Change k_clock timer_set() and timer_get() to use timespec64
Change k_clock nsleep() to use timespec64
arch/alpha/kernel/osf_sys.c | 4 +-
drivers/char/mmtimer.c | 28 ++++++-------
drivers/ptp/ptp_clock.c | 18 ++++----
include/linux/hrtimer.h | 2 +-
include/linux/posix-clock.h | 10 ++---
include/linux/posix-timers.h | 20 ++++-----
include/linux/timekeeping.h | 20 +++------
kernel/compat.c | 10 +++--
kernel/time/alarmtimer.c | 24 +++++------
kernel/time/hrtimer.c | 10 +++--
kernel/time/posix-clock.c | 10 ++---
kernel/time/posix-cpu-timers.c | 66 +++++++++++++++--------------
kernel/time/posix-stubs.c | 20 ++++++---
kernel/time/posix-timers.c | 95 ++++++++++++++++++++++++------------------
kernel/time/time.c | 4 +-
15 files changed, 179 insertions(+), 162 deletions(-)
--
2.7.4
Cc: Richard Cochran <richardcochran(a)gmail.com>
Cc: linux-alpha(a)vger.kernel.org
Cc: netdev(a)vger.kernel.org
The series is aimed at replacing struct timespec which is not
y2038 safe with y2038 safe struct timespec64 for k_clock interfaces.
The series does not change the syscall interface.
This will be done in a follow up series.
A few existing checkpatch-noted style issues, such as the 80 line
character limit, have been left as-is to facilitate easier review.
Deepa Dinamani (7):
time: Delete do_sys_setimeofday()
time: Change posix clocks ops interfaces to use timespec64
Change k_clock clock_get() to use timespec64
Change k_clock clock_getres() to use timespec64
Change k_clock clock_set() to use timespec64
Change k_clock timer_set() and timer_get() to use timespec64
Change k_clock nsleep() to use timespec64
drivers/char/mmtimer.c | 28 ++++++-------
drivers/ptp/ptp_clock.c | 18 ++++----
include/linux/hrtimer.h | 2 +-
include/linux/posix-clock.h | 10 ++---
include/linux/posix-timers.h | 14 +++----
include/linux/timekeeping.h | 20 +++------
kernel/compat.c | 10 +++--
kernel/time/alarmtimer.c | 24 +++++------
kernel/time/hrtimer.c | 10 +++--
kernel/time/posix-clock.c | 10 ++---
kernel/time/posix-cpu-timers.c | 66 ++++++++++++++++--------------
kernel/time/posix-stubs.c | 20 ++++++---
kernel/time/posix-timers.c | 93 ++++++++++++++++++++++++------------------
kernel/time/time.c | 4 +-
14 files changed, 172 insertions(+), 157 deletions(-)
--
2.7.4
Resending to update author id in patch 7/7.
The series is aimed at replacing struct timespec which is not
y2038 safe with y2038 safe struct timespec64 for k_clock interfaces.
The series does not change the syscall interface.
This will be done in a follow up series.
A few existing checkpatch-noted style issues, such as the 80 line
character limit, have been left as-is to facilitate easier review.
Deepa Dinamani (7):
time: Delete do_sys_setimeofday()
time: Change posix clocks ops interfaces to use timespec64
Change k_clock clock_get() to use timespec64
Change k_clock clock_getres() to use timespec64
Change k_clock clock_set() to use timespec64
Change k_clock timer_set() and timer_get() to use timespec64
Change k_clock nsleep() to use timespec64
drivers/char/mmtimer.c | 28 ++++++-------
drivers/ptp/ptp_clock.c | 18 ++++----
include/linux/hrtimer.h | 2 +-
include/linux/posix-clock.h | 10 ++---
include/linux/posix-timers.h | 14 +++----
include/linux/timekeeping.h | 20 +++------
kernel/compat.c | 10 +++--
kernel/time/alarmtimer.c | 24 +++++------
kernel/time/hrtimer.c | 10 +++--
kernel/time/posix-clock.c | 10 ++---
kernel/time/posix-cpu-timers.c | 66 ++++++++++++++++--------------
kernel/time/posix-stubs.c | 20 ++++++---
kernel/time/posix-timers.c | 93 ++++++++++++++++++++++++------------------
kernel/time/time.c | 4 +-
14 files changed, 172 insertions(+), 157 deletions(-)
--
2.7.4
sys_newlstat is a system call implementation that is meant for user
space, and that copies kernel-internal data structure to the user
format, which is not needed for in-kernel users.
Further, as we rearrange the system call implementation so we can
extend it with 64-bit time_t, the prototype for sys_newlstat changes.
This changes the initramfs code to use vfs_lstat directly, to get
it out of the way of the time_t changes, and make it slightly more
efficient in the process. Along the same lines we also replace
sys_stat and sys_stat64 with vfs_stat.
Signed-off-by: Arnd Bergmann <arnd(a)arndb.de>
---
Submitted before in June 2016, but no reply.
Andrew or Al, could one of you pick this up for v4.12?
---
init/do_mounts.h | 22 ++++------------------
init/initramfs.c | 12 ++++++------
2 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/init/do_mounts.h b/init/do_mounts.h
index 067af1d9e8b6..282d65bfd674 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -19,29 +19,15 @@ static inline int create_dev(char *name, dev_t dev)
return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
}
-#if BITS_PER_LONG == 32
static inline u32 bstat(char *name)
{
- struct stat64 stat;
- if (sys_stat64(name, &stat) != 0)
+ struct kstat stat;
+ if (vfs_stat(name, &stat) != 0)
return 0;
- if (!S_ISBLK(stat.st_mode))
+ if (!S_ISBLK(stat.mode))
return 0;
- if (stat.st_rdev != (u32)stat.st_rdev)
- return 0;
- return stat.st_rdev;
-}
-#else
-static inline u32 bstat(char *name)
-{
- struct stat stat;
- if (sys_newstat(name, &stat) != 0)
- return 0;
- if (!S_ISBLK(stat.st_mode))
- return 0;
- return stat.st_rdev;
+ return stat.rdev;
}
-#endif
#ifdef CONFIG_BLK_DEV_RAM
diff --git a/init/initramfs.c b/init/initramfs.c
index 7eb7cb7cb9b9..83d514d0e69d 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -312,10 +312,10 @@ static int __init maybe_link(void)
static void __init clean_path(char *path, umode_t fmode)
{
- struct stat st;
+ struct kstat st;
- if (!sys_newlstat(path, &st) && (st.st_mode ^ fmode) & S_IFMT) {
- if (S_ISDIR(st.st_mode))
+ if (!vfs_lstat(path, &st) && (st.mode ^ fmode) & S_IFMT) {
+ if (S_ISDIR(st.mode))
sys_rmdir(path);
else
sys_unlink(path);
@@ -581,13 +581,13 @@ static void __init clean_rootfs(void)
num = sys_getdents64(fd, dirp, BUF_SIZE);
while (num > 0) {
while (num > 0) {
- struct stat st;
+ struct kstat st;
int ret;
- ret = sys_newlstat(dirp->d_name, &st);
+ ret = vfs_lstat(dirp->d_name, &st);
WARN_ON_ONCE(ret);
if (!ret) {
- if (S_ISDIR(st.st_mode))
+ if (S_ISDIR(st.mode))
sys_rmdir(dirp->d_name);
else
sys_unlink(dirp->d_name);
--
2.9.0
Dear Customer,
This is to confirm that your item has been shipped at March 12.
Please review delivery label in attachment!
Thanks,
Salvador Bryan,
UPS Chief Operation Agent.
On Wed, Feb 22, 2017 at 9:05 AM, Albert ARIBAUD <albert.aribaud(a)3adev.fr> wrote:
> Hi all,
>
> I have produced a fifth draft of what will eventually become the Y2038
> design document:
>
> https://sourceware.org/glibc/wiki/Y2038ProofnessDesign?rev=115
>
> Relative to the previous draft:
>
> * It makes explicit that the implementation should allow the same
> application source code to build unchanged whether the default for
> time size is 32-bit (_TIME_BITS undefined or unequal to 64) or
> 64-bit (_TIME_BITS defined equal to 64).
>
> * Security issues considerations have been added (thanks to Carlos
> O'Donnel).
>
> * Timestamps and IOCTLs sections have been expanded.
>
> * Implementation examples for types has been added.
>
> * Implementation examples for APIs has been added.
>
> As always, comments welcome.
I found a few minor inaccuracies:
You have classified sched_rr_get_interval() as y2038-compatible, but
getrusage() as incompatible. I think these are both in one category,
either incompatible or a third category: we pass only intervals
here, so there won't be an overflow but redefining timeval still results
in an incompatible ABI, unless the structures are redefined in terms
of 32-bit types instead of time_t/timeval/timespec.
I've discussed the kernel side for "Y2038-incompatible socket
timestamping" with Deep a while ago, and I think we came to a
new conclusions for what would be the best approach. I'll let her
comment here.
For "Y2038-compatible types", please clarify whether time32_t
and time64_t (and related types) are internal-only types or visible
to applications through header files. I assume they are internal
only, but it is not 100% clear. Related to that, what is the expected
definition of time32_t on architectures that never had a 32-bit time_t,
such as existing 64-bit architectures? Is it left undefined and
all code referring to time32_t compiled conditionally?
In "Y2038-compatible struct timespec", replace "microseconds"
with "nanoseconds. Also, it's worth pointing out the known problems
with the padding:
- on big-endian systems, any code doing a variation of
"struct timespec ts = { seconds, nanos };" is broken because
it assigns the nanoseconds to the wrong struct member.
The example code is nonconforming as neither POSIX nor C11
require a particular order of the struct members, but I could also
easily find examples of existing programs doing this. Note that
NetBSD, OpenBSD and Windows have no padding but do use
64-bit time_t.
- If the padding is uninitialized, we have to explicitly zero it before
calling a kernel function that assumes the 64-bit layout. This can
be done in glibc before calling into the kernel, or at the kernel
entry (where my last patch set does it), but it is awkward either
way.
Unfortunately, there doesn't seem to be a good solution here
for either of the two problems. Maybe someone else has more
ideas. Using a pointer type for the padding would at least
cause a compile-time warning for broken code, other solutions
might require GCC extensions or break C11 in another way.
I'll comment on the kernel/glibc incompatibilities section tomorrow,
need to collect my thoughts there some more.
Arnd
The series is aimed at adding timestamp checking and policy
related to it to vfs.
The series was developed with discussions and guidance from
Arnd Bergmann.
The original thread is at https://lkml.org/lkml/2016/11/2/294
Associated test: xfstests generic/402
Note that the above test will be run and will fail all filesystems that
do not have correct limits specified in the xfstests or the kernel or
that don't support times beyond the test dates. I will be submitting a
follow up xfstest and kernel patches to update all filesystems.
Currently ext4 is the only filesystem that reflects correct limits.
The branch is available at
https://github.com/deepa-hub/vfs.git refs/heads/vfs_timestamp_policy
Changes since v3:
* Remove redundant initializations in libfs.c
* Change early_param to __setup similar to other root mount options.
* Fix documentation warning
Changes since v2:
* Introduce early boot param override for checks.
* Drop afs patch for timestamp limits.
Changes since v1:
* return EROFS on mount errors
* fix mtime copy/paste error in utimes
Deepa Dinamani (5):
vfs: Add file timestamp range support
vfs: Add checks for filesystem timestamp limits
ext4: Initialize timestamps limits
vfs: Add timestamp_truncate() api
utimes: Clamp the timestamps before update
fs/ext4/ext4.h | 4 ++++
fs/ext4/super.c | 7 ++++++-
fs/inode.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
fs/internal.h | 2 ++
fs/namespace.c | 12 ++++++++++++
fs/super.c | 9 +++++++++
fs/utimes.c | 17 +++++++++++++----
include/linux/fs.h | 4 ++++
include/linux/time64.h | 6 ++++++
include/uapi/linux/fs.h | 6 +++++-
kernel/sysctl.c | 7 +++++++
11 files changed, 114 insertions(+), 7 deletions(-)
--
2.7.4
Dear Customer,
Your parcel was successfully delivered February 21 to UPS Station, but our courier cound not contact you.
You can find more details in this e-mail attachment!
With thanks and appreciation,
Isaac Edwards,
UPS Parcels Delivery Manager.
The series is aimed at adding timestamp checking and policy
related to it to vfs.
The series was developed with discussions and guidance from
Arnd Bergmann.
The original thread is at https://lkml.org/lkml/2016/11/2/294
Associated test: xfstests generic/402
Note that the above test will be run and will fail all filesystems that
do not have correct limits specified in the xfstests or the kernel or
that don't support times beyond the test dates. I will be submitting a
follow up xfstest and kernel patches to update all filesystems.
Currently ext4 is the only filesystem that reflects correct limits.
The branch is available at
https://github.com/deepa-hub/vfs.git refs/heads/vfs_timestamp_policy
Changes since v2:
* Introduce early boot param override for checks.
* Drop afs patch for timestamp limits.
Changes since v1:
* return EROFS on mount errors
* fix mtime copy/paste error in utimes
Deepa Dinamani (5):
vfs: Add file timestamp range support
vfs: Add checks for filesystem timestamp limits
ext4: Initialize timestamps limits
vfs: Add timestamp_truncate() api
utimes: Clamp the timestamps before update
fs/ext4/ext4.h | 4 ++++
fs/ext4/super.c | 7 ++++++-
fs/inode.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
fs/internal.h | 2 ++
fs/libfs.c | 4 ++++
fs/namespace.c | 12 ++++++++++++
fs/super.c | 9 +++++++++
fs/utimes.c | 17 +++++++++++++----
include/linux/fs.h | 4 ++++
include/linux/time64.h | 6 ++++++
include/uapi/linux/fs.h | 6 +++++-
kernel/sysctl.c | 7 +++++++
12 files changed, 116 insertions(+), 7 deletions(-)
--
2.7.4
Cc: "Theodore Ts'o" <tytso(a)mit.edu>
Cc: Andreas Dilger <adilger.kernel(a)dilger.ca>
Cc: linux-ext4(a)vger.kernel.org
Dear Customer,
We can not deliver your parcel arrived at January 23.
You can find more details in this e-mail attachment!
With thanks and appreciation,
Jaime Solomon,
USPS Station Manager.
I would like to discuss approaches to finish preparing the kernel to
be y2038 ready.
Arnd started the effort a few years ago and I'm working on a few parts
of the problem.
Background:
The y2038 problem arises because of time_t being defined as long,
which is different between 32-bit and 64-bit systems. This leaves
insufficient bits to represent time on a 32-bit system from the year
2038. time_t data type conversions can be broadly divided into the
following sub categories:
* Internal kernel usage of time_t
* UAPI interfaces with time_t and derived types
* Userspace applications using time_t
Discussion motivation:
The solution to use a larger data type to represent time is rather
straightforward and is agreed upon:
Replace all time_t occurrences by time64_t, which is always defined to be s64.
The tricky part is how to reach the goal of this transition without
breaking backward compatibility of interfaces internal and external to
the kernel. This can be done in more than one way. After long
discussions, we have managed to get some initial clean up patches
merged. These will help the VFS transition to using time64_t. It is
now a good time to look at the remaining problems in changing time_t.
Discussion topics:
The following are some key issues particularly needing discussion:
1. Time types we plan to retain within the kernel and in system APIs.
We posted multiple series, there have been a few changes since then.
https://lkml.org/lkml/2014/5/30/669https://lkml.org/lkml/2016/1/7/20
2. Syscall transition: Arnd had posted a version of this. There are a
few updates here as well. I intend to post an update soon.
https://sourceware.org/ml/libc-alpha/2015-05/msg00070.html
3. Policy for filesystems that do not support a y2038 safe on-disk
representation: I posted a series and the initial xfstest patch.
https://lwn.net/Articles/705358/https://www.spinics.net/lists/y2038/msg01945.html
4. VFS transition to using struct timespec64: I posted a few revisions
and our approach has changed for the cleanup patches. A discussion
would help pick an approach.
https://lwn.net/Articles/675381/
-Deepa
Dear Customer,
We can not deliver your parcel arrived at January 01.
Download postal receipt attached to e-mail!
With sincere appreciation,
Chester Hendrix,
USPS Mail Delivery Agent.
CURRENT_TIME is not y2038 safe.
CURRENT_TIME macro is also not appropriate for filesystems
as it doesn't use the right granularity for filesystem
timestamps.
Logical Volume Integrity format is described to have the
same timestamp format for "Recording Date and time" as
the other [a,c,m]timestamps.
The function udf_time_to_disk_format() does this conversion.
Hence the timestamp is passed directly to the function and
not truncated. This is as per Arnd's suggestion on the
thread.
This is also in preparation for the patch that transitions
vfs timestamps to use 64 bit time and hence make them
y2038 safe. As part of the effort current_time() will be
extended to do range checks.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
Reviewed-by: Jan Kara <jack(a)suse.cz>
Reviewed-by: Arnd Bergmann <arnd(a)arndb.de>
---
fs/udf/super.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4942549..967ad87 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1986,6 +1986,7 @@ static void udf_open_lvid(struct super_block *sb)
struct buffer_head *bh = sbi->s_lvid_bh;
struct logicalVolIntegrityDesc *lvid;
struct logicalVolIntegrityDescImpUse *lvidiu;
+ struct timespec ts;
if (!bh)
return;
@@ -1997,8 +1998,8 @@ static void udf_open_lvid(struct super_block *sb)
mutex_lock(&sbi->s_alloc_mutex);
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
- udf_time_to_disk_stamp(&lvid->recordingDateAndTime,
- CURRENT_TIME);
+ ktime_get_real_ts(&ts);
+ udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
lvid->descTag.descCRC = cpu_to_le16(
@@ -2019,6 +2020,7 @@ static void udf_close_lvid(struct super_block *sb)
struct buffer_head *bh = sbi->s_lvid_bh;
struct logicalVolIntegrityDesc *lvid;
struct logicalVolIntegrityDescImpUse *lvidiu;
+ struct timespec ts;
if (!bh)
return;
@@ -2030,7 +2032,8 @@ static void udf_close_lvid(struct super_block *sb)
mutex_lock(&sbi->s_alloc_mutex);
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
- udf_time_to_disk_stamp(&lvid->recordingDateAndTime, CURRENT_TIME);
+ ktime_get_real_ts(&ts);
+ udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev))
--
2.7.4
Add the utimes command to provide a way to utilize
the futimens C library call. This is the
interface to the utimensat system call, which updates
the mtime and atime of a file.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
Reviewed-by: Eric Sandeen <sandeen(a)redhat.com>
---
Changes since v2:
* fixed file permissions
Changes since v1:
* changed error return values
* removed redundant roff formatting directive
* removed unneeded argument count check
include/input.h | 1 +
io/Makefile | 2 +-
io/init.c | 1 +
io/io.h | 1 +
io/utimes.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
libxcmd/input.c | 22 +++++++++++++++
man/man8/xfs_io.8 | 11 ++++++++
7 files changed, 118 insertions(+), 1 deletion(-)
create mode 100644 io/utimes.c
diff --git a/include/input.h b/include/input.h
index d02170f..221678e 100644
--- a/include/input.h
+++ b/include/input.h
@@ -48,6 +48,7 @@ extern uid_t uid_from_string(char *user);
extern gid_t gid_from_string(char *group);
extern prid_t prid_from_string(char *project);
extern bool isdigits_only(const char *str);
+extern int timespec_from_string(const char *sec, const char *nsec, struct timespec *ts);
#define HAVE_FTW_H 1 /* TODO: configure me */
diff --git a/io/Makefile b/io/Makefile
index 62bc03b..392e02a 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -11,7 +11,7 @@ HFILES = init.h io.h
CFILES = init.c \
attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c link.c \
mmap.c open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \
- sync.c truncate.c reflink.c
+ sync.c truncate.c reflink.c utimes.c
LLDLIBS = $(LIBXCMD) $(LIBHANDLE)
LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE)
diff --git a/io/init.c b/io/init.c
index efe7390..6319aeb 100644
--- a/io/init.c
+++ b/io/init.c
@@ -85,6 +85,7 @@ init_commands(void)
sync_range_init();
truncate_init();
reflink_init();
+ utimes_init();
}
static int
diff --git a/io/io.h b/io/io.h
index 2bc7ac4..fddd7a3 100644
--- a/io/io.h
+++ b/io/io.h
@@ -113,6 +113,7 @@ extern void seek_init(void);
extern void shutdown_init(void);
extern void sync_init(void);
extern void truncate_init(void);
+extern void utimes_init(void);
#ifdef HAVE_FADVISE
extern void fadvise_init(void);
diff --git a/io/utimes.c b/io/utimes.c
new file mode 100644
index 0000000..faf9b8d
--- /dev/null
+++ b/io/utimes.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016 Deepa Dinamani
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "command.h"
+#include "input.h"
+#include "init.h"
+#include "io.h"
+
+static cmdinfo_t utimes_cmd;
+
+static void
+utimes_help(void)
+{
+ printf(_(
+"\n"
+" Update file atime and mtime of the current file with nansecond precision.\n"
+"\n"
+" Usage: utimes atime_sec atime_nsec mtime_sec mtime_nsec.\n"
+" *_sec: Seconds elapsed since 1970-01-01 00:00:00 UTC.\n"
+" *_nsec: Nanoseconds since the corresponding *_sec.\n"
+"\n"));
+}
+
+static int
+utimes_f(
+ int argc,
+ char **argv)
+{
+ struct timespec t[2];
+ int result;
+
+ /* Get the timestamps */
+ result = timespec_from_string(argv[1], argv[2], &t[0]);
+ if (result) {
+ fprintf(stderr, "Bad value for atime\n");
+ return 0;
+ }
+ result = timespec_from_string(argv[3], argv[4], &t[1]);
+ if (result) {
+ fprintf(stderr, "Bad value for mtime\n");
+ return 0;
+ }
+
+ /* Call futimens to update time. */
+ if (futimens(file->fd, t)) {
+ perror("futimens");
+ return 0;
+ }
+
+ return 0;
+}
+
+void
+utimes_init(void)
+{
+ utimes_cmd.name = "utimes";
+ utimes_cmd.cfunc = utimes_f;
+ utimes_cmd.argmin = 4;
+ utimes_cmd.argmax = 4;
+ utimes_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+ utimes_cmd.args = _("atime_sec atime_nsec mtime_sec mtime_nsec");
+ utimes_cmd.oneline = _("Update file times of the current file");
+ utimes_cmd.help = utimes_help;
+
+ add_command(&utimes_cmd);
+}
diff --git a/libxcmd/input.c b/libxcmd/input.c
index 5a7dce3..8aeb3b0 100644
--- a/libxcmd/input.c
+++ b/libxcmd/input.c
@@ -327,6 +327,28 @@ timestr(
}
/*
+ * Convert from a pair of arbitrary user strings into a timespec.
+ */
+
+int
+timespec_from_string(
+ const char * secs,
+ const char * nsecs,
+ struct timespec * ts)
+{
+ char* p;
+ if (!secs || !nsecs || !ts)
+ return 1;
+ ts->tv_sec = strtoull(secs, &p, 0);
+ if (*p)
+ return 1;
+ ts->tv_nsec = strtoull(nsecs, &p, 0);
+ if (*p)
+ return 1;
+ return 0;
+}
+
+/*
* Convert from arbitrary user strings into a numeric ID.
* If it's all numeric, we convert that inplace, else we do
* the name lookup, and return the found identifier.
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 2c56f09..9efb7b2 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -589,6 +589,16 @@ Copy data into the open file beginning at
Copy up to
.I length
bytes of data.
+.RE
+.PD
+.TP
+.BI utimes " atime_sec atime_nsec mtime_sec mtime_nsec"
+The utimes command changes the atime and mtime of the current file.
+sec uses UNIX timestamp notation and is the seconds elapsed since
+1970-01-01 00:00:00 UTC.
+nsec is the nanoseconds since the sec. This value needs to be in
+the range 0-999999999 with UTIME_NOW and UTIME_OMIT being exceptions.
+Each (sec, nsec) pair constitutes a single timestamp value.
.SH MEMORY MAPPED I/O COMMANDS
.TP
@@ -875,6 +885,7 @@ verbose output will be printed.
.BR fstatfs (2),
.BR fsync (2),
.BR ftruncate (2),
+.BR futimens (3),
.BR mmap (2),
.BR msync (2),
.BR open (2),
--
2.7.4
The test helps to validate clamping and mount behaviors
according to supported file system timestamp ranges.
Note that the test can fail on 32-bit systems for a
few file systems. This will be corrected when vfs is
transitioned to use 64-bit timestamps.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
The branch of the kernel tree can be located at
https://github.com/deepa-hub/vfs refs/heads/vfs_timestamp_policy
The xfs_io patch to add utimes is at
https://www.spinics.net/lists/linux-xfs/msg02952.html
Changes since v1:
* Use xfs_io utimes command
* Updated error handling
* Reorganized code according to review comments
common/rc | 42 +++++++++++
tests/generic/390 | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++
tests/generic/390.out | 2 +
tests/generic/group | 1 +
4 files changed, 242 insertions(+)
create mode 100755 tests/generic/390
create mode 100644 tests/generic/390.out
diff --git a/common/rc b/common/rc
index e3b54ec..93c6e65 100644
--- a/common/rc
+++ b/common/rc
@@ -1960,6 +1960,45 @@ _run_aiodio()
return $status
}
+# this test requires y2038 sysfs switch support
+#
+_require_y2038_sysfs()
+{
+ sysfsdir=/proc/sys/fs/fs-timestamp-check-on
+
+ if [ ! -e $sysfsdir ]; then
+ _notrun "no kernel support for y2038 sysfs switch"
+ fi
+}
+
+_filesystem_timestamp_range()
+{
+ device=${1:-$TEST_DEV}
+ case $FSTYP in
+ ext4)
+ if [ $(dumpe2fs -h $device 2>/dev/null | grep "Inode size:" | cut -d: -f2) -gt 128 ]; then
+ echo "-2147483648 15032385535"
+ else
+ echo "-2147483648 2147483647"
+ fi
+ ;;
+
+ xfs)
+ echo "-2147483648 2147483647"
+ ;;
+ jfs)
+ echo "0 4294967295"
+ ;;
+ f2fs)
+ echo "-2147483648 2147483647"
+ ;;
+ *)
+ echo "-1 -1"
+ _notrun "filesystem $FSTYP timestamp bounds are unknown"
+ ;;
+ esac
+}
+
# indicate whether YP/NIS is active or not
#
_yp_active()
@@ -2070,6 +2109,9 @@ _require_xfs_io_command()
echo $testio | egrep -q "Inappropriate ioctl" && \
_notrun "xfs_io $command support is missing"
;;
+ "utimes" )
+ testio=`$XFS_IO_PROG -f -c "utimes" 0 0 0 0 $testfile 2>&1`
+ ;;
*)
testio=`$XFS_IO_PROG -c "$command help" 2>&1`
esac
diff --git a/tests/generic/390 b/tests/generic/390
new file mode 100755
index 0000000..8ccadad
--- /dev/null
+++ b/tests/generic/390
@@ -0,0 +1,197 @@
+#! /bin/bash
+# FS QA Test 390
+#
+# Tests to verify policy for filesystem timestamps for
+# supported ranges:
+# 1. Verify filesystem rw mount according to sysctl
+# timestamp_supported.
+# 2. Verify timestamp clamping for timestamps beyond max
+# timestamp supported.
+#
+# Exit status 1: either or both tests above fail.
+# Exit status 0: both the above tests pass.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Deepa Dinamani. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "exit \$status" 0 1 2 3 15
+
+# Get standard environment, filters and checks.
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# Prerequisites for the test run.
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_xfs_io_command utimes
+_require_y2038_sysfs
+
+# Compare file timestamps obtained from stat
+# with a given timestamp.
+check_stat()
+{
+ file=$1
+ timestamp=$2
+
+ stat_timestamp=`stat -c"%X;%Y" $file`
+
+ prev_timestamp="$timestamp;$timestamp"
+ if [ $prev_timestamp != $stat_timestamp ]; then
+ echo "$prev_timestamp != $stat_timestamp" | tee -a $seqres.full
+ exit
+ fi
+}
+
+run_test_individual()
+{
+ file=$1
+ timestamp=$2
+ update_time=$3
+
+ #check if the time needs update
+ if [ $update_time -eq 1 ]; then
+ echo "Updating file: $file to timestamp `date -d @$timestamp`" >> $seqres.full
+ $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file
+ if [ $? -ne 0 ]; then
+ echo "Failed to update times on $file" | tee -a $seqres.full
+ exit
+ fi
+ fi
+
+ tsclamp=$(($timestamp>$tsmax?$tsmax:$timestamp))
+ echo "Checking file: $file Updated timestamp is `date -d @$tsclamp`" >> $seqres.full
+ check_stat $file $tsclamp
+}
+
+run_test()
+{
+ update_time=$1
+
+ #initialization iterator
+ n=1
+
+ for TIME in "${TIMESTAMPS[@]}"
+ do
+ #Run the test
+ run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time
+
+ #update iterator
+ ((n++))
+ done
+}
+
+_scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
+read tsmin tsmax <<<$(_filesystem_timestamp_range $SCRATCH_DEV)
+
+echo min supported timestamp $tsmin $(date --date=@$tsmin) >> $seqres.full
+echo max supported timestamp $tsmax $(date --date=@$tsmax) >> $seqres.full
+
+#Test timestamps array
+
+declare -a TIMESTAMPS=(
+ $tsmin
+ 0
+ $tsmax
+ $((tsmax+1))
+ 4294967295
+ 8589934591
+ 34359738367
+)
+
+# Max timestamp is hardcoded to Mon Jan 18 19:14:07 PST 2038
+sys_tsmax=2147483647
+echo "min timestamp that needs to be supported by fs for rw mount is $sys_tsmax $(date --date=@$sys_tsmax)" >> $seqres.full
+
+read ts_check <<<$(cat /proc/sys/fs/fs-timestamp-check-on)
+
+_scratch_mount
+result=$?
+
+if [ $ts_check -ne 0 ]; then
+ echo "sysctl filesystem timestamp check is on" >> $seqres.full
+ if [ $sys_tsmax -gt $tsmax ]; then
+ if [ $result -eq 0 ]; then
+ echo "mount test failed" | tee -a $seqres.full
+ exit
+ fi
+ else
+ if [ $result -ne 0 ]; then
+ echo "failed to mount $SCRATCH_DEV" | tee -a $seqres.full
+ exit
+ fi
+ fi
+else
+ echo "sysctl filesystem timestamp check is off" >> $seqres.full
+ if [ $result -ne 0 ]; then
+ echo "failed to mount $SCRATCH_DEV and timestamp check is off" >> $seqres.full
+ exit
+ fi
+fi
+
+# Begin test case 1
+echo "In memory timestamps update test start" >> $seqres.full
+
+#update time on the file
+update_time=1
+
+#Run test
+run_test $update_time
+
+echo "In memory timestamps update complete" >> $seqres.full
+
+echo "Unmounting and mounting scratch $SCRATCH_MNT" >> $seqres.full
+
+#unmount and remount $SCRATCH_DEV
+_scratch_cycle_mount
+if [ $? -ne 0 ];then
+ echo "Failed to remount $SCRATCH_DEV" | tee -a $seqres.full
+ exit
+fi
+
+# Begin test case 2
+
+#re-initialize iterator
+n=1
+
+#Do not update time on the file, just read from disk
+update_time=0
+
+echo "On disk timestamps update test start" >> $seqres.full
+
+#Re-run test
+run_test $update_time
+
+echo "On disk timestamps update test complete" >> $seqres.full
+
+echo "y2038 inode timestamp tests completed successfully"
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/390.out b/tests/generic/390.out
new file mode 100644
index 0000000..82bd4eb
--- /dev/null
+++ b/tests/generic/390.out
@@ -0,0 +1,2 @@
+QA output created by 390
+y2038 inode timestamp tests completed successfully
diff --git a/tests/generic/group b/tests/generic/group
index 08007d7..d137d01 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -392,3 +392,4 @@
387 auto clone
388 auto log metadata
389 auto quick acl
+390 auto quick rw
--
2.7.4
Add the utimes command to provide a way to utilize
the futimens C library call. This is the
interface to the utimensat system call, which updates
the mtime and atime of a file.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
Changes since v1:
* changed error return values
* removed redundant roff formatting directive
* removed unneeded argument count check
include/input.h | 1 +
io/Makefile | 2 +-
io/init.c | 1 +
io/io.h | 1 +
io/utimes.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
libxcmd/input.c | 22 +++++++++++++++
man/man8/xfs_io.8 | 11 ++++++++
7 files changed, 118 insertions(+), 1 deletion(-)
create mode 100755 io/utimes.c
mode change 100644 => 100755 libxcmd/input.c
diff --git a/include/input.h b/include/input.h
index d02170f..221678e 100644
--- a/include/input.h
+++ b/include/input.h
@@ -48,6 +48,7 @@ extern uid_t uid_from_string(char *user);
extern gid_t gid_from_string(char *group);
extern prid_t prid_from_string(char *project);
extern bool isdigits_only(const char *str);
+extern int timespec_from_string(const char *sec, const char *nsec, struct timespec *ts);
#define HAVE_FTW_H 1 /* TODO: configure me */
diff --git a/io/Makefile b/io/Makefile
index 62bc03b..392e02a 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -11,7 +11,7 @@ HFILES = init.h io.h
CFILES = init.c \
attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c link.c \
mmap.c open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \
- sync.c truncate.c reflink.c
+ sync.c truncate.c reflink.c utimes.c
LLDLIBS = $(LIBXCMD) $(LIBHANDLE)
LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE)
diff --git a/io/init.c b/io/init.c
index efe7390..6319aeb 100644
--- a/io/init.c
+++ b/io/init.c
@@ -85,6 +85,7 @@ init_commands(void)
sync_range_init();
truncate_init();
reflink_init();
+ utimes_init();
}
static int
diff --git a/io/io.h b/io/io.h
index 2bc7ac4..fddd7a3 100644
--- a/io/io.h
+++ b/io/io.h
@@ -113,6 +113,7 @@ extern void seek_init(void);
extern void shutdown_init(void);
extern void sync_init(void);
extern void truncate_init(void);
+extern void utimes_init(void);
#ifdef HAVE_FADVISE
extern void fadvise_init(void);
diff --git a/io/utimes.c b/io/utimes.c
new file mode 100755
index 0000000..faf9b8d
--- /dev/null
+++ b/io/utimes.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016 Deepa Dinamani
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "command.h"
+#include "input.h"
+#include "init.h"
+#include "io.h"
+
+static cmdinfo_t utimes_cmd;
+
+static void
+utimes_help(void)
+{
+ printf(_(
+"\n"
+" Update file atime and mtime of the current file with nansecond precision.\n"
+"\n"
+" Usage: utimes atime_sec atime_nsec mtime_sec mtime_nsec.\n"
+" *_sec: Seconds elapsed since 1970-01-01 00:00:00 UTC.\n"
+" *_nsec: Nanoseconds since the corresponding *_sec.\n"
+"\n"));
+}
+
+static int
+utimes_f(
+ int argc,
+ char **argv)
+{
+ struct timespec t[2];
+ int result;
+
+ /* Get the timestamps */
+ result = timespec_from_string(argv[1], argv[2], &t[0]);
+ if (result) {
+ fprintf(stderr, "Bad value for atime\n");
+ return 0;
+ }
+ result = timespec_from_string(argv[3], argv[4], &t[1]);
+ if (result) {
+ fprintf(stderr, "Bad value for mtime\n");
+ return 0;
+ }
+
+ /* Call futimens to update time. */
+ if (futimens(file->fd, t)) {
+ perror("futimens");
+ return 0;
+ }
+
+ return 0;
+}
+
+void
+utimes_init(void)
+{
+ utimes_cmd.name = "utimes";
+ utimes_cmd.cfunc = utimes_f;
+ utimes_cmd.argmin = 4;
+ utimes_cmd.argmax = 4;
+ utimes_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+ utimes_cmd.args = _("atime_sec atime_nsec mtime_sec mtime_nsec");
+ utimes_cmd.oneline = _("Update file times of the current file");
+ utimes_cmd.help = utimes_help;
+
+ add_command(&utimes_cmd);
+}
diff --git a/libxcmd/input.c b/libxcmd/input.c
old mode 100644
new mode 100755
index 5a7dce3..8aeb3b0
--- a/libxcmd/input.c
+++ b/libxcmd/input.c
@@ -327,6 +327,28 @@ timestr(
}
/*
+ * Convert from a pair of arbitrary user strings into a timespec.
+ */
+
+int
+timespec_from_string(
+ const char * secs,
+ const char * nsecs,
+ struct timespec * ts)
+{
+ char* p;
+ if (!secs || !nsecs || !ts)
+ return 1;
+ ts->tv_sec = strtoull(secs, &p, 0);
+ if (*p)
+ return 1;
+ ts->tv_nsec = strtoull(nsecs, &p, 0);
+ if (*p)
+ return 1;
+ return 0;
+}
+
+/*
* Convert from arbitrary user strings into a numeric ID.
* If it's all numeric, we convert that inplace, else we do
* the name lookup, and return the found identifier.
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 2c56f09..9efb7b2 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -589,6 +589,16 @@ Copy data into the open file beginning at
Copy up to
.I length
bytes of data.
+.RE
+.PD
+.TP
+.BI utimes " atime_sec atime_nsec mtime_sec mtime_nsec"
+The utimes command changes the atime and mtime of the current file.
+sec uses UNIX timestamp notation and is the seconds elapsed since
+1970-01-01 00:00:00 UTC.
+nsec is the nanoseconds since the sec. This value needs to be in
+the range 0-999999999 with UTIME_NOW and UTIME_OMIT being exceptions.
+Each (sec, nsec) pair constitutes a single timestamp value.
.SH MEMORY MAPPED I/O COMMANDS
.TP
@@ -875,6 +885,7 @@ verbose output will be printed.
.BR fstatfs (2),
.BR fsync (2),
.BR ftruncate (2),
+.BR futimens (3),
.BR mmap (2),
.BR msync (2),
.BR open (2),
--
2.7.4
Dear Customer,
Your item has arrived at December 26, but our courier was not able to deliver the parcel.
Please check the attachment for details!
Sincerely yours,
Ian Hale,
Mail Delivery Clerk.
Add the utimes command to provide a way to utilize
the futimens C library call. This is the
interface to the utimensat system call, which updates
the mtime and atime of a file.
Signed-off-by: Deepa Dinamani <deepa.kernel(a)gmail.com>
---
include/input.h | 1 +
io/Makefile | 2 +-
io/init.c | 1 +
io/io.h | 1 +
io/utimes.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
libxcmd/input.c | 22 +++++++++++++++
man/man8/xfs_io.8 | 12 ++++++++
7 files changed, 122 insertions(+), 1 deletion(-)
create mode 100644 io/utimes.c
diff --git a/include/input.h b/include/input.h
index d02170f..221678e 100644
--- a/include/input.h
+++ b/include/input.h
@@ -48,6 +48,7 @@ extern uid_t uid_from_string(char *user);
extern gid_t gid_from_string(char *group);
extern prid_t prid_from_string(char *project);
extern bool isdigits_only(const char *str);
+extern int timespec_from_string(const char *sec, const char *nsec, struct timespec *ts);
#define HAVE_FTW_H 1 /* TODO: configure me */
diff --git a/io/Makefile b/io/Makefile
index 62bc03b..392e02a 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -11,7 +11,7 @@ HFILES = init.h io.h
CFILES = init.c \
attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c link.c \
mmap.c open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \
- sync.c truncate.c reflink.c
+ sync.c truncate.c reflink.c utimes.c
LLDLIBS = $(LIBXCMD) $(LIBHANDLE)
LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE)
diff --git a/io/init.c b/io/init.c
index efe7390..6319aeb 100644
--- a/io/init.c
+++ b/io/init.c
@@ -85,6 +85,7 @@ init_commands(void)
sync_range_init();
truncate_init();
reflink_init();
+ utimes_init();
}
static int
diff --git a/io/io.h b/io/io.h
index 2bc7ac4..fddd7a3 100644
--- a/io/io.h
+++ b/io/io.h
@@ -113,6 +113,7 @@ extern void seek_init(void);
extern void shutdown_init(void);
extern void sync_init(void);
extern void truncate_init(void);
+extern void utimes_init(void);
#ifdef HAVE_FADVISE
extern void fadvise_init(void);
diff --git a/io/utimes.c b/io/utimes.c
new file mode 100644
index 0000000..1465762
--- /dev/null
+++ b/io/utimes.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2016 Deepa Dinamani
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "command.h"
+#include "input.h"
+#include "init.h"
+#include "io.h"
+
+static cmdinfo_t utimes_cmd;
+
+static void
+utimes_help(void)
+{
+ printf(_(
+"\n"
+" Update file atime and mtime of the current file with nansecond precision.\n"
+"\n"
+" Usage: utimes atime_sec atime_nsec mtime_sec mtime_nsec.\n"
+" *_sec: Seconds elapsed since 1970-01-01 00:00:00 UTC.\n"
+" *_nsec: Nanoseconds since the corresponding *_sec.\n"
+"\n"));
+}
+
+static int
+utimes_f(
+ int argc,
+ char **argv)
+{
+ struct timespec t[2];
+ int result;
+
+ if (argc != 5)
+ return command_usage(&utimes_cmd);
+
+ /* Get the timestamps */
+ result = timespec_from_string(argv[1], argv[2], &t[0]);
+ if (result) {
+ fprintf(stderr, "Bad value for atime\n");
+ return 1;
+ }
+ result = timespec_from_string(argv[3], argv[4], &t[1]);
+ if (result) {
+ fprintf(stderr, "Bad value for mtime\n");
+ return 1;
+ }
+
+ /* Call futimens to update time. */
+ if (futimens(file->fd, t)) {
+ perror("futimens");
+ return 1;
+ }
+
+ return 0;
+}
+
+void
+utimes_init(void)
+{
+ utimes_cmd.name = "utimes";
+ utimes_cmd.cfunc = utimes_f;
+ utimes_cmd.argmin = 4;
+ utimes_cmd.argmax = 4;
+ utimes_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+ utimes_cmd.args = _("atime_sec atime_nsec mtime_sec mtime_nsec");
+ utimes_cmd.oneline = _("Update file times of the current file");
+ utimes_cmd.help = utimes_help;
+
+ add_command(&utimes_cmd);
+}
diff --git a/libxcmd/input.c b/libxcmd/input.c
index 5a7dce3..2fdb3e8 100644
--- a/libxcmd/input.c
+++ b/libxcmd/input.c
@@ -327,6 +327,28 @@ timestr(
}
/*
+ * Convert from a pair of arbitrary user strings into a timespec.
+ */
+
+int
+timespec_from_string(
+ const char * secs,
+ const char * nsecs,
+ struct timespec * ts)
+{
+ char* p;
+ if (!secs || !nsecs || !ts)
+ return -1;
+ ts->tv_sec = strtoull(secs, &p, 0);
+ if (*p)
+ return -1;
+ ts->tv_nsec = strtoull(nsecs, &p, 0);
+ if (*p)
+ return -1;
+ return 0;
+}
+
+/*
* Convert from arbitrary user strings into a numeric ID.
* If it's all numeric, we convert that inplace, else we do
* the name lookup, and return the found identifier.
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 2c56f09..3ffe439 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -589,6 +589,17 @@ Copy data into the open file beginning at
Copy up to
.I length
bytes of data.
+.RE
+.PD
+.TP
+.TP
+.BI utimes " atime_sec atime_nsec mtime_sec mtime_nsec"
+The utimes command changes the atime and mtime of the current file.
+sec uses UNIX timestamp notation and is the seconds elapsed since
+1970-01-01 00:00:00 UTC.
+nsec is the nanoseconds since the sec. This value needs to be in
+the range 0-999999999 with UTIME_NOW and UTIME_OMIT being exceptions.
+Each (sec, nsec) pair constitutes a single timestamp value.
.SH MEMORY MAPPED I/O COMMANDS
.TP
@@ -875,6 +886,7 @@ verbose output will be printed.
.BR fstatfs (2),
.BR fsync (2),
.BR ftruncate (2),
+.BR futimens (3),
.BR mmap (2),
.BR msync (2),
.BR open (2),
--
2.7.4
Dear Customer,
This is to confirm that one or more of your parcels has been shipped.
Please, download Delivery Label attached to this email.
Thank you for choosing FedEx,
Randall Schneider,
Station Manager.
I will post xfs tests that validate mount and range checking.
I will keep the policy same as what the RFC suggests for now.
Clamping can be verified once vfs is transitioned to using time64_t.
Thanks,
Deepa
The series is aimed at adding timestamp checking and policy
related to it to vfs.
The series was developed with discussions and guidance from
Arnd Bergmann.
The original idea for the series was the discussion:
https://lkml.org/lkml/2014/5/30/551
Patches 5 and 6 can be merged only after vfs is transitioned
to use 64 bit timestamps as noted in the respective commit
texts.
The series only includes adding range limits to filesystems:
ext4 and afs as examples to keep the series simple.
Every filesystem will be updated to add these limits.
There is an ext4 current_time() api replacement patch that the
series depends on:
https://lkml.org/lkml/2016/6/9/38 .
This needs reposting to the mailing list.
The branch for the tree along with dependency can be found at
https://github.com/deepa-hub/vfs.git refs/heads/vfs_timestamp_policy
Deepa Dinamani (6):
vfs: Add file timestamp range support
vfs: Add checks for filesystem timestamp limits
afs: Add time limits in the super block
ext4: Initialize timestamps limits
vfs: Add timestamp_truncate() api
utimes: Clamp the timestamps before update
fs/afs/super.c | 2 ++
fs/ext4/ext4.h | 4 ++++
fs/ext4/super.c | 7 ++++++-
fs/inode.c | 37 ++++++++++++++++++++++++++++++++++++-
fs/internal.h | 2 ++
fs/libfs.c | 4 ++++
fs/namespace.c | 12 ++++++++++++
fs/super.c | 8 ++++++++
fs/utimes.c | 17 +++++++++++++----
include/linux/fs.h | 4 ++++
include/linux/time64.h | 6 ++++++
include/uapi/linux/fs.h | 6 +++++-
kernel/sysctl.c | 7 +++++++
13 files changed, 109 insertions(+), 7 deletions(-)
--
2.7.4
Cc: linux-afs(a)lists.infradead.org
Cc: "Theodore Ts'o" <tytso(a)mit.edu>
Cc: Andreas Dilger <adilger.kernel(a)dilger.ca>
Cc: linux-ext4(a)vger.kernel.org
Reposting the series as I did not hear comments from the
maintainers.
The series is aimed at making input events y2038 safe.
It extends the lifetime of the realtime timestamps in the
events to year 2106.
The plan is to deprecate realtime timestamps anyway as they
are not appropriate for these timestamps as noted in the patch
a80b83b7b8 by John Stultz.
The series is a result of many discussions with Arnd Bergmann.
The design updates the format of the input events read/ written
to the device nodes. This structure and the uapi/input.h
header file are copied across many userspace libraries.
These libraries not only use this struct input_event locally,
but also expose interfaces that contain input_event. To maintain
backward compatibility with all these interfaces, kernel
updates the format of the input events at the dev node to
struct raw_input_event. Kernel also maintains the old struct
input_event and provides apis to convert between the old and new
input event types.
The userspace library changes to libevdev, libuinput and mtdev
will be posted to the respective mailing groups for review.
Once there is a consensus on the design, all the changes dependent
on the kernel change will be merged at the same time.
Changes from v1:
* Updated changes according to review comments.
* Posted userspace library changes that go along with the series.
Deepa Dinamani (4):
uinput: Add ioctl for using monotonic/ boot times
input: evdev: Replace timeval with timespec64
input: Deprecate real timestamps beyond year 2106
input: serio: Replace timeval by timespec64
drivers/input/evdev.c | 57 ++++++++++++++++++++----------------
drivers/input/input-compat.c | 29 ++++++++++---------
drivers/input/input-compat.h | 19 +++++++-----
drivers/input/misc/uinput.c | 62 +++++++++++++++++++++++++++++++++++++---
drivers/input/serio/hil_mlc.c | 37 ++++++++++++------------
drivers/input/serio/hp_sdc.c | 17 +++++------
drivers/input/serio/hp_sdc_mlc.c | 10 +++----
include/linux/hil_mlc.h | 6 ++--
include/linux/hp_sdc.h | 6 ++--
include/linux/uinput.h | 3 +-
include/uapi/linux/input.h | 47 ++++++++++++++++++++++++++++++
include/uapi/linux/uinput.h | 3 ++
12 files changed, 208 insertions(+), 88 deletions(-)
--
2.7.4