[PATCH v1 2/5] libcsupport: Implement utime() in terms of utimensat()
utime() now calls utimensat() to update file access and modification timestamps. Closes #4397 --- cpukit/libcsupport/src/utime.c | 74 +++--- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index e2d8883..610ce35 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c @@ -1,58 +1,66 @@ /** * @file * - * @brief Set File Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in seconds. */ /* - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2009, 2021. * 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. + * 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 -/* FIXME: This include is a workaround for a broken in Newlib */ -#include +#include +#include +#include #include -#include - /** - * POSIX 1003.1b 5.5.6 - Set File Access and Modification Times + * https://pubs.opengroup.org/onlinepubs/009604599/functions/utime.html + * + * Set file access and modification times */ -int utime( const char *path, const struct utimbuf *times ) +int utime( + const char *path, + const struct utimbuf *times +) { - int rv = 0; - rtems_filesystem_eval_path_context_t ctx; - int eval_flags = RTEMS_FS_FOLLOW_LINK; - const rtems_filesystem_location_info_t *currentloc = -rtems_filesystem_eval_path_start( &ctx, path, eval_flags ); - struct utimbuf now_times; - - if ( times == NULL ) { -time_t now = time( NULL ); - -now_times.actime = now; -now_times.modtime = now; - -times = &now_times; - } + struct timespec new_times[2]; - rv = (*currentloc->mt_entry->ops->utime_h)( -currentloc, -times->actime, -times->modtime - ); + if( times == NULL ) +return utimensat(AT_FDCWD, path, NULL, 0); - rtems_filesystem_eval_path_cleanup( &ctx ); + new_times[0].tv_sec = times->actime; + new_times[0].tv_nsec = 0; + new_times[1].tv_sec = times->modtime; + new_times[1].tv_nsec = 0; - return rv; + return utimensat(AT_FDCWD, path, new_times, 0); } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH v1 2/5] libcsupport: Implement utime() in terms of utimensat()
On 03/05/2021 15:40, Ryan Long wrote: utime() now calls utimensat() to update file access and modification timestamps. Mention license change? Closes #4397 --- cpukit/libcsupport/src/utime.c | 74 +++--- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index e2d8883..610ce35 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c SDPX license identifier? @@ -1,58 +1,66 @@ /** * @file * - * @brief Set File Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in seconds. Does the file set the file access and modification times in seconds? I used the following term in my recent @file rework: * @brief This source file contains the implementation of utime(). */ /* - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2009, 2021. * On-Line Applications Research Corporation (OAR). This copyright line doesn't match the new template. Could we please use the new template or update it to allow more formats. In the future we could use the copyright statement patterns in a script. * - * 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. + * 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. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v1 2/5] libcsupport: Implement utime() in terms of utimensat()
-Original Message- From: Sebastian Huber Sent: Monday, May 3, 2021 11:54 PM To: Ryan Long ; devel@rtems.org Subject: Re: [PATCH v1 2/5] libcsupport: Implement utime() in terms of utimensat() On 03/05/2021 15:40, Ryan Long wrote: > utime() now calls utimensat() to update file access and modification > timestamps. Mention license change? [Ryan Long] I'll add that for V2. > > Closes #4397 > --- > cpukit/libcsupport/src/utime.c | 74 > +++--- > 1 file changed, 41 insertions(+), 33 deletions(-) > > diff --git a/cpukit/libcsupport/src/utime.c > b/cpukit/libcsupport/src/utime.c index e2d8883..610ce35 100644 > --- a/cpukit/libcsupport/src/utime.c > +++ b/cpukit/libcsupport/src/utime.c SDPX license identifier? > @@ -1,58 +1,66 @@ > /** >* @file >* > - * @brief Set File Access and Modification Times >* @ingroup libcsupport > + * > + * @brief Set file access and modification times in seconds. Does the file set the file access and modification times in seconds? I used the following term in my recent @file rework: * @brief This source file contains the implementation of utime(). [Ryan Long] utime() is used with filesystems that only use seconds for their file timestamps. Utimes() is used with filesystems that support millisecond granularity and utimensat() is used with filesystems that support nanosecond granularity. I'll change that brief though. >*/ > > /* > - * COPYRIGHT (c) 1989-1999. > + * COPYRIGHT (c) 1989-2009, 2021. >* On-Line Applications Research Corporation (OAR). This copyright line doesn't match the new template. Could we please use the new template or update it to allow more formats. In the future we could use the copyright statement patterns in a script. [Ryan Long] Since the template is 'Copyright (C) , ', I should change it to 'Copyright (C) 1989, 2021 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. > + * 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. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel