From ea41722c92313e884368106832d3454114ba88b3 Mon Sep 17 00:00:00 2001 From: Ryan Long Date: Fri, 30 Apr 2021 13:14:48 -0400 Subject: Change filesystem utime_h handler to utimens_h Also updated licenses. Closes #4400 Updates #3899 --- cpukit/libfs/src/defaults/default_ops.c | 34 ++++++++++++----- cpukit/libfs/src/defaults/default_utime.c | 32 ---------------- cpukit/libfs/src/defaults/default_utimens.c | 49 ++++++++++++++++++++++++ cpukit/libfs/src/dosfs/msdos_init.c | 11 +++--- cpukit/libfs/src/ftpfs/ftpfs.c | 44 ++++++++++++---------- cpukit/libfs/src/ftpfs/tftpDriver.c | 2 +- cpukit/libfs/src/imfs/imfs_init.c | 30 ++++++++++++--- cpukit/libfs/src/imfs/imfs_utime.c | 41 -------------------- cpukit/libfs/src/imfs/imfs_utimens.c | 58 +++++++++++++++++++++++++++++ cpukit/libfs/src/jffs2/src/fs-rtems.c | 11 +++--- cpukit/libfs/src/rfs/rtems-rfs-rtems.c | 16 ++++---- 11 files changed, 197 insertions(+), 131 deletions(-) delete mode 100644 cpukit/libfs/src/defaults/default_utime.c create mode 100644 cpukit/libfs/src/defaults/default_utimens.c delete mode 100644 cpukit/libfs/src/imfs/imfs_utime.c create mode 100644 cpukit/libfs/src/imfs/imfs_utimens.c (limited to 'cpukit/libfs') diff --git a/cpukit/libfs/src/defaults/default_ops.c b/cpukit/libfs/src/defaults/default_ops.c index 63ad2cefe1..45069e76d7 100644 --- a/cpukit/libfs/src/defaults/default_ops.c +++ b/cpukit/libfs/src/defaults/default_ops.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,16 +9,28 @@ */ /* - * Copyright (c) 2010 - * embedded brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * + * Copyright (C) 2010 embedded brains GmbH + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #include @@ -36,7 +50,7 @@ const rtems_filesystem_operations_table rtems_filesystem_operations_default = { .mount_h = rtems_filesystem_default_mount, .unmount_h = rtems_filesystem_default_unmount, .fsunmount_me_h = rtems_filesystem_default_fsunmount, - .utime_h = rtems_filesystem_default_utime, + .utimens_h = rtems_filesystem_default_utimens, .symlink_h = rtems_filesystem_default_symlink, .readlink_h = rtems_filesystem_default_readlink, .rename_h = rtems_filesystem_default_rename, diff --git a/cpukit/libfs/src/defaults/default_utime.c b/cpukit/libfs/src/defaults/default_utime.c deleted file mode 100644 index aaf4e445b6..0000000000 --- a/cpukit/libfs/src/defaults/default_utime.c +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file - * - * @ingroup LibIOFSOps File System Operations - * - * @brief RTEMS Default File System sets file access and modification times - */ - -/* - * COPYRIGHT (c) 2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -int rtems_filesystem_default_utime( - const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime -) -{ - rtems_set_errno_and_return_minus_one( ENOTSUP ); -} diff --git a/cpukit/libfs/src/defaults/default_utimens.c b/cpukit/libfs/src/defaults/default_utimens.c new file mode 100644 index 0000000000..c2321dc214 --- /dev/null +++ b/cpukit/libfs/src/defaults/default_utimens.c @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup LibIOFSOps File System Operations + * + * @brief RTEMS Default File System sets file access and modification times + */ + +/* + * COPYRIGHT (C) 2010, 2021 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +int rtems_filesystem_default_utimens( + const rtems_filesystem_location_info_t *loc, + struct timespec times[2] +) +{ + rtems_set_errno_and_return_minus_one( ENOTSUP ); +} diff --git a/cpukit/libfs/src/dosfs/msdos_init.c b/cpukit/libfs/src/dosfs/msdos_init.c index 67b16b64ed..a96b973cba 100644 --- a/cpukit/libfs/src/dosfs/msdos_init.c +++ b/cpukit/libfs/src/dosfs/msdos_init.c @@ -36,18 +36,17 @@ static int msdos_clone_node_info(rtems_filesystem_location_info_t *loc) return fat_file_reopen(fat_fd); } -static int msdos_utime( +static int msdos_utimens( const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime + struct timespec times[2] ) { fat_file_fd_t *fat_fd = loc->node_access; - if (actime != modtime) + if (times[0].tv_sec != times[1].tv_sec) rtems_set_errno_and_return_minus_one( ENOTSUP ); - fat_file_set_mtime(fat_fd, modtime); + fat_file_set_mtime(fat_fd, times[1].tv_sec); return RC_OK; } @@ -67,7 +66,7 @@ const rtems_filesystem_operations_table msdos_ops = { .mount_h = rtems_filesystem_default_mount, .unmount_h = rtems_filesystem_default_unmount, .fsunmount_me_h = msdos_shut_down, - .utime_h = msdos_utime, + .utimens_h = msdos_utimens, .symlink_h = rtems_filesystem_default_symlink, .readlink_h = rtems_filesystem_default_readlink, .rename_h = msdos_rename, diff --git a/cpukit/libfs/src/ftpfs/ftpfs.c b/cpukit/libfs/src/ftpfs/ftpfs.c index 5e0cb95dd3..06d06bc9cc 100644 --- a/cpukit/libfs/src/ftpfs/ftpfs.c +++ b/cpukit/libfs/src/ftpfs/ftpfs.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -5,27 +7,29 @@ */ /* - * Copyright (c) 2009-2012 embedded brains GmbH. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * (c) Copyright 2002 - * Thomas Doerfler - * IMD Ingenieurbuero fuer Microcomputertechnik - * Herbststr. 8 - * 82178 Puchheim, Germany - * + * COPYRIGHT (C) 2009-2012 embedded brains GmbH. + * COPYRIGHT (C) 2002 IMD Ingenieurbuero fuer Microcomputertechnik. * - * This code has been created after closly inspecting "tftpdriver.c" from Eric - * Norum. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -1384,7 +1388,7 @@ static const rtems_filesystem_operations_table rtems_ftpfs_ops = { .mount_h = rtems_filesystem_default_mount, .unmount_h = rtems_filesystem_default_unmount, .fsunmount_me_h = rtems_ftpfs_unmount_me, - .utime_h = rtems_filesystem_default_utime, + .utimens_h = rtems_filesystem_default_utimens, .symlink_h = rtems_filesystem_default_symlink, .readlink_h = rtems_filesystem_default_readlink, .rename_h = rtems_filesystem_default_rename, diff --git a/cpukit/libfs/src/ftpfs/tftpDriver.c b/cpukit/libfs/src/ftpfs/tftpDriver.c index 7cbb402b63..bc0e74ad86 100644 --- a/cpukit/libfs/src/ftpfs/tftpDriver.c +++ b/cpukit/libfs/src/ftpfs/tftpDriver.c @@ -1039,7 +1039,7 @@ static const rtems_filesystem_operations_table rtems_tftp_ops = { .mount_h = rtems_filesystem_default_mount, .unmount_h = rtems_filesystem_default_unmount, .fsunmount_me_h = rtems_tftpfs_shutdown, - .utime_h = rtems_filesystem_default_utime, + .utimens_h = rtems_filesystem_default_utimens, .symlink_h = rtems_filesystem_default_symlink, .readlink_h = rtems_filesystem_default_readlink, .rename_h = rtems_filesystem_default_rename, diff --git a/cpukit/libfs/src/imfs/imfs_init.c b/cpukit/libfs/src/imfs/imfs_init.c index 1b9b76912a..8685caae68 100644 --- a/cpukit/libfs/src/imfs/imfs_init.c +++ b/cpukit/libfs/src/imfs/imfs_init.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,12 +9,28 @@ */ /* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifdef HAVE_CONFIG_H @@ -40,7 +58,7 @@ static const rtems_filesystem_operations_table IMFS_ops = { .mount_h = IMFS_mount, .unmount_h = IMFS_unmount, .fsunmount_me_h = IMFS_fsunmount, - .utime_h = IMFS_utime, + .utimens_h = IMFS_utimens, .symlink_h = IMFS_symlink, .readlink_h = IMFS_readlink, .rename_h = IMFS_rename, diff --git a/cpukit/libfs/src/imfs/imfs_utime.c b/cpukit/libfs/src/imfs/imfs_utime.c deleted file mode 100644 index 21e5139ce7..0000000000 --- a/cpukit/libfs/src/imfs/imfs_utime.c +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file - * - * @ingroup IMFS - * - * @brief Set IMFS File Access and Modification Times - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -int IMFS_utime( - const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime -) -{ - IMFS_jnode_t *the_jnode; - - the_jnode = (IMFS_jnode_t *) loc->node_access; - - the_jnode->stat_atime = actime; - the_jnode->stat_mtime = modtime; - the_jnode->stat_ctime = time( NULL ); - - return 0; -} diff --git a/cpukit/libfs/src/imfs/imfs_utimens.c b/cpukit/libfs/src/imfs/imfs_utimens.c new file mode 100644 index 0000000000..78cc766ab0 --- /dev/null +++ b/cpukit/libfs/src/imfs/imfs_utimens.c @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup IMFS + * + * @brief Set IMFS File Access and Modification Times + */ + +/* + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +int IMFS_utimens( + const rtems_filesystem_location_info_t *loc, + struct timespec times[2] +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = (IMFS_jnode_t *) loc->node_access; + + the_jnode->stat_atime = times[0].tv_sec; + the_jnode->stat_mtime = times[1].tv_sec; + the_jnode->stat_ctime = time( NULL ); + + return 0; +} diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c index aae208ccef..8bc3d85cc3 100644 --- a/cpukit/libfs/src/jffs2/src/fs-rtems.c +++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c @@ -1118,10 +1118,9 @@ static int rtems_jffs2_statvfs( return 0; } -static int rtems_jffs2_utime( +static int rtems_jffs2_utimens( const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime + struct timespec times[2] ) { struct _inode *inode = rtems_jffs2_get_inode_by_location(loc); @@ -1129,8 +1128,8 @@ static int rtems_jffs2_utime( int eno; iattr.ia_valid = ATTR_ATIME | ATTR_MTIME | ATTR_CTIME; - iattr.ia_atime = actime; - iattr.ia_mtime = modtime; + iattr.ia_atime = times[0].tv_sec; + iattr.ia_mtime = times[1].tv_sec; iattr.ia_ctime = get_seconds(); eno = -jffs2_do_setattr(inode, &iattr); @@ -1186,7 +1185,7 @@ static const rtems_filesystem_operations_table rtems_jffs2_ops = { .mount_h = rtems_filesystem_default_mount, .unmount_h = rtems_filesystem_default_unmount, .fsunmount_me_h = rtems_jffs2_fsunmount, - .utime_h = rtems_jffs2_utime, + .utimens_h = rtems_jffs2_utimens, .symlink_h = rtems_jffs2_symlink, .readlink_h = rtems_jffs2_readlink, .rename_h = rtems_jffs2_rename, diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c index 35db9eeca1..0efab2cca6 100644 --- a/cpukit/libfs/src/rfs/rtems-rfs-rtems.c +++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems.c @@ -296,16 +296,14 @@ rtems_rfs_rtems_chown (const rtems_filesystem_location_info_t *pathloc, * This routine is the implementation of the utime() system call for the * RFS. * - * @param pathloc - * @param atime - * @param mtime + * @param pathloc The path to the file to be modified + * @param times The times to update the file to * return int */ static int -rtems_rfs_rtems_utime(const rtems_filesystem_location_info_t* pathloc, - time_t atime, - time_t mtime) +rtems_rfs_rtems_utimens(const rtems_filesystem_location_info_t* pathloc, + struct timespec times[2]) { rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (pathloc); rtems_rfs_ino ino = rtems_rfs_rtems_get_pathloc_ino (pathloc); @@ -318,8 +316,8 @@ rtems_rfs_rtems_utime(const rtems_filesystem_location_info_t* pathloc, return rtems_rfs_rtems_error ("utime: read inode", rc); } - rtems_rfs_inode_set_atime (&inode, atime); - rtems_rfs_inode_set_mtime (&inode, mtime); + rtems_rfs_inode_set_atime (&inode, times[0].tv_sec); + rtems_rfs_inode_set_mtime (&inode, times[1].tv_sec); rc = rtems_rfs_inode_close (fs, &inode); if (rc) @@ -735,7 +733,7 @@ const rtems_filesystem_operations_table rtems_rfs_ops = .mount_h = rtems_filesystem_default_mount, .unmount_h = rtems_filesystem_default_unmount, .fsunmount_me_h = rtems_rfs_rtems_shutdown, - .utime_h = rtems_rfs_rtems_utime, + .utimens_h = rtems_rfs_rtems_utimens, .symlink_h = rtems_rfs_rtems_symlink, .readlink_h = rtems_rfs_rtems_readlink, .rename_h = rtems_rfs_rtems_rename, -- cgit v1.2.3