rtems-bsps: add ability to print architecture/bsps list
Hi, The attached patch adds the ability to print the set of bsps in the form of architecture/bsp. This is useful for feeding into other programs. Thanks, Ryan 0001-rtems-bsps-add-ability-to-print-architecture-bsp-lis.patch Description: 0001-rtems-bsps-add-ability-to-print-architecture-bsp-lis.patch ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Oddity with address recorded for gcc instrumentation on ARM
Hi, We turned on gcc instrumentation with a test function, and got the following records. Timestamp Channel CPU Event type Contents TID PrioPID Source 18:00:06.483 017 719 stream_0 0 FUNCTION_ENTRY code=0x104ec7 167837716 0167837716 18:00:06.483 371 019 stream_0 0 FUNCTION_EXIT code=0x104ec7 167837716 0167837716 Notice that the code value ends in "7". The actual address of the function is 0x104ec6. Can someone explain this? Thanks, Ryan ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
rtems-record-lttng live support
Hi, Can rtems-record-lttng provide a live feed of traces? Thanks, Ryan ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: Debugging rtems-docs Sphinx issue
Gedare, I applied your patch, but it still isn’t working for me. The error is the same in the console output and config.log. The ./waf configure command that I’m running is ./waf configure --prefix='`pwd`' –pdf I don’t know if that could be part of the issue. Thanks, Ryan From: Gedare Bloom Sent: Wednesday, February 3, 2021 11:28 AM To: Ryan Long Cc: devel@rtems.org Subject: Re: Debugging rtems-docs Sphinx issue Hi Ryan, On Tue, Feb 2, 2021 at 2:53 PM Ryan Long mailto:ryan.l...@oarcorp.com>> wrote: Hi, I’m working on https://devel.rtems.org/ticket/4229#ticket . The following command is being issued: /home/rlong/nta-workspace/nta-docs/sphinx/bin/sphinx-build -b html -D extensions=sphinxcontrib.bibtex -C . out contents.rst -> If I run this with the “->” at the end, I get “bash: syntax error near unexpected token `newline'” as the erro message. If I run it without the arrow, It prints out the usage, and it says “sphinx-build: error: cannot find files ['contents.rst']”. That -> is not valid bash syntax. I guess that is something out of the waf error logging. You can see where these checks are built in common/waf.py contents.rst appears to be something generated dynamically by that waf.py in check_sphinx_extension, so that is not something you can test independently. I tried adding the recommended configuration settings to each of the conf.py files as sphinxcontrib-bibtex’s documentation recommended, and I added “master_doc = 'contents'” to each of them as well based on the warning message from config.log. Neither had any effect. I think the master_doc thing is unrelated. Does anyone know how to fix this? It looks like the important part is actually this: err: Extension error: You must configure the bibtex_bibfiles setting So our waf.py that checks the sphinxcontrib.bibtex extension does not pass through the bibtex_bibfiles setting. Since that check uses the -C flag, the config file doesn't get read, so modifying conf.py will bring no joy. That said, we should include that bibtex_bibfiles in our conf.py, so I add that in a separate patch. You can create a file contents.rst by hand and put in it the same: .. COMMENT sphinx test then you can run $ sphinx-build -b html -D extensions=sphinx.ext.autodoc -C . out contents.rst for example Unfortunately, I can't seem to figure out how to pass the bibtex_bibfiles list to the command line. Everything I tried ends up parsing it into individual characters, e.g., $ touch refs.bib $ sphinx-build -b html -D extensions=sphinxcontrib.bibtex -D bibtex_bibfiles=refs.bib -C . out contents.rst WARNING: could not open bibtex file /mnt/devel/rtems/rtems-docs/build/r. WARNING: could not open bibtex file /mnt/devel/rtems/rtems-docs/build/e. WARNING: could not open bibtex file /mnt/devel/rtems/rtems-docs/build/f. WARNING: could not open bibtex file /mnt/devel/rtems/rtems-docs/build/s. then it dies because it can't open . What I could get to work is to create a minimal config file and pass that: $ echo "bibtex_bibfiles = ['refs.bib']" > conf.py sphinx-build -b html -D extensions=sphinxcontrib.bibtex -c . . out contents.rst So I made the check rule dynamically create refs.bib and conf.py within the testbuild directory. It might be more elegant to figure out how to pass the _list_ that contains refs.bib in the command line -D version, but this seemed to work. I also added the bibtex_bibfiles setting to our common/conf.py file. Please try out the patch I just sent. Thanks, Gedare Thanks, Ryan ___ devel mailing list devel@rtems.org<mailto:devel@rtems.org> http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1] GcovData: Convert to c++ and fix formatting
Converted printf statements to c++'s method of printing, adjusted to use c++ file handling, changed char arrays to strings, fixed inconsistent formatting. --- tester/covoar/GcovData.cc | 388 +--- tester/covoar/GcovData.h | 32 +-- tester/covoar/GcovFunctionData.cc | 457 -- tester/covoar/GcovFunctionData.h | 76 --- 4 files changed, 509 insertions(+), 444 deletions(-) diff --git a/tester/covoar/GcovData.cc b/tester/covoar/GcovData.cc index e8b8573..7847ce6 100644 --- a/tester/covoar/GcovData.cc +++ b/tester/covoar/GcovData.cc @@ -1,5 +1,4 @@ /* - * TODO: use strings instead of cstrings for reliability and saving memory * TODO: use global buffers * */ @@ -34,71 +33,73 @@ namespace Gcov { { } - bool GcovData::readGcnoFile( const char* const fileName ) + bool GcovData::readGcnoFile( const std::string& fileName ) { -intstatus; -FILE* gcovFile; -char* tempString; -char* tempString2; -char* tempString3; - -if ( strlen(fileName) >= FILE_NAME_LENGTH ){ - fprintf( -stderr, -"ERROR: File name is too long to be correctly stored: %u\n", -(unsigned int) strlen(fileName) - ); +int status; +std::ifstream gcovFile; +std::string tempString; +std::string tempString2; +std::string tempString3; +size_t index; + +if ( fileName.length() >= FILE_NAME_LENGTH ) { + std::cerr << "ERROR: File name is too long to be correctly stored: " +<< fileName.length() << std::endl; return false; } -strcpy( gcnoFileName, fileName ); -strcpy( gcdaFileName, fileName ); -strcpy( textFileName, fileName ); -strcpy( cFileName, fileName ); -tempString = strstr( gcdaFileName,".gcno" ); -tempString2 = strstr( textFileName,".gcno" ); -tempString3 = strstr( cFileName,".gcno" ); - -if ( (tempString == NULL) && (tempString2 == NULL) ){ - fprintf(stderr, "ERROR: incorrect name of *.gcno file\n"); -} -else -{ - strcpy( tempString, ".gcda"); // construct gcda file name - strcpy( tempString2, ".txt"); // construct report file name - strcpy( tempString3, ".c"); // construct source file name + +gcnoFileName = fileName; +gcdaFileName = fileName; +textFileName = fileName; +cFileName= fileName; +tempString = gcdaFileName; +tempString2 = textFileName; +tempString3 = cFileName; + +index = tempString.find( ".gcno" ); +if ( index == std::string::npos ) { + std::cerr << "ERROR: incorrect name of *.gcno file" << std::endl; + return false; +} else { + // construct gcda file name + tempString = tempString.replace( index, strlen( ".gcno" ), ".gcda" ); + + // construct report file name + tempString2 = tempString2.replace( index, strlen( ".gcno" ), ".txt" ); + + // construct source file name + tempString3 = tempString3.replace( index, strlen( ".gcno" ), ".c" ); } // Debug message -// fprintf( stderr, "Readning file: %s\n", gcnoFileName); +// std::cerr << "Reading file: " << gcnoFileName << std::endl; // Open the notes file. -gcovFile = fopen( gcnoFileName, "r" ); +gcovFile.open( gcnoFileName ); if ( !gcovFile ) { - fprintf( stderr, "Unable to open %s\n", gcnoFileName ); + std::cerr << "Unable to open " << gcnoFileName << std::endl; return false; } // Read and validate the gcnoPreamble (magic, version, timestamp) from the file -status = readFilePreamble( , gcovFile, GCNO_MAGIC ); -if ( status <= 0 ){ - fprintf( stderr, "Unable to read %s\n", gcnoFileName ); - fclose( gcovFile ); +status = readFilePreamble( , , GCNO_MAGIC ); +if ( status <= 0 ) { + std::cerr << "Unable to read " << gcnoFileName << std::endl; return false; } //Read all remaining frames from file -while( readFrame(gcovFile) ){} +while( readFrame( ) ) {} -fclose( gcovFile ); return true; } - bool GcovData::writeGcdaFile () + bool GcovData::writeGcdaFile() { gcov_preamble preamble; gcov_frame_header header; -FILE* gcdaFile; +std::ofstream gcdaFile; functions_iterator_t currentFunction; arcs_iterator_t currentArc; uint32_t buffer; @@ -109,32 +110,35 @@ namespace Gcov { uint64_t llBuffer[4096];// TODO: Use common buffer gcov_statistics objectStats; gcov_statistics programStats; -size_tstatus; +size_tbytes_before; +size_tbytes_after; // Debug message -// fprintf( stderr, "Writing file: %s\n", gcdaFileName); +//std::cerr << "Writing file: " << gcdaFileName <<
[PATCH v1] cpukit: Add timespecisnonnegative to Makefile.am
--- cpukit/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index 78e33b6..df970e5 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -998,6 +998,7 @@ librtemscpu_a_SOURCES += score/src/timespeclessthan.c librtemscpu_a_SOURCES += score/src/timespecsubtract.c librtemscpu_a_SOURCES += score/src/timespectoticks.c librtemscpu_a_SOURCES += score/src/timespecdivide.c +librtemscpu_a_SOURCES += score/src/timespecisnonnegative.c librtemscpu_a_SOURCES += score/src/timespecdividebyinteger.c librtemscpu_a_SOURCES += score/src/timespecgetasnanoseconds.c librtemscpu_a_SOURCES += score/src/coretod.c -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v2 1/5] libcsupport: Added futimens() and utimensat()
Reply is below. -Original Message- From: Gedare Bloom Sent: Monday, May 10, 2021 12:36 PM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH v2 1/5] libcsupport: Added futimens() and utimensat() On Thu, May 6, 2021 at 1:51 PM Ryan Long wrote: > > Created futimens.c and utimensat.c to add support for the POSIX > methods futimens() and utimensat(). > > utime() and utimes() are considered obsolote by POSIX, but RTEMS will > continue to support them. > > Closes #4396 > --- > cpukit/Makefile.am | 2 + > cpukit/include/rtems/libio_.h | 60 +- > cpukit/libcsupport/src/futimens.c | 87 ++ > cpukit/libcsupport/src/utimensat.c | 239 + > spec/build/cpukit/librtemscpu.yml | 2 + > 5 files changed, 387 insertions(+), 3 deletions(-) create mode > 100644 cpukit/libcsupport/src/futimens.c create mode 100644 > cpukit/libcsupport/src/utimensat.c > > diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index > b0df610..29b4207 100644 > --- a/cpukit/Makefile.am > +++ b/cpukit/Makefile.am > @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c > librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c > librtemscpu_a_SOURCES += libcsupport/src/utime.c > librtemscpu_a_SOURCES += libcsupport/src/utimes.c > +librtemscpu_a_SOURCES += libcsupport/src/futimens.c > +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c > librtemscpu_a_SOURCES += libcsupport/src/utsname.c > librtemscpu_a_SOURCES += libcsupport/src/vprintk.c > librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git > a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index > e9eb462..7a0a169 100644 > --- a/cpukit/include/rtems/libio_.h > +++ b/cpukit/include/rtems/libio_.h > @@ -2,13 +2,12 @@ > * @file > * > * @brief LibIO Internal Interface > - * > + * > * This file is the libio internal interface. > */ > > /* > - * COPYRIGHT (c) 1989-2011. > - * On-Line Applications Research Corporation (OAR). > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). > * > * Modifications to support reference counting in the file system are > * Copyright (c) 2012 embedded brains GmbH. > @@ -357,6 +356,61 @@ static inline void rtems_filesystem_instance_unlock( >(*mt_entry->ops->unlock_h)( mt_entry ); } > > +/* Prototypes for functions used between utimensat() and futimens() > +*/ > + We don't usually have this kind of separator comment. > +/** > + * @brief Checks the tv_sec member of a timespec struct > + * > + * @param[in] time The timespec struct to be validated > + * > + * Ensures that the value in the tv_sec member is non-negative. > + * > + * @retval Returns true if the tv_sec member is a valid value, otherwise > false. > + */ > +bool rtems_filesystem_utime_tv_sec_valid( struct timespec time ); > + Should this be a timespec helper instead? It seems like a straightforward helper. [Ryan Long] Do you mean just change the name of the function to "timespec_helper_tv_sec_valid" or what? > +/** > + * @brief Checks the tv_nsec member of a timespec struct > + * > + * Ensures that the value in the tv_nsec member is equal to either > + * UTIME_NOW, UTIME_OMIT, or a value greater-than or equal to zero > + * and less than a billion. > + * > + * @param[in] time The timespec struct to be validated > + * > + * @retval Returns true if tv_nsec member is a valid value, otherwise false. > + */ > +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); > + > +/** > + * @brief Determines if the process has write permissions to a file > + * > + * Checks that the process has the same userID as the file and > +whether the > + * file has write permissions. > + * > + * @param[in] currentloc The current location to a file > + * @param[in] fstat_h The file handler of @currentloc > + * > + * @retval Returns 0 if the process has write permissions, otherwise -1. > + */ > +int rtems_filesystem_utime_check_permissions( > + const rtems_filesystem_location_info_t *currentloc, > + const struct timespec times[2] > +); > + The function name is overly broad. it seems like there should be a filesystem helper that checks for write permission (or ownership). I don't know why times[] is passed? What is @param[in] fstat_h? Passing an array is a bit unusual. [Ryan Long] Forgot to update the Doxygen for that, but I got rid of the ftat_h argument because I can just use currentloc to get what was being passed in. The array of timespec structures is passed in to check for the conditions for the EACCES and EPERM errors. > +/** > + * @brief Checks @times and updates @new
[PATCH v3 2/5] libcsupport: Implement utime() in terms of utimensat()
utime() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4397 --- cpukit/libcsupport/src/utime.c | 77 +++--- 1 file changed, 43 insertions(+), 34 deletions(-) diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index e2d8883..884d227 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c @@ -1,58 +1,67 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Set File Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in seconds. */ /* - * 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 #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( , path, eval_flags ); - struct utimbuf now_times; - - if ( times == NULL ) { -time_t now = time( NULL ); - -now_times.actime = now; -now_times.modtime = now; - -times = _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( ); + 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
[PATCH v3 5/5] Change filesystem utime_h handler to utimens_h
Also updated licenses. Closes #4400 --- bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 4 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 7 ++-- cpukit/include/rtems/libio.h| 21 +-- cpukit/libcsupport/src/__usrenv.c | 9 ++--- cpukit/libfs/src/defaults/default_ops.c | 2 +- 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 | 2 +- cpukit/libfs/src/ftpfs/tftpDriver.c | 2 +- cpukit/libfs/src/imfs/imfs_init.c | 4 +- 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 spec/build/cpukit/librtemscpu.yml | 4 +- 18 files changed, 152 insertions(+), 127 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 diff --git a/bsps/arm/csb337/umon/tfsDriver.c b/bsps/arm/csb337/umon/tfsDriver.c index 0195346..caf3a4b 100644 --- a/bsps/arm/csb337/umon/tfsDriver.c +++ b/bsps/arm/csb337/umon/tfsDriver.c @@ -657,7 +657,7 @@ static const rtems_filesystem_operations_table rtems_tfs_ops = { .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/Makefile.am b/cpukit/Makefile.am index 29b4207..c144773 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -377,7 +377,7 @@ librtemscpu_a_SOURCES += libfs/src/defaults/default_rmnod.c librtemscpu_a_SOURCES += libfs/src/defaults/default_statvfs.c librtemscpu_a_SOURCES += libfs/src/defaults/default_symlink.c librtemscpu_a_SOURCES += libfs/src/defaults/default_unmount.c -librtemscpu_a_SOURCES += libfs/src/defaults/default_utime.c +librtemscpu_a_SOURCES += libfs/src/defaults/default_utimens.c librtemscpu_a_SOURCES += libfs/src/defaults/default_write.c librtemscpu_a_SOURCES += libfs/src/defaults/default_writev.c librtemscpu_a_SOURCES += libfs/src/dosfs/fat.c @@ -434,7 +434,7 @@ librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat_file.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_symlink.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_unmount.c -librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utime.c +librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utimens.c librtemscpu_a_SOURCES += libfs/src/imfs/ioman.c librtemscpu_a_SOURCES += libfs/src/pipe/fifo.c librtemscpu_a_SOURCES += libfs/src/pipe/pipe.c diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h index 16a4fb69..1b84f8c 100644 --- a/cpukit/include/rtems/confdefs/libio.h +++ b/cpukit/include/rtems/confdefs/libio.h @@ -231,9 +231,9 @@ static const rtems_filesystem_operations_table IMFS_root_ops = { #endif rtems_filesystem_default_fsunmount, #ifdef CONFIGURE_IMFS_DISABLE_UTIME -rtems_filesystem_default_utime, +rtems_filesystem_default_utimens, #else -IMFS_utime, +IMFS_utimens, #endif #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK rtems_filesystem_default_symlink, diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index b2a9868..6e0d5d5 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -5,7 +5,7 @@ */ /* - * COPYRIGHT (c) 1989-2011. + * COPYRIGHT (c) 1989-2011, 2021. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -954,10 +954,9 @@ extern int device_ftruncate( * This routine is the implementation of the utime() system * call for the IMFS. */ -extern int IMFS_utime( +extern int IMFS_utimens( const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime + struct timespec times[2] ); /** diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h index 519e797..99543ba 100644 --- a/cpukit/include/rtems/libio.h +++ b/cpukit/include/rtems/libio.h @@ -11,7 +11,7 @@ */ /* - * COPYRIGHT (c) 1989-2008. + * COPYRIGHT (c) 1989-2008, 2021. * On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are @@ -375,18 +375,16 @@ typedef int
[PATCH v3 3/5] libcsupport: Implement utimes() in terms of utimensat()
utimes() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4398 --- cpukit/libcsupport/src/utimes.c | 53 +++-- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/cpukit/libcsupport/src/utimes.c b/cpukit/libcsupport/src/utimes.c index 3dc47c0..f16e6cf 100644 --- a/cpukit/libcsupport/src/utimes.c +++ b/cpukit/libcsupport/src/utimes.c @@ -1,38 +1,65 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Change File Last Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in milliseconds. */ /* - * Written by: Vinu Rajashekhar + * 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. + * + * 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 #include +#include + +/** + * https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/futimens.html + * + * Set file access and modification times + */ int utimes( const char *path, const struct timeval times[2] -) +) { - struct utimbuf timeinsecs; + struct timespec timeinsecs[2]; if ( times == NULL ) -return utime( path, NULL ); +return utimensat( AT_FDCWD, path, NULL , 0 ); - timeinsecs.actime = times[0].tv_sec; - timeinsecs.modtime = times[1].tv_sec; + timeinsecs[0].tv_sec = times[0].tv_sec; + timeinsecs[0].tv_nsec = times[0].tv_usec * 1000; + timeinsecs[1].tv_sec = times[1].tv_sec; + timeinsecs[1].tv_nsec = times[1].tv_usec * 1000; - return utime( path, ); + return utimensat( AT_FDCWD, path, timeinsecs, 0 ); } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v3 0/5] Add nanosecond support patch
Hi, The notable changes in this iteration are: - got rid of rtems_filesystem_utime_tv_sec_valid() created _Timespec_Is_non_negative() in rtems/score/timespec.h to take its place. - Fixed some license issues Thanks, Ryan Ryan Long (5): libcsupport: Added futimens() and utimensat() libcsupport: Implement utime() in terms of utimensat() libcsupport: Implement utimes() in terms of utimensat() psx13: Added tests for utimensat() and futimens() Change filesystem utime_h handler to utimens_h bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 6 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 7 +- cpukit/include/rtems/libio.h| 21 +- cpukit/include/rtems/libio_.h | 64 +++- cpukit/include/rtems/score/timespec.h | 16 +- cpukit/libcsupport/src/__usrenv.c | 9 +- cpukit/libcsupport/src/futimens.c | 87 + cpukit/libcsupport/src/utime.c | 77 +++-- cpukit/libcsupport/src/utimensat.c | 224 cpukit/libcsupport/src/utimes.c | 53 ++- cpukit/libfs/src/defaults/default_ops.c | 2 +- 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 | 2 +- cpukit/libfs/src/ftpfs/tftpDriver.c | 2 +- cpukit/libfs/src/imfs/imfs_init.c | 4 +- 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 +- cpukit/score/src/timespecisnonnegative.c| 35 ++ spec/build/cpukit/librtemscpu.yml | 7 +- testsuites/psxtests/psx13/main.c| 5 +- testsuites/psxtests/psx13/test.c| 517 ++-- 27 files changed, 1159 insertions(+), 203 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c 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 create mode 100644 cpukit/score/src/timespecisnonnegative.c -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v3 1/5] libcsupport: Added futimens() and utimensat()
Created futimens.c and utimensat.c to add support for the POSIX methods futimens() and utimensat(). utime() and utimes() are considered obsolote by POSIX, but RTEMS will continue to support them. Closes #4396 --- cpukit/Makefile.am | 2 + cpukit/include/rtems/libio_.h| 64 - cpukit/include/rtems/score/timespec.h| 16 ++- cpukit/libcsupport/src/futimens.c| 87 cpukit/libcsupport/src/utimensat.c | 224 +++ cpukit/score/src/timespecisnonnegative.c | 35 + spec/build/cpukit/librtemscpu.yml| 3 + 7 files changed, 426 insertions(+), 5 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c create mode 100644 cpukit/score/src/timespecisnonnegative.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index b0df610..29b4207 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c librtemscpu_a_SOURCES += libcsupport/src/utime.c librtemscpu_a_SOURCES += libcsupport/src/utimes.c +librtemscpu_a_SOURCES += libcsupport/src/futimens.c +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c librtemscpu_a_SOURCES += libcsupport/src/utsname.c librtemscpu_a_SOURCES += libcsupport/src/vprintk.c librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index e9eb462..b7455ef 100644 --- a/cpukit/include/rtems/libio_.h +++ b/cpukit/include/rtems/libio_.h @@ -2,13 +2,12 @@ * @file * * @brief LibIO Internal Interface - * + * * This file is the libio internal interface. */ /* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are * Copyright (c) 2012 embedded brains GmbH. @@ -30,6 +29,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -357,6 +357,64 @@ static inline void rtems_filesystem_instance_unlock( (*mt_entry->ops->unlock_h)( mt_entry ); } +/** + * @brief Checks the tv_nsec member of a timespec struct + * + * This function is used with utimensat() and futimens() only. This ensures + * that the value in the tv_nsec member is equal to either UTIME_NOW, + * UTIME_OMIT, or a value greater-than or equal to zero and less than a + * billion. + * + * @param[in] time The timespec struct to be validated + * + * @retval Returns true if tv_nsec member is a valid value, otherwise false. + */ +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); + +/** + * @brief Determines if the process has write permissions to a file + * + * The timespec at index 0 is the access time, the timespec at index 1 is the + * modification time. + * + * This function is only used with utimensat() and futimens(). This checks + * whether the process has write access to a file, and checks for EACCES + * and EPERM errors depending on what values are in @times and if the process + * has write permissions to the file. + * + * @param[in] currentloc The current location to a file + * @param[in] times The timespec instance that will update the timestamps + * + * @retval Returns 0 if the process has write permissions, otherwise -1. + */ +int rtems_filesystem_utime_check_permissions( + const rtems_filesystem_location_info_t *currentloc, + const struct timespec times[2] +); + +/** + * @brief Checks @times and fills @new_times with the time to be written + * + * For each of the arguments, the timespec at index 0 is the access time, and + * the timespec at index 1 is the modification time. + * + * This function is only used with utimensat() and futimens(). @times contains + * the constant values passed into utimensat/futimens. @new_times contains the + * values that will be written to the file. These values depend on @times. If + * @times is NULL, or either of its elements' tv_nsec members are UTIME_NOW, + * the current elapsed time in nanoseconds will be saved in the corresponding + * location in @new_times. + * + * @param[in] times The timespecs to be checked + * @param[in,out] new_times The timespecs containing the time to be written + * + * @retval Returns 0 if @times is valid, otherwise -1. + */ +int rtems_filesystem_utime_check_times( + const struct timespec times[2], + struct timespec new_times[2] +); + /* * File Descriptor Routine Prototypes */ diff --git a/cpukit/include/rtems/score/timespec.h b/cpukit/include/rtems/score/timespec.h index 314d804..3671067 100644 --- a/cpukit/include/rtems/score/timespec.h +++ b/cpukit/include/rtems/score/timespec.h @@ -8,8 +8,7 @@ */ /* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research
[PATCH v3 4/5] psx13: Added tests for utimensat() and futimens()
Improved tests for utime() and utimes() and update license. Close #4399 --- testsuites/psxtests/psx13/main.c | 5 +- testsuites/psxtests/psx13/test.c | 517 +-- 2 files changed, 498 insertions(+), 24 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index f9e7907..7a560f9 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * @@ -8,8 +6,7 @@ */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index e98b03a..cc929ef 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * @@ -17,12 +15,13 @@ * - umask() * - utime() * - utimes() + * - utimensat() + * - futimens() * - sync() */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 @@ -210,8 +209,7 @@ static void Dup2Test( void ) } /** - * @brief Exercises fdatasync(). Does NOT test the functionality of the - *underlying fdatasync entry in the IMFS op table. + * @brief Exercises fdatasync(). */ static void FDataSyncTest( void ) { @@ -259,60 +257,537 @@ static void UMaskTest( void ) } /** - * @brief Exercises utime(). Does not test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utime(). */ static void UTimeTest( void ) { int rv; struct utimbuf time; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: Pass an invalid filename. */ rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Case: Change user ID to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv == 0 ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = seteuid( 0 ); + rtems_test_assert( rv == 0 ); + + /* EINVAL test cases */ + + /* Case: Invalid access time */ + time.actime = -1; + time.modtime = 54321; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Case: Invalid modified time */ + time.actime = 12345; + time.modtime = -1; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Successful test cases */ + + /* Case: Test without times argument */ + clock_gettime( CLOCK_REALTIME, _time ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == 0 ); + + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); + + /* Case: time is filled with valid values */ time.actime = 12345; time.modtime = 54321; rv = utime( "testfile1.tst", ); rtems_test_assert( rv == 0 ); - /* But, did it set the time? */ + /* Check that it actually changed the time */ rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 ); rtems_test_assert( fstat.st_atime == 12345 ); rtems_test_assert( fstat.st_mtime == 54321 ); - - rv = utime( "testfile1.tst", NULL ); - rtems_test_assert( rv == 0 ); } /** - * @brief Exercises utimes(). Does NOT test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utimes(). */ static void UTimesTest( void ) { int rv; struct timeval time[2]; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: First, an invalid filename. */ rv = utimes( "!This is an =invalid p@thname!!! : )", NULL); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Change the user ID of the process to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv == 0 ); + + rv = utimes( "testfile1.tst", NULL ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv =
[PATCH v6 5/5] Change filesystem utime_h handler to utimens_h
Also updated licenses. Closes #4400 Updates #3899 --- bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 4 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 35 - cpukit/include/rtems/libio.h| 55 +-- cpukit/libcsupport/src/__usrenv.c | 39 +-- cpukit/libcsupport/src/futimens.c | 2 +- cpukit/libcsupport/src/utimensat.c | 2 +- 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 spec/build/cpukit/librtemscpu.yml | 4 +- 20 files changed, 295 insertions(+), 180 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 diff --git a/bsps/arm/csb337/umon/tfsDriver.c b/bsps/arm/csb337/umon/tfsDriver.c index 0195346..caf3a4b 100644 --- a/bsps/arm/csb337/umon/tfsDriver.c +++ b/bsps/arm/csb337/umon/tfsDriver.c @@ -657,7 +657,7 @@ static const rtems_filesystem_operations_table rtems_tfs_ops = { .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/Makefile.am b/cpukit/Makefile.am index 29b4207..c144773 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -377,7 +377,7 @@ librtemscpu_a_SOURCES += libfs/src/defaults/default_rmnod.c librtemscpu_a_SOURCES += libfs/src/defaults/default_statvfs.c librtemscpu_a_SOURCES += libfs/src/defaults/default_symlink.c librtemscpu_a_SOURCES += libfs/src/defaults/default_unmount.c -librtemscpu_a_SOURCES += libfs/src/defaults/default_utime.c +librtemscpu_a_SOURCES += libfs/src/defaults/default_utimens.c librtemscpu_a_SOURCES += libfs/src/defaults/default_write.c librtemscpu_a_SOURCES += libfs/src/defaults/default_writev.c librtemscpu_a_SOURCES += libfs/src/dosfs/fat.c @@ -434,7 +434,7 @@ librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat_file.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_symlink.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_unmount.c -librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utime.c +librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utimens.c librtemscpu_a_SOURCES += libfs/src/imfs/ioman.c librtemscpu_a_SOURCES += libfs/src/pipe/fifo.c librtemscpu_a_SOURCES += libfs/src/pipe/pipe.c diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h index 16a4fb69..1b84f8c 100644 --- a/cpukit/include/rtems/confdefs/libio.h +++ b/cpukit/include/rtems/confdefs/libio.h @@ -231,9 +231,9 @@ static const rtems_filesystem_operations_table IMFS_root_ops = { #endif rtems_filesystem_default_fsunmount, #ifdef CONFIGURE_IMFS_DISABLE_UTIME -rtems_filesystem_default_utime, +rtems_filesystem_default_utimens, #else -IMFS_utime, +IMFS_utimens, #endif #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK rtems_filesystem_default_symlink, diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index b2a9868..57c498c 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -5,12 +7,28 @@ */ /* - * COPYRIGHT (c) 1989-2011. - * 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. + * 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.
[PATCH v6 4/5] psx13: Added tests for utimensat() and futimens()
Improved tests for utime() and utimes() and update license. Close #4399 --- testsuites/psxtests/psx13/main.c | 5 +- testsuites/psxtests/psx13/test.c | 499 +-- 2 files changed, 481 insertions(+), 23 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index f9e7907..7a560f9 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * @@ -8,8 +6,7 @@ */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index e98b03a..0754dbc 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ +/* SPDX-License-Identifier: BSD-2-Clause */ /** * @file @@ -17,12 +17,13 @@ * - umask() * - utime() * - utimes() + * - utimensat() + * - futimens() * - sync() */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 @@ -52,6 +53,8 @@ #include #include +#include +#include #include #include #include @@ -210,8 +213,7 @@ static void Dup2Test( void ) } /** - * @brief Exercises fdatasync(). Does NOT test the functionality of the - *underlying fdatasync entry in the IMFS op table. + * @brief Exercises fdatasync(). */ static void FDataSyncTest( void ) { @@ -259,60 +261,517 @@ static void UMaskTest( void ) } /** - * @brief Exercises utime(). Does not test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utime(). */ static void UTimeTest( void ) { int rv; struct utimbuf time; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: Pass an invalid filename. */ rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Case: Change user ID to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv == 0 ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = seteuid( 0 ); + rtems_test_assert( rv == 0 ); + + /* EINVAL test cases */ + + /* Case: Invalid access time */ + time.actime = -1; + time.modtime = 54321; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Case: Invalid modified time */ + time.actime = 12345; + time.modtime = -1; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Successful test cases */ + + /* Case: Test without times argument */ + clock_gettime( CLOCK_REALTIME, _time ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == 0 ); + + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); + + /* Case: time is filled with valid values */ time.actime = 12345; time.modtime = 54321; rv = utime( "testfile1.tst", ); rtems_test_assert( rv == 0 ); - /* But, did it set the time? */ + /* Check that it actually changed the time */ rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 ); rtems_test_assert( fstat.st_atime == 12345 ); rtems_test_assert( fstat.st_mtime == 54321 ); - - rv = utime( "testfile1.tst", NULL ); - rtems_test_assert( rv == 0 ); } /** - * @brief Exercises utimes(). Does NOT test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utimes(). */ static void UTimesTest( void ) { int rv; struct timeval time[2]; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: First, an invalid filename. */ rv = utimes( "!This is an =invalid p@thname!!! : )", NULL); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Change the user ID of the process to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv ==
[PATCH v6 2/5] libcsupport: Implement utime() in terms of utimensat()
utime() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4397 --- cpukit/libcsupport/src/utime.c | 72 +++--- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index e2d8883..5d80ca3 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c @@ -1,58 +1,66 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Set File Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in seconds. */ /* - * 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 #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( , path, eval_flags ); - struct utimbuf now_times; + struct timespec new_times[2]; if ( times == NULL ) { -time_t now = time( NULL ); - -now_times.actime = now; -now_times.modtime = now; - -times = _times; +return utimensat(AT_FDCWD, path, NULL, 0); } - rv = (*currentloc->mt_entry->ops->utime_h)( -currentloc, -times->actime, -times->modtime - ); - - rtems_filesystem_eval_path_cleanup( ); + _Timespec_Set(_times[0], times->actime, 0); + _Timespec_Set(_times[1], times->modtime, 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
[PATCH v6 0/5] Add nanosecond support patch
Hi, For this series of patches, I - Removed extra whitespace - Removed some changes made to licenses Thanks, Ryan Ryan Long (5): libcsupport: Added futimens() and utimensat() libcsupport: Implement utime() in terms of utimensat() libcsupport: Implement utimes() in terms of utimensat() psx13: Added tests for utimensat() and futimens() Change filesystem utime_h handler to utimens_h bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 6 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 35 +- cpukit/include/rtems/libio.h| 55 +-- cpukit/include/rtems/libio_.h | 94 +- cpukit/include/rtems/score/timespec.h | 44 ++- cpukit/libcsupport/src/__usrenv.c | 39 ++- cpukit/libcsupport/src/futimens.c | 87 + cpukit/libcsupport/src/utime.c | 72 ++-- cpukit/libcsupport/src/utimensat.c | 225 + cpukit/libcsupport/src/utimes.c | 63 +++- 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 +- cpukit/score/src/timespecisnonnegative.c| 54 +++ spec/build/cpukit/librtemscpu.yml | 7 +- testsuites/psxtests/psx13/main.c| 5 +- testsuites/psxtests/psx13/test.c| 499 ++-- 27 files changed, 1357 insertions(+), 262 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c 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 create mode 100644 cpukit/score/src/timespecisnonnegative.c -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v6 1/5] libcsupport: Added futimens() and utimensat()
Created futimens.c and utimensat.c to add support for the POSIX methods futimens() and utimensat(). utime() and utimes() are considered obsolote by POSIX, but RTEMS will continue to support them. Closes #4396 --- cpukit/Makefile.am | 2 + cpukit/include/rtems/libio_.h| 94 +++-- cpukit/include/rtems/score/timespec.h| 44 +- cpukit/libcsupport/src/futimens.c| 87 cpukit/libcsupport/src/utimensat.c | 225 +++ cpukit/score/src/timespecisnonnegative.c | 54 spec/build/cpukit/librtemscpu.yml| 3 + 7 files changed, 494 insertions(+), 15 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c create mode 100644 cpukit/score/src/timespecisnonnegative.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index b0df610..29b4207 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c librtemscpu_a_SOURCES += libcsupport/src/utime.c librtemscpu_a_SOURCES += libcsupport/src/utimes.c +librtemscpu_a_SOURCES += libcsupport/src/futimens.c +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c librtemscpu_a_SOURCES += libcsupport/src/utsname.c librtemscpu_a_SOURCES += libcsupport/src/vprintk.c librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index e9eb462..8d4a2dc 100644 --- a/cpukit/include/rtems/libio_.h +++ b/cpukit/include/rtems/libio_.h @@ -1,21 +1,39 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * * @brief LibIO Internal Interface - * + * * This file is the libio internal interface. */ /* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). + * + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. * - * Modifications to support reference counting in the file system are - * Copyright (c) 2012 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. */ #ifndef _RTEMS_RTEMS_LIBIO__H @@ -30,6 +48,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -357,6 +376,65 @@ static inline void rtems_filesystem_instance_unlock( (*mt_entry->ops->unlock_h)( mt_entry ); } +/** + * @brief Checks the tv_nsec member of a timespec struct + * + * This function is used with utimensat() and futimens() only. This ensures + * that the value in the tv_nsec member is equal to either UTIME_NOW, + * UTIME_OMIT, or a value greater-than or equal to zero and less than a + * billion. + * + * @param[in] time The timespec struct to be validated + * + * @retval true The tv_nsec member is a valid value. + * @retval false The tv_nsec member is not a valid value. + */ +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); + +/** + * @brief Checks for errors and if the process has write permissions to the file. + * + * This function is only used with utimensat() and futimens().It checks for + * EACCES and EPERM errors depending on what values are in @a times and if the + * process has write permissions to the file. + * + * @param[in] currentloc The current location to a file + * @param[in] times The timespecs used to check for errors. The timespec at + * index
[PATCH v6 3/5] libcsupport: Implement utimes() in terms of utimensat()
utimes() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4398 --- cpukit/libcsupport/src/utimes.c | 63 - 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/cpukit/libcsupport/src/utimes.c b/cpukit/libcsupport/src/utimes.c index 3dc47c0..9748abb 100644 --- a/cpukit/libcsupport/src/utimes.c +++ b/cpukit/libcsupport/src/utimes.c @@ -1,38 +1,73 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Change File Last Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in milliseconds. */ /* - * Written by: Vinu Rajashekhar + * 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. + * + * 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 #include +#include + +#include +/** + * https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/futimens.html + * + * Set file access and modification times + */ int utimes( const char *path, const struct timeval times[2] -) +) { - struct utimbuf timeinsecs; + struct timespec new_times[2]; - if ( times == NULL ) -return utime( path, NULL ); + if ( times == NULL ) { +return utimensat( AT_FDCWD, path, NULL , 0 ); + } - timeinsecs.actime = times[0].tv_sec; - timeinsecs.modtime = times[1].tv_sec; + _Timespec_Set( +_times[0], +times[0].tv_sec, +times[0].tv_usec * TOD_NANOSECONDS_PER_MICROSECOND + ); + _Timespec_Set( +_times[1], +times[1].tv_sec, +times[1].tv_usec * TOD_NANOSECONDS_PER_MICROSECOND + ); - return utime( path, ); + 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 v6 4/5] psx13: Added tests for utimensat() and futimens()
-Original Message- From: Gedare Bloom Sent: Tuesday, May 18, 2021 3:15 PM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH v6 4/5] psx13: Added tests for utimensat() and futimens() On Tue, May 18, 2021 at 2:03 PM Ryan Long wrote: > > Improved tests for utime() and utimes() and update license. > > Close #4399 > --- > testsuites/psxtests/psx13/main.c | 5 +- > testsuites/psxtests/psx13/test.c | 499 > +-- > 2 files changed, 481 insertions(+), 23 deletions(-) > > diff --git a/testsuites/psxtests/psx13/main.c > b/testsuites/psxtests/psx13/main.c > index f9e7907..7a560f9 100644 > --- a/testsuites/psxtests/psx13/main.c > +++ b/testsuites/psxtests/psx13/main.c > @@ -1,5 +1,3 @@ > -/* SPDX-License-Identifier: BSD-2-Clause */ > - why this is being removed? [Ryan Long] I don't remember doing this, but I'll make sure it's put back in. > /** > * @file > * > @@ -8,8 +6,7 @@ > */ > > /* > - * COPYRIGHT (c) 1989-2009, 2021. > - * 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 > diff --git a/testsuites/psxtests/psx13/test.c > b/testsuites/psxtests/psx13/test.c > index e98b03a..0754dbc 100644 > --- a/testsuites/psxtests/psx13/test.c > +++ b/testsuites/psxtests/psx13/test.c > @@ -1,4 +1,4 @@ > -/* SPDX-License-Identifier: BSD-2-Clause */ > +/* SPDX-License-Identifier: BSD-2-Clause */ > > /** > * @file > @@ -17,12 +17,13 @@ > * - umask() > * - utime() > * - utimes() > + * - utimensat() > + * - futimens() > * - sync() > */ > > /* > - * COPYRIGHT (c) 1989-2009, 2021. > - * 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 > @@ -52,6 +53,8 @@ > > #include > #include > +#include > +#include > #include > #include > #include > @@ -210,8 +213,7 @@ static void Dup2Test( void ) } > > /** > - * @brief Exercises fdatasync(). Does NOT test the functionality of the > - *underlying fdatasync entry in the IMFS op table. > + * @brief Exercises fdatasync(). > */ > static void FDataSyncTest( void ) > { > @@ -259,60 +261,517 @@ static void UMaskTest( void ) } > > /** > - * @brief Exercises utime(). Does not test the functionality of the > - *underlying utime entry in the IMFS op table. > + * @brief Exercises utime(). > */ > static void UTimeTest( void ) > { >int rv; >struct utimbuf time; > + struct timespec current_time; >struct stat fstat; > > - /* First, an invalid filename. */ > + /* ENOENT test case */ > + > + /* Case: Pass an invalid filename. */ >rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); >rtems_test_assert( rv == -1 ); >rtems_test_assert( errno == ENOENT ); > > - /* Now, the success test. */ > + /* EACCES test case */ > + > + /* Case: Change user ID to someone besides root */ rv = seteuid( 1 > + ); rtems_test_assert( rv == 0 ); > + > + rv = utime( "testfile1.tst", NULL ); rtems_test_assert( rv == -1 > + ); rtems_test_assert( errno == EACCES ); > + > + rv = seteuid( 0 ); > + rtems_test_assert( rv == 0 ); > + > + /* EINVAL test cases */ > + > + /* Case: Invalid access time */ > + time.actime = -1; > + time.modtime = 54321; > + > + rv = utime( "testfile1.tst", ); rtems_test_assert( rv == -1 > + ); rtems_test_assert( errno == EINVAL ); > + > + /* Case: Invalid modified time */ > + time.actime = 12345; > + time.modtime = -1; > + > + rv = utime( "testfile1.tst", ); rtems_test_assert( rv == -1 > + ); rtems_test_assert( errno == EINVAL ); > + > + /* Successful test cases */ > + > + /* Case: Test without times argument */ clock_gettime( > + CLOCK_REALTIME, _time ); > + > + rv = utime( "testfile1.tst", NULL ); rtems_test_assert( rv == 0 ); > + > + rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 > + ); rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec > + ); rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec > + ); > + > + /* Case: time is filled with valid values */ >time.actime = 12345; >time.modtime = 54321; > >
[PATCH v7 0/5] Add nanosecond support patch
Hi, For this series of patches, I - Added the SPDX clause that had been accidentally removed in main.c - Removed the extra space in the clause Thanks, Ryan Ryan Long (5): libcsupport: Added futimens() and utimensat() libcsupport: Implement utime() in terms of utimensat() libcsupport: Implement utimes() in terms of utimensat() psx13: Added tests for utimensat() and futimens() Change filesystem utime_h handler to utimens_h bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 6 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 35 +- cpukit/include/rtems/libio.h| 55 +-- cpukit/include/rtems/libio_.h | 94 +- cpukit/include/rtems/score/timespec.h | 44 ++- cpukit/libcsupport/src/__usrenv.c | 39 ++- cpukit/libcsupport/src/futimens.c | 87 + cpukit/libcsupport/src/utime.c | 72 ++-- cpukit/libcsupport/src/utimensat.c | 225 + cpukit/libcsupport/src/utimes.c | 63 +++- 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 +- cpukit/score/src/timespecisnonnegative.c| 54 +++ spec/build/cpukit/librtemscpu.yml | 7 +- testsuites/psxtests/psx13/main.c| 5 +- testsuites/psxtests/psx13/test.c| 499 ++-- 27 files changed, 1358 insertions(+), 261 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c 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 create mode 100644 cpukit/score/src/timespecisnonnegative.c -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v7 1/5] libcsupport: Added futimens() and utimensat()
Created futimens.c and utimensat.c to add support for the POSIX methods futimens() and utimensat(). utime() and utimes() are considered obsolote by POSIX, but RTEMS will continue to support them. Closes #4396 --- cpukit/Makefile.am | 2 + cpukit/include/rtems/libio_.h| 94 +++-- cpukit/include/rtems/score/timespec.h| 44 +- cpukit/libcsupport/src/futimens.c| 87 cpukit/libcsupport/src/utimensat.c | 225 +++ cpukit/score/src/timespecisnonnegative.c | 54 spec/build/cpukit/librtemscpu.yml| 3 + 7 files changed, 494 insertions(+), 15 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c create mode 100644 cpukit/score/src/timespecisnonnegative.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index b0df610..29b4207 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c librtemscpu_a_SOURCES += libcsupport/src/utime.c librtemscpu_a_SOURCES += libcsupport/src/utimes.c +librtemscpu_a_SOURCES += libcsupport/src/futimens.c +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c librtemscpu_a_SOURCES += libcsupport/src/utsname.c librtemscpu_a_SOURCES += libcsupport/src/vprintk.c librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index e9eb462..8d4a2dc 100644 --- a/cpukit/include/rtems/libio_.h +++ b/cpukit/include/rtems/libio_.h @@ -1,21 +1,39 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * * @brief LibIO Internal Interface - * + * * This file is the libio internal interface. */ /* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). + * + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. * - * Modifications to support reference counting in the file system are - * Copyright (c) 2012 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. */ #ifndef _RTEMS_RTEMS_LIBIO__H @@ -30,6 +48,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -357,6 +376,65 @@ static inline void rtems_filesystem_instance_unlock( (*mt_entry->ops->unlock_h)( mt_entry ); } +/** + * @brief Checks the tv_nsec member of a timespec struct + * + * This function is used with utimensat() and futimens() only. This ensures + * that the value in the tv_nsec member is equal to either UTIME_NOW, + * UTIME_OMIT, or a value greater-than or equal to zero and less than a + * billion. + * + * @param[in] time The timespec struct to be validated + * + * @retval true The tv_nsec member is a valid value. + * @retval false The tv_nsec member is not a valid value. + */ +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); + +/** + * @brief Checks for errors and if the process has write permissions to the file. + * + * This function is only used with utimensat() and futimens().It checks for + * EACCES and EPERM errors depending on what values are in @a times and if the + * process has write permissions to the file. + * + * @param[in] currentloc The current location to a file + * @param[in] times The timespecs used to check for errors. The timespec at + * index
[PATCH v7 2/5] libcsupport: Implement utime() in terms of utimensat()
utime() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4397 --- cpukit/libcsupport/src/utime.c | 72 +++--- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index e2d8883..5d80ca3 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c @@ -1,58 +1,66 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Set File Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in seconds. */ /* - * 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 #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( , path, eval_flags ); - struct utimbuf now_times; + struct timespec new_times[2]; if ( times == NULL ) { -time_t now = time( NULL ); - -now_times.actime = now; -now_times.modtime = now; - -times = _times; +return utimensat(AT_FDCWD, path, NULL, 0); } - rv = (*currentloc->mt_entry->ops->utime_h)( -currentloc, -times->actime, -times->modtime - ); - - rtems_filesystem_eval_path_cleanup( ); + _Timespec_Set(_times[0], times->actime, 0); + _Timespec_Set(_times[1], times->modtime, 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
[PATCH v7 5/5] Change filesystem utime_h handler to utimens_h
Also updated licenses. Closes #4400 Updates #3899 --- bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 4 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 35 - cpukit/include/rtems/libio.h| 55 +-- cpukit/libcsupport/src/__usrenv.c | 39 +-- cpukit/libcsupport/src/futimens.c | 2 +- cpukit/libcsupport/src/utimensat.c | 2 +- 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 spec/build/cpukit/librtemscpu.yml | 4 +- 20 files changed, 295 insertions(+), 180 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 diff --git a/bsps/arm/csb337/umon/tfsDriver.c b/bsps/arm/csb337/umon/tfsDriver.c index 0195346..caf3a4b 100644 --- a/bsps/arm/csb337/umon/tfsDriver.c +++ b/bsps/arm/csb337/umon/tfsDriver.c @@ -657,7 +657,7 @@ static const rtems_filesystem_operations_table rtems_tfs_ops = { .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/Makefile.am b/cpukit/Makefile.am index 29b4207..c144773 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -377,7 +377,7 @@ librtemscpu_a_SOURCES += libfs/src/defaults/default_rmnod.c librtemscpu_a_SOURCES += libfs/src/defaults/default_statvfs.c librtemscpu_a_SOURCES += libfs/src/defaults/default_symlink.c librtemscpu_a_SOURCES += libfs/src/defaults/default_unmount.c -librtemscpu_a_SOURCES += libfs/src/defaults/default_utime.c +librtemscpu_a_SOURCES += libfs/src/defaults/default_utimens.c librtemscpu_a_SOURCES += libfs/src/defaults/default_write.c librtemscpu_a_SOURCES += libfs/src/defaults/default_writev.c librtemscpu_a_SOURCES += libfs/src/dosfs/fat.c @@ -434,7 +434,7 @@ librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat_file.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_symlink.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_unmount.c -librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utime.c +librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utimens.c librtemscpu_a_SOURCES += libfs/src/imfs/ioman.c librtemscpu_a_SOURCES += libfs/src/pipe/fifo.c librtemscpu_a_SOURCES += libfs/src/pipe/pipe.c diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h index 16a4fb69..1b84f8c 100644 --- a/cpukit/include/rtems/confdefs/libio.h +++ b/cpukit/include/rtems/confdefs/libio.h @@ -231,9 +231,9 @@ static const rtems_filesystem_operations_table IMFS_root_ops = { #endif rtems_filesystem_default_fsunmount, #ifdef CONFIGURE_IMFS_DISABLE_UTIME -rtems_filesystem_default_utime, +rtems_filesystem_default_utimens, #else -IMFS_utime, +IMFS_utimens, #endif #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK rtems_filesystem_default_symlink, diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index b2a9868..57c498c 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -5,12 +7,28 @@ */ /* - * COPYRIGHT (c) 1989-2011. - * 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. + * 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.
[PATCH v7 3/5] libcsupport: Implement utimes() in terms of utimensat()
utimes() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4398 --- cpukit/libcsupport/src/utimes.c | 63 - 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/cpukit/libcsupport/src/utimes.c b/cpukit/libcsupport/src/utimes.c index 3dc47c0..9748abb 100644 --- a/cpukit/libcsupport/src/utimes.c +++ b/cpukit/libcsupport/src/utimes.c @@ -1,38 +1,73 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Change File Last Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in milliseconds. */ /* - * Written by: Vinu Rajashekhar + * 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. + * + * 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 #include +#include + +#include +/** + * https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/futimens.html + * + * Set file access and modification times + */ int utimes( const char *path, const struct timeval times[2] -) +) { - struct utimbuf timeinsecs; + struct timespec new_times[2]; - if ( times == NULL ) -return utime( path, NULL ); + if ( times == NULL ) { +return utimensat( AT_FDCWD, path, NULL , 0 ); + } - timeinsecs.actime = times[0].tv_sec; - timeinsecs.modtime = times[1].tv_sec; + _Timespec_Set( +_times[0], +times[0].tv_sec, +times[0].tv_usec * TOD_NANOSECONDS_PER_MICROSECOND + ); + _Timespec_Set( +_times[1], +times[1].tv_sec, +times[1].tv_usec * TOD_NANOSECONDS_PER_MICROSECOND + ); - return utime( path, ); + 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
[PATCH v7 4/5] psx13: Added tests for utimensat() and futimens()
Improved tests for utime() and utimes() and update license. Close #4399 --- testsuites/psxtests/psx13/main.c | 5 +- testsuites/psxtests/psx13/test.c | 499 +-- 2 files changed, 482 insertions(+), 22 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index f9e7907..29bacd4 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ +/* SPDX-License-Identifier: BSD-2-Clause */ /** * @file @@ -8,8 +8,7 @@ */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index e98b03a..0754dbc 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ +/* SPDX-License-Identifier: BSD-2-Clause */ /** * @file @@ -17,12 +17,13 @@ * - umask() * - utime() * - utimes() + * - utimensat() + * - futimens() * - sync() */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 @@ -52,6 +53,8 @@ #include #include +#include +#include #include #include #include @@ -210,8 +213,7 @@ static void Dup2Test( void ) } /** - * @brief Exercises fdatasync(). Does NOT test the functionality of the - *underlying fdatasync entry in the IMFS op table. + * @brief Exercises fdatasync(). */ static void FDataSyncTest( void ) { @@ -259,60 +261,517 @@ static void UMaskTest( void ) } /** - * @brief Exercises utime(). Does not test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utime(). */ static void UTimeTest( void ) { int rv; struct utimbuf time; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: Pass an invalid filename. */ rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Case: Change user ID to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv == 0 ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = seteuid( 0 ); + rtems_test_assert( rv == 0 ); + + /* EINVAL test cases */ + + /* Case: Invalid access time */ + time.actime = -1; + time.modtime = 54321; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Case: Invalid modified time */ + time.actime = 12345; + time.modtime = -1; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Successful test cases */ + + /* Case: Test without times argument */ + clock_gettime( CLOCK_REALTIME, _time ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == 0 ); + + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); + + /* Case: time is filled with valid values */ time.actime = 12345; time.modtime = 54321; rv = utime( "testfile1.tst", ); rtems_test_assert( rv == 0 ); - /* But, did it set the time? */ + /* Check that it actually changed the time */ rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 ); rtems_test_assert( fstat.st_atime == 12345 ); rtems_test_assert( fstat.st_mtime == 54321 ); - - rv = utime( "testfile1.tst", NULL ); - rtems_test_assert( rv == 0 ); } /** - * @brief Exercises utimes(). Does NOT test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utimes(). */ static void UTimesTest( void ) { int rv; struct timeval time[2]; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: First, an invalid filename. */ rv = utimes( "!This is an =invalid p@thname!!! : )", NULL); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Change the user ID of the process to someone besides root */ + rv =
[PATCH v2 4/5] psx13: Added tests for utimensat() and futimens()
Improved tests for utime() and utimes() and update license. Close #4399 --- testsuites/psxtests/psx13/main.c | 5 +- testsuites/psxtests/psx13/test.c | 517 +-- 2 files changed, 498 insertions(+), 24 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index f9e7907..7a560f9 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * @@ -8,8 +6,7 @@ */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index e98b03a..cc929ef 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * @@ -17,12 +15,13 @@ * - umask() * - utime() * - utimes() + * - utimensat() + * - futimens() * - sync() */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 @@ -210,8 +209,7 @@ static void Dup2Test( void ) } /** - * @brief Exercises fdatasync(). Does NOT test the functionality of the - *underlying fdatasync entry in the IMFS op table. + * @brief Exercises fdatasync(). */ static void FDataSyncTest( void ) { @@ -259,60 +257,537 @@ static void UMaskTest( void ) } /** - * @brief Exercises utime(). Does not test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utime(). */ static void UTimeTest( void ) { int rv; struct utimbuf time; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: Pass an invalid filename. */ rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Case: Change user ID to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv == 0 ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = seteuid( 0 ); + rtems_test_assert( rv == 0 ); + + /* EINVAL test cases */ + + /* Case: Invalid access time */ + time.actime = -1; + time.modtime = 54321; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Case: Invalid modified time */ + time.actime = 12345; + time.modtime = -1; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Successful test cases */ + + /* Case: Test without times argument */ + clock_gettime( CLOCK_REALTIME, _time ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == 0 ); + + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); + + /* Case: time is filled with valid values */ time.actime = 12345; time.modtime = 54321; rv = utime( "testfile1.tst", ); rtems_test_assert( rv == 0 ); - /* But, did it set the time? */ + /* Check that it actually changed the time */ rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 ); rtems_test_assert( fstat.st_atime == 12345 ); rtems_test_assert( fstat.st_mtime == 54321 ); - - rv = utime( "testfile1.tst", NULL ); - rtems_test_assert( rv == 0 ); } /** - * @brief Exercises utimes(). Does NOT test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utimes(). */ static void UTimesTest( void ) { int rv; struct timeval time[2]; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: First, an invalid filename. */ rv = utimes( "!This is an =invalid p@thname!!! : )", NULL); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Change the user ID of the process to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv == 0 ); + + rv = utimes( "testfile1.tst", NULL ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv =
[PATCH v2 5/5] Change filesystem utime_h handler to utimens_h
Also updated licenses. Closes #4400 --- bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 4 +-- cpukit/include/rtems/confdefs/libio.h | 4 +-- cpukit/include/rtems/imfs.h | 7 +++-- cpukit/include/rtems/libio.h| 21 +++ cpukit/libcsupport/src/__usrenv.c | 9 +++ cpukit/libfs/src/defaults/default_ops.c | 2 +- cpukit/libfs/src/defaults/default_utime.c | 32 -- cpukit/libfs/src/defaults/default_utimens.c | 33 +++ cpukit/libfs/src/dosfs/msdos_init.c | 11 cpukit/libfs/src/ftpfs/ftpfs.c | 2 +- cpukit/libfs/src/ftpfs/tftpDriver.c | 2 +- cpukit/libfs/src/imfs/imfs_init.c | 4 +-- cpukit/libfs/src/imfs/imfs_utime.c | 41 cpukit/libfs/src/imfs/imfs_utimens.c| 42 + cpukit/libfs/src/jffs2/src/fs-rtems.c | 11 cpukit/libfs/src/rfs/rtems-rfs-rtems.c | 16 +-- spec/build/cpukit/librtemscpu.yml | 4 +-- 18 files changed, 120 insertions(+), 127 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 diff --git a/bsps/arm/csb337/umon/tfsDriver.c b/bsps/arm/csb337/umon/tfsDriver.c index 0195346..caf3a4b 100644 --- a/bsps/arm/csb337/umon/tfsDriver.c +++ b/bsps/arm/csb337/umon/tfsDriver.c @@ -657,7 +657,7 @@ static const rtems_filesystem_operations_table rtems_tfs_ops = { .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/Makefile.am b/cpukit/Makefile.am index 29b4207..c144773 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -377,7 +377,7 @@ librtemscpu_a_SOURCES += libfs/src/defaults/default_rmnod.c librtemscpu_a_SOURCES += libfs/src/defaults/default_statvfs.c librtemscpu_a_SOURCES += libfs/src/defaults/default_symlink.c librtemscpu_a_SOURCES += libfs/src/defaults/default_unmount.c -librtemscpu_a_SOURCES += libfs/src/defaults/default_utime.c +librtemscpu_a_SOURCES += libfs/src/defaults/default_utimens.c librtemscpu_a_SOURCES += libfs/src/defaults/default_write.c librtemscpu_a_SOURCES += libfs/src/defaults/default_writev.c librtemscpu_a_SOURCES += libfs/src/dosfs/fat.c @@ -434,7 +434,7 @@ librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat_file.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_symlink.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_unmount.c -librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utime.c +librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utimens.c librtemscpu_a_SOURCES += libfs/src/imfs/ioman.c librtemscpu_a_SOURCES += libfs/src/pipe/fifo.c librtemscpu_a_SOURCES += libfs/src/pipe/pipe.c diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h index 16a4fb69..1b84f8c 100644 --- a/cpukit/include/rtems/confdefs/libio.h +++ b/cpukit/include/rtems/confdefs/libio.h @@ -231,9 +231,9 @@ static const rtems_filesystem_operations_table IMFS_root_ops = { #endif rtems_filesystem_default_fsunmount, #ifdef CONFIGURE_IMFS_DISABLE_UTIME -rtems_filesystem_default_utime, +rtems_filesystem_default_utimens, #else -IMFS_utime, +IMFS_utimens, #endif #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK rtems_filesystem_default_symlink, diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index b2a9868..6e0d5d5 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -5,7 +5,7 @@ */ /* - * COPYRIGHT (c) 1989-2011. + * COPYRIGHT (c) 1989-2011, 2021. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -954,10 +954,9 @@ extern int device_ftruncate( * This routine is the implementation of the utime() system * call for the IMFS. */ -extern int IMFS_utime( +extern int IMFS_utimens( const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime + struct timespec times[2] ); /** diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h index 519e797..99543ba 100644 --- a/cpukit/include/rtems/libio.h +++ b/cpukit/include/rtems/libio.h @@ -11,7 +11,7 @@ */ /* - * COPYRIGHT (c) 1989-2008. + * COPYRIGHT (c) 1989-2008, 2021. * On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are @@ -375,18
[PATCH v2 2/5] libcsupport: Implement utime() in terms of utimensat()
utime() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4397 --- cpukit/libcsupport/src/utime.c | 75 +++--- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index e2d8883..cca7eb5 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c @@ -1,58 +1,65 @@ /** * @file * - * @brief Set File Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in seconds. */ /* - * 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 #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( , path, eval_flags ); - struct utimbuf now_times; - - if ( times == NULL ) { -time_t now = time( NULL ); - -now_times.actime = now; -now_times.modtime = now; - -times = _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( ); + 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
[PATCH v2 1/5] libcsupport: Added futimens() and utimensat()
Created futimens.c and utimensat.c to add support for the POSIX methods futimens() and utimensat(). utime() and utimes() are considered obsolote by POSIX, but RTEMS will continue to support them. Closes #4396 --- cpukit/Makefile.am | 2 + cpukit/include/rtems/libio_.h | 60 +- cpukit/libcsupport/src/futimens.c | 87 ++ cpukit/libcsupport/src/utimensat.c | 239 + spec/build/cpukit/librtemscpu.yml | 2 + 5 files changed, 387 insertions(+), 3 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index b0df610..29b4207 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c librtemscpu_a_SOURCES += libcsupport/src/utime.c librtemscpu_a_SOURCES += libcsupport/src/utimes.c +librtemscpu_a_SOURCES += libcsupport/src/futimens.c +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c librtemscpu_a_SOURCES += libcsupport/src/utsname.c librtemscpu_a_SOURCES += libcsupport/src/vprintk.c librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index e9eb462..7a0a169 100644 --- a/cpukit/include/rtems/libio_.h +++ b/cpukit/include/rtems/libio_.h @@ -2,13 +2,12 @@ * @file * * @brief LibIO Internal Interface - * + * * This file is the libio internal interface. */ /* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are * Copyright (c) 2012 embedded brains GmbH. @@ -357,6 +356,61 @@ static inline void rtems_filesystem_instance_unlock( (*mt_entry->ops->unlock_h)( mt_entry ); } +/* Prototypes for functions used between utimensat() and futimens() */ + +/** + * @brief Checks the tv_sec member of a timespec struct + * + * @param[in] time The timespec struct to be validated + * + * Ensures that the value in the tv_sec member is non-negative. + * + * @retval Returns true if the tv_sec member is a valid value, otherwise false. + */ +bool rtems_filesystem_utime_tv_sec_valid( struct timespec time ); + +/** + * @brief Checks the tv_nsec member of a timespec struct + * + * Ensures that the value in the tv_nsec member is equal to either + * UTIME_NOW, UTIME_OMIT, or a value greater-than or equal to zero + * and less than a billion. + * + * @param[in] time The timespec struct to be validated + * + * @retval Returns true if tv_nsec member is a valid value, otherwise false. + */ +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); + +/** + * @brief Determines if the process has write permissions to a file + * + * Checks that the process has the same userID as the file and whether the + * file has write permissions. + * + * @param[in] currentloc The current location to a file + * @param[in] fstat_h The file handler of @currentloc + * + * @retval Returns 0 if the process has write permissions, otherwise -1. + */ +int rtems_filesystem_utime_check_permissions( + const rtems_filesystem_location_info_t *currentloc, + const struct timespec times[2] +); + +/** + * @brief Checks @times and updates @new_times + * + * @param[in] times The timespec struct to be checked + * @param[in,out] new_times The timespec struct to contain the updated time + * + * @retval Returns 0 if the time was update, otherwise -1. + */ +int rtems_filesystem_utime_check_times( + const struct timespec times[2], + struct timespec new_times[2] +); + /* * File Descriptor Routine Prototypes */ diff --git a/cpukit/libcsupport/src/futimens.c b/cpukit/libcsupport/src/futimens.c new file mode 100644 index 000..c2ef9da --- /dev/null +++ b/cpukit/libcsupport/src/futimens.c @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup libcsupport + * + * @brief Set file access and modification times based on file descriptor in + * nanoseconds. + */ + +/* + * 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
[PATCH v2 3/5] libcsupport: Implement utimes() in terms of utimensat()
utimes() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4398 --- cpukit/libcsupport/src/utimes.c | 51 ++--- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/cpukit/libcsupport/src/utimes.c b/cpukit/libcsupport/src/utimes.c index 3dc47c0..eaed492 100644 --- a/cpukit/libcsupport/src/utimes.c +++ b/cpukit/libcsupport/src/utimes.c @@ -1,38 +1,63 @@ /** * @file * - * @brief Change File Last Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in milliseconds. */ /* - * Written by: Vinu Rajashekhar + * 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 #include "config.h" #endif -#include -#include #include +#include + +/** + * https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/futimens.html + * + * Set file access and modification times + */ int utimes( const char *path, const struct timeval times[2] -) +) { - struct utimbuf timeinsecs; + struct timespec timeinsecs[2]; if ( times == NULL ) -return utime( path, NULL ); +return utimensat( AT_FDCWD, path, NULL , 0 ); - timeinsecs.actime = times[0].tv_sec; - timeinsecs.modtime = times[1].tv_sec; + timeinsecs[0].tv_sec = times[0].tv_sec; + timeinsecs[0].tv_nsec = times[0].tv_usec * 1000; + timeinsecs[1].tv_sec = times[1].tv_sec; + timeinsecs[1].tv_nsec = times[1].tv_usec * 1000; - return utime( path, ); + return utimensat( AT_FDCWD, path, timeinsecs, 0 ); } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 0/5] Add nanosecond support patch
Hi, Here's the patch set with the recommended changes. Joel, Kinsey, and I changed the check for the EACCES and added the EPERM case. We believe that it is correct now. Thanks, Ryan Ryan Long (5): libcsupport: Added futimens() and utimensat() libcsupport: Implement utime() in terms of utimensat() libcsupport: Implement utimes() in terms of utimensat() psx13: Added tests for utimensat() and futimens() Change filesystem utime_h handler to utimens_h bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 6 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 7 +- cpukit/include/rtems/libio.h| 21 +- cpukit/include/rtems/libio_.h | 60 +++- cpukit/libcsupport/src/__usrenv.c | 9 +- cpukit/libcsupport/src/futimens.c | 87 + cpukit/libcsupport/src/utime.c | 75 ++-- cpukit/libcsupport/src/utimensat.c | 239 + cpukit/libcsupport/src/utimes.c | 51 ++- cpukit/libfs/src/defaults/default_ops.c | 2 +- cpukit/libfs/src/defaults/default_utime.c | 32 -- cpukit/libfs/src/defaults/default_utimens.c | 33 ++ cpukit/libfs/src/dosfs/msdos_init.c | 11 +- cpukit/libfs/src/ftpfs/ftpfs.c | 2 +- cpukit/libfs/src/ftpfs/tftpDriver.c | 2 +- cpukit/libfs/src/imfs/imfs_init.c | 4 +- cpukit/libfs/src/imfs/imfs_utime.c | 41 --- cpukit/libfs/src/imfs/imfs_utimens.c| 42 +++ cpukit/libfs/src/jffs2/src/fs-rtems.c | 11 +- cpukit/libfs/src/rfs/rtems-rfs-rtems.c | 16 +- spec/build/cpukit/librtemscpu.yml | 6 +- testsuites/psxtests/psx13/main.c| 5 +- testsuites/psxtests/psx13/test.c| 517 ++-- 25 files changed, 1084 insertions(+), 201 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c 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 -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v5 4/5] psx13: Added tests for utimensat() and futimens()
Improved tests for utime() and utimes() and update license. Close #4399 --- testsuites/psxtests/psx13/main.c | 5 +- testsuites/psxtests/psx13/test.c | 499 +-- 2 files changed, 481 insertions(+), 23 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index f9e7907..7a560f9 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * @@ -8,8 +6,7 @@ */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index e98b03a..0754dbc 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ +/* SPDX-License-Identifier: BSD-2-Clause */ /** * @file @@ -17,12 +17,13 @@ * - umask() * - utime() * - utimes() + * - utimensat() + * - futimens() * - sync() */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 @@ -52,6 +53,8 @@ #include #include +#include +#include #include #include #include @@ -210,8 +213,7 @@ static void Dup2Test( void ) } /** - * @brief Exercises fdatasync(). Does NOT test the functionality of the - *underlying fdatasync entry in the IMFS op table. + * @brief Exercises fdatasync(). */ static void FDataSyncTest( void ) { @@ -259,60 +261,517 @@ static void UMaskTest( void ) } /** - * @brief Exercises utime(). Does not test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utime(). */ static void UTimeTest( void ) { int rv; struct utimbuf time; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: Pass an invalid filename. */ rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Case: Change user ID to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv == 0 ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = seteuid( 0 ); + rtems_test_assert( rv == 0 ); + + /* EINVAL test cases */ + + /* Case: Invalid access time */ + time.actime = -1; + time.modtime = 54321; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Case: Invalid modified time */ + time.actime = 12345; + time.modtime = -1; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Successful test cases */ + + /* Case: Test without times argument */ + clock_gettime( CLOCK_REALTIME, _time ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == 0 ); + + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); + + /* Case: time is filled with valid values */ time.actime = 12345; time.modtime = 54321; rv = utime( "testfile1.tst", ); rtems_test_assert( rv == 0 ); - /* But, did it set the time? */ + /* Check that it actually changed the time */ rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 ); rtems_test_assert( fstat.st_atime == 12345 ); rtems_test_assert( fstat.st_mtime == 54321 ); - - rv = utime( "testfile1.tst", NULL ); - rtems_test_assert( rv == 0 ); } /** - * @brief Exercises utimes(). Does NOT test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utimes(). */ static void UTimesTest( void ) { int rv; struct timeval time[2]; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: First, an invalid filename. */ rv = utimes( "!This is an =invalid p@thname!!! : )", NULL); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Change the user ID of the process to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv ==
[PATCH v5 5/5] Change filesystem utime_h handler to utimens_h
Also updated licenses. Closes #4400 --- bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 4 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 35 - cpukit/include/rtems/libio.h| 55 +-- cpukit/libcsupport/src/__usrenv.c | 39 +-- cpukit/libcsupport/src/futimens.c | 2 +- cpukit/libcsupport/src/utimensat.c | 2 +- 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 | 49 cpukit/libfs/src/ftpfs/ftpfs.c | 44 -- cpukit/libfs/src/ftpfs/tftpDriver.c | 28 +++--- 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 spec/build/cpukit/librtemscpu.yml | 4 +- 20 files changed, 346 insertions(+), 193 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 diff --git a/bsps/arm/csb337/umon/tfsDriver.c b/bsps/arm/csb337/umon/tfsDriver.c index 0195346..caf3a4b 100644 --- a/bsps/arm/csb337/umon/tfsDriver.c +++ b/bsps/arm/csb337/umon/tfsDriver.c @@ -657,7 +657,7 @@ static const rtems_filesystem_operations_table rtems_tfs_ops = { .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/Makefile.am b/cpukit/Makefile.am index 29b4207..c144773 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -377,7 +377,7 @@ librtemscpu_a_SOURCES += libfs/src/defaults/default_rmnod.c librtemscpu_a_SOURCES += libfs/src/defaults/default_statvfs.c librtemscpu_a_SOURCES += libfs/src/defaults/default_symlink.c librtemscpu_a_SOURCES += libfs/src/defaults/default_unmount.c -librtemscpu_a_SOURCES += libfs/src/defaults/default_utime.c +librtemscpu_a_SOURCES += libfs/src/defaults/default_utimens.c librtemscpu_a_SOURCES += libfs/src/defaults/default_write.c librtemscpu_a_SOURCES += libfs/src/defaults/default_writev.c librtemscpu_a_SOURCES += libfs/src/dosfs/fat.c @@ -434,7 +434,7 @@ librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat_file.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_symlink.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_unmount.c -librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utime.c +librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utimens.c librtemscpu_a_SOURCES += libfs/src/imfs/ioman.c librtemscpu_a_SOURCES += libfs/src/pipe/fifo.c librtemscpu_a_SOURCES += libfs/src/pipe/pipe.c diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h index 16a4fb69..1b84f8c 100644 --- a/cpukit/include/rtems/confdefs/libio.h +++ b/cpukit/include/rtems/confdefs/libio.h @@ -231,9 +231,9 @@ static const rtems_filesystem_operations_table IMFS_root_ops = { #endif rtems_filesystem_default_fsunmount, #ifdef CONFIGURE_IMFS_DISABLE_UTIME -rtems_filesystem_default_utime, +rtems_filesystem_default_utimens, #else -IMFS_utime, +IMFS_utimens, #endif #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK rtems_filesystem_default_symlink, diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index b2a9868..57c498c 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -5,12 +7,28 @@ */ /* - * COPYRIGHT (c) 1989-2011. - * 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. + * 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. +
[PATCH v5 3/5] libcsupport: Implement utimes() in terms of utimensat()
utimes() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4398 --- cpukit/libcsupport/src/utimes.c | 63 - 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/cpukit/libcsupport/src/utimes.c b/cpukit/libcsupport/src/utimes.c index 3dc47c0..9748abb 100644 --- a/cpukit/libcsupport/src/utimes.c +++ b/cpukit/libcsupport/src/utimes.c @@ -1,38 +1,73 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Change File Last Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in milliseconds. */ /* - * Written by: Vinu Rajashekhar + * 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. + * + * 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 #include +#include + +#include +/** + * https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/futimens.html + * + * Set file access and modification times + */ int utimes( const char *path, const struct timeval times[2] -) +) { - struct utimbuf timeinsecs; + struct timespec new_times[2]; - if ( times == NULL ) -return utime( path, NULL ); + if ( times == NULL ) { +return utimensat( AT_FDCWD, path, NULL , 0 ); + } - timeinsecs.actime = times[0].tv_sec; - timeinsecs.modtime = times[1].tv_sec; + _Timespec_Set( +_times[0], +times[0].tv_sec, +times[0].tv_usec * TOD_NANOSECONDS_PER_MICROSECOND + ); + _Timespec_Set( +_times[1], +times[1].tv_sec, +times[1].tv_usec * TOD_NANOSECONDS_PER_MICROSECOND + ); - return utime( path, ); + 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
[PATCH v5 1/5] libcsupport: Added futimens() and utimensat()
Created futimens.c and utimensat.c to add support for the POSIX methods futimens() and utimensat(). utime() and utimes() are considered obsolote by POSIX, but RTEMS will continue to support them. Closes #4396 --- cpukit/Makefile.am | 2 + cpukit/include/rtems/libio_.h| 95 +++-- cpukit/include/rtems/score/timespec.h| 44 +- cpukit/libcsupport/src/futimens.c| 87 cpukit/libcsupport/src/utimensat.c | 225 +++ cpukit/score/src/timespecisnonnegative.c | 54 spec/build/cpukit/librtemscpu.yml| 3 + 7 files changed, 495 insertions(+), 15 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c create mode 100644 cpukit/score/src/timespecisnonnegative.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index b0df610..29b4207 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c librtemscpu_a_SOURCES += libcsupport/src/utime.c librtemscpu_a_SOURCES += libcsupport/src/utimes.c +librtemscpu_a_SOURCES += libcsupport/src/futimens.c +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c librtemscpu_a_SOURCES += libcsupport/src/utsname.c librtemscpu_a_SOURCES += libcsupport/src/vprintk.c librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index e9eb462..26d6c1e 100644 --- a/cpukit/include/rtems/libio_.h +++ b/cpukit/include/rtems/libio_.h @@ -1,23 +1,42 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * * @brief LibIO Internal Interface - * + * * This file is the libio internal interface. */ /* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). * - * Modifications to support reference counting in the file system are - * Copyright (c) 2012 embedded brains GmbH. + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. * - * 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. */ + #ifndef _RTEMS_RTEMS_LIBIO__H #define _RTEMS_RTEMS_LIBIO__H @@ -30,6 +49,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -357,6 +377,65 @@ static inline void rtems_filesystem_instance_unlock( (*mt_entry->ops->unlock_h)( mt_entry ); } +/** + * @brief Checks the tv_nsec member of a timespec struct + * + * This function is used with utimensat() and futimens() only. This ensures + * that the value in the tv_nsec member is equal to either UTIME_NOW, + * UTIME_OMIT, or a value greater-than or equal to zero and less than a + * billion. + * + * @param[in] time The timespec struct to be validated + * + * @retval true The tv_nsec member is a valid value. + * @retval false The tv_nsec member is not a valid value. + */ +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); + +/** + * @brief Checks for errors and if the process has write permissions to the file. + * + * This function is only used with utimensat() and futimens().It checks for + * EACCES and EPERM errors depending on what values are in @a times and if the + * process has write permissions to the file. + * + * @param[in] currentloc The current location to a file + * @param[in] times The timespecs used to check for errors. The
[PATCH v5 2/5] libcsupport: Implement utime() in terms of utimensat()
utime() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4397 --- cpukit/libcsupport/src/utime.c | 72 +++--- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index e2d8883..5d80ca3 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c @@ -1,58 +1,66 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Set File Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in seconds. */ /* - * 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 #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( , path, eval_flags ); - struct utimbuf now_times; + struct timespec new_times[2]; if ( times == NULL ) { -time_t now = time( NULL ); - -now_times.actime = now; -now_times.modtime = now; - -times = _times; +return utimensat(AT_FDCWD, path, NULL, 0); } - rv = (*currentloc->mt_entry->ops->utime_h)( -currentloc, -times->actime, -times->modtime - ); - - rtems_filesystem_eval_path_cleanup( ); + _Timespec_Set(_times[0], times->actime, 0); + _Timespec_Set(_times[1], times->modtime, 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
[PATCH v5 0/5] Add nanosecond support patch
Hi, For this series of patches, I - fixed brace placement in utime.c and utimes.c - Changed license back to what it was in msdos_init.c Thanks, Ryan Ryan Long (5): libcsupport: Added futimens() and utimensat() libcsupport: Implement utime() in terms of utimensat() libcsupport: Implement utimes() in terms of utimensat() psx13: Added tests for utimensat() and futimens() Change filesystem utime_h handler to utimens_h bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 6 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 35 +- cpukit/include/rtems/libio.h| 55 +-- cpukit/include/rtems/libio_.h | 95 +- cpukit/include/rtems/score/timespec.h | 44 ++- cpukit/libcsupport/src/__usrenv.c | 39 ++- cpukit/libcsupport/src/futimens.c | 87 + cpukit/libcsupport/src/utime.c | 72 ++-- cpukit/libcsupport/src/utimensat.c | 225 + cpukit/libcsupport/src/utimes.c | 63 +++- 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 | 49 ++- cpukit/libfs/src/ftpfs/ftpfs.c | 44 +-- cpukit/libfs/src/ftpfs/tftpDriver.c | 28 +- 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 +- cpukit/score/src/timespecisnonnegative.c| 54 +++ spec/build/cpukit/librtemscpu.yml | 7 +- testsuites/psxtests/psx13/main.c| 5 +- testsuites/psxtests/psx13/test.c| 499 ++-- 27 files changed, 1409 insertions(+), 275 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c 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 create mode 100644 cpukit/score/src/timespecisnonnegative.c -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v3 1/5] libcsupport: Added futimens() and utimensat()
Reply is below. -Original Message- From: Gedare Bloom Sent: Wednesday, May 12, 2021 12:34 PM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH v3 1/5] libcsupport: Added futimens() and utimensat() On Wed, May 12, 2021 at 7:33 AM Ryan Long wrote: > > Created futimens.c and utimensat.c to add support for the POSIX > methods futimens() and utimensat(). > > utime() and utimes() are considered obsolote by POSIX, but RTEMS will > continue to support them. > > Closes #4396 > --- > cpukit/Makefile.am | 2 + > cpukit/include/rtems/libio_.h| 64 - > cpukit/include/rtems/score/timespec.h| 16 ++- > cpukit/libcsupport/src/futimens.c| 87 > cpukit/libcsupport/src/utimensat.c | 224 > +++ > cpukit/score/src/timespecisnonnegative.c | 35 + > spec/build/cpukit/librtemscpu.yml| 3 + > 7 files changed, 426 insertions(+), 5 deletions(-) create mode > 100644 cpukit/libcsupport/src/futimens.c create mode 100644 > cpukit/libcsupport/src/utimensat.c > create mode 100644 cpukit/score/src/timespecisnonnegative.c > > diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index > b0df610..29b4207 100644 > --- a/cpukit/Makefile.am > +++ b/cpukit/Makefile.am > @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c > librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c > librtemscpu_a_SOURCES += libcsupport/src/utime.c > librtemscpu_a_SOURCES += libcsupport/src/utimes.c > +librtemscpu_a_SOURCES += libcsupport/src/futimens.c > +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c > librtemscpu_a_SOURCES += libcsupport/src/utsname.c > librtemscpu_a_SOURCES += libcsupport/src/vprintk.c > librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git > a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index > e9eb462..b7455ef 100644 > --- a/cpukit/include/rtems/libio_.h > +++ b/cpukit/include/rtems/libio_.h > @@ -2,13 +2,12 @@ > * @file > * > * @brief LibIO Internal Interface > - * > + * > * This file is the libio internal interface. > */ > > /* > - * COPYRIGHT (c) 1989-2011. > - * On-Line Applications Research Corporation (OAR). > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). > * > * Modifications to support reference counting in the file system are > * Copyright (c) 2012 embedded brains GmbH. > @@ -30,6 +29,7 @@ > #include > #include > #include > +#include > > #ifdef __cplusplus > extern "C" { > @@ -357,6 +357,64 @@ static inline void rtems_filesystem_instance_unlock( >(*mt_entry->ops->unlock_h)( mt_entry ); } > > +/** > + * @brief Checks the tv_nsec member of a timespec struct > + * > + * This function is used with utimensat() and futimens() only. This > +ensures > + * that the value in the tv_nsec member is equal to either UTIME_NOW, > + * UTIME_OMIT, or a value greater-than or equal to zero and less than > +a > + * billion. > + * > + * @param[in] time The timespec struct to be validated > + * > + * @retval Returns true if tv_nsec member is a valid value, otherwise false. > + */ > +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); > + > +/** > + * @brief Determines if the process has write permissions to a file I think it is more specific than that. Also, missing period. > + * > + * The timespec at index 0 is the access time, the timespec at index > + 1 is the > + * modification time. Should this note be on the @param[in] times below? [Ryan Long] Makes sense. I'll move it there. > + * > + * This function is only used with utimensat() and futimens(). This > + checks > + * whether the process has write access to a file, and checks for > + EACCES > + * and EPERM errors depending on what values are in @times and if the > + process > + * has write permissions to the file. > + * > + * @param[in] currentloc The current location to a file > + * @param[in] times The timespec instance that will update the > + timestamps update? nothing about this function seems to be an update? [Ryan Long] I'll change this to just say something like "The timespec instance used to check for errors". Is there another name for this function that you think would fit better? While it is checking for the appropriate permissions, it's also checking for errors, so I'm not sure if this function name fits anymore. > + * > + * @retval Returns 0 if the process has write permissions, otherwise -1. > + */ > +int rtems_filesystem_utime_check_permissions( > + const rtems_filesystem_location_info_t *currentloc, > + const struct timespec times[2] > +); &
[PATCH v4 4/5] psx13: Added tests for utimensat() and futimens()
Improved tests for utime() and utimes() and update license. Close #4399 --- testsuites/psxtests/psx13/main.c | 5 +- testsuites/psxtests/psx13/test.c | 499 +-- 2 files changed, 481 insertions(+), 23 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index f9e7907..7a560f9 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * @@ -8,8 +6,7 @@ */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index e98b03a..0754dbc 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ +/* SPDX-License-Identifier: BSD-2-Clause */ /** * @file @@ -17,12 +17,13 @@ * - umask() * - utime() * - utimes() + * - utimensat() + * - futimens() * - sync() */ /* - * COPYRIGHT (c) 1989-2009, 2021. - * 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 @@ -52,6 +53,8 @@ #include #include +#include +#include #include #include #include @@ -210,8 +213,7 @@ static void Dup2Test( void ) } /** - * @brief Exercises fdatasync(). Does NOT test the functionality of the - *underlying fdatasync entry in the IMFS op table. + * @brief Exercises fdatasync(). */ static void FDataSyncTest( void ) { @@ -259,60 +261,517 @@ static void UMaskTest( void ) } /** - * @brief Exercises utime(). Does not test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utime(). */ static void UTimeTest( void ) { int rv; struct utimbuf time; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: Pass an invalid filename. */ rv = utime( "!This is an =invalid p@thname!!! :)", NULL ); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Case: Change user ID to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv == 0 ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = seteuid( 0 ); + rtems_test_assert( rv == 0 ); + + /* EINVAL test cases */ + + /* Case: Invalid access time */ + time.actime = -1; + time.modtime = 54321; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Case: Invalid modified time */ + time.actime = 12345; + time.modtime = -1; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + /* Successful test cases */ + + /* Case: Test without times argument */ + clock_gettime( CLOCK_REALTIME, _time ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == 0 ); + + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); + + /* Case: time is filled with valid values */ time.actime = 12345; time.modtime = 54321; rv = utime( "testfile1.tst", ); rtems_test_assert( rv == 0 ); - /* But, did it set the time? */ + /* Check that it actually changed the time */ rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 ); rtems_test_assert( fstat.st_atime == 12345 ); rtems_test_assert( fstat.st_mtime == 54321 ); - - rv = utime( "testfile1.tst", NULL ); - rtems_test_assert( rv == 0 ); } /** - * @brief Exercises utimes(). Does NOT test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utimes(). */ static void UTimesTest( void ) { int rv; struct timeval time[2]; + struct timespec current_time; struct stat fstat; - /* First, an invalid filename. */ + /* ENOENT test case */ + + /* Case: First, an invalid filename. */ rv = utimes( "!This is an =invalid p@thname!!! : )", NULL); rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); - /* Now, the success test. */ + /* EACCES test case */ + + /* Change the user ID of the process to someone besides root */ + rv = seteuid( 1 ); + rtems_test_assert( rv ==
[PATCH v4 0/5] Add nanosecond support patch
Hi, Here are the patches with the requested changes. In this iteration, I: - Used timespec macros and defined constants - Updated more file copyrights - Fixed some wording - changed rtems_filesystem_utime_check_times() to rtems_filesystem_utime_update() Thanks, Ryan Ryan Long (5): libcsupport: Added futimens() and utimensat() libcsupport: Implement utime() in terms of utimensat() libcsupport: Implement utimes() in terms of utimensat() psx13: Added tests for utimensat() and futimens() Change filesystem utime_h handler to utimens_h bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 6 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 35 +- cpukit/include/rtems/libio.h| 55 +-- cpukit/include/rtems/libio_.h | 95 +- cpukit/include/rtems/score/timespec.h | 44 ++- cpukit/libcsupport/src/__usrenv.c | 39 ++- cpukit/libcsupport/src/futimens.c | 87 + cpukit/libcsupport/src/utime.c | 75 +++-- cpukit/libcsupport/src/utimensat.c | 225 + cpukit/libcsupport/src/utimes.c | 62 +++- 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 | 48 ++- cpukit/libfs/src/ftpfs/ftpfs.c | 44 +-- cpukit/libfs/src/ftpfs/tftpDriver.c | 28 +- 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 +- cpukit/score/src/timespecisnonnegative.c| 54 +++ spec/build/cpukit/librtemscpu.yml | 7 +- testsuites/psxtests/psx13/main.c| 5 +- testsuites/psxtests/psx13/test.c| 499 ++-- 27 files changed, 1410 insertions(+), 275 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c 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 create mode 100644 cpukit/score/src/timespecisnonnegative.c -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v4 2/5] libcsupport: Implement utime() in terms of utimensat()
utime() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4397 --- cpukit/libcsupport/src/utime.c | 75 +++--- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c index e2d8883..a42303c 100644 --- a/cpukit/libcsupport/src/utime.c +++ b/cpukit/libcsupport/src/utime.c @@ -1,58 +1,67 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Set File Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in seconds. */ /* - * 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 #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( , path, eval_flags ); - struct utimbuf now_times; - - if ( times == NULL ) { -time_t now = time( NULL ); + struct timespec new_times[2]; -now_times.actime = now; -now_times.modtime = now; - -times = _times; + if ( times == NULL ) + { +return utimensat(AT_FDCWD, path, NULL, 0); } - rv = (*currentloc->mt_entry->ops->utime_h)( -currentloc, -times->actime, -times->modtime - ); - - rtems_filesystem_eval_path_cleanup( ); + _Timespec_Set(_times[0], times->actime, 0); + _Timespec_Set(_times[1], times->modtime, 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
[PATCH v4 1/5] libcsupport: Added futimens() and utimensat()
Created futimens.c and utimensat.c to add support for the POSIX methods futimens() and utimensat(). utime() and utimes() are considered obsolote by POSIX, but RTEMS will continue to support them. Closes #4396 --- cpukit/Makefile.am | 2 + cpukit/include/rtems/libio_.h| 95 +++-- cpukit/include/rtems/score/timespec.h| 44 +- cpukit/libcsupport/src/futimens.c| 87 cpukit/libcsupport/src/utimensat.c | 225 +++ cpukit/score/src/timespecisnonnegative.c | 54 spec/build/cpukit/librtemscpu.yml| 3 + 7 files changed, 495 insertions(+), 15 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c create mode 100644 cpukit/score/src/timespecisnonnegative.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index b0df610..29b4207 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c librtemscpu_a_SOURCES += libcsupport/src/utime.c librtemscpu_a_SOURCES += libcsupport/src/utimes.c +librtemscpu_a_SOURCES += libcsupport/src/futimens.c +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c librtemscpu_a_SOURCES += libcsupport/src/utsname.c librtemscpu_a_SOURCES += libcsupport/src/vprintk.c librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index e9eb462..26d6c1e 100644 --- a/cpukit/include/rtems/libio_.h +++ b/cpukit/include/rtems/libio_.h @@ -1,23 +1,42 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * * @brief LibIO Internal Interface - * + * * This file is the libio internal interface. */ /* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation (OAR). * - * Modifications to support reference counting in the file system are - * Copyright (c) 2012 embedded brains GmbH. + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. * - * 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. */ + #ifndef _RTEMS_RTEMS_LIBIO__H #define _RTEMS_RTEMS_LIBIO__H @@ -30,6 +49,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -357,6 +377,65 @@ static inline void rtems_filesystem_instance_unlock( (*mt_entry->ops->unlock_h)( mt_entry ); } +/** + * @brief Checks the tv_nsec member of a timespec struct + * + * This function is used with utimensat() and futimens() only. This ensures + * that the value in the tv_nsec member is equal to either UTIME_NOW, + * UTIME_OMIT, or a value greater-than or equal to zero and less than a + * billion. + * + * @param[in] time The timespec struct to be validated + * + * @retval true The tv_nsec member is a valid value. + * @retval false The tv_nsec member is not a valid value. + */ +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); + +/** + * @brief Checks for errors and if the process has write permissions to the file. + * + * This function is only used with utimensat() and futimens().It checks for + * EACCES and EPERM errors depending on what values are in @a times and if the + * process has write permissions to the file. + * + * @param[in] currentloc The current location to a file + * @param[in] times The timespecs used to check for errors. The
[PATCH v4 3/5] libcsupport: Implement utimes() in terms of utimensat()
utimes() now calls utimensat() to update file access and modification timestamps. Updated license. Closes #4398 --- cpukit/libcsupport/src/utimes.c | 62 - 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/cpukit/libcsupport/src/utimes.c b/cpukit/libcsupport/src/utimes.c index 3dc47c0..0ff6662 100644 --- a/cpukit/libcsupport/src/utimes.c +++ b/cpukit/libcsupport/src/utimes.c @@ -1,38 +1,74 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @brief Change File Last Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in milliseconds. */ /* - * Written by: Vinu Rajashekhar + * 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. + * + * 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 #include +#include + +#include +/** + * https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/futimens.html + * + * Set file access and modification times + */ int utimes( const char *path, const struct timeval times[2] -) +) { - struct utimbuf timeinsecs; + struct timespec new_times[2]; if ( times == NULL ) -return utime( path, NULL ); + { +return utimensat( AT_FDCWD, path, NULL , 0 ); + } - timeinsecs.actime = times[0].tv_sec; - timeinsecs.modtime = times[1].tv_sec; + _Timespec_Set( +_times[0], +times[0].tv_sec, +times[0].tv_usec * TOD_NANOSECONDS_PER_MICROSECOND + ); + _Timespec_Set( +_times[1], +times[1].tv_sec, +times[1].tv_usec * TOD_NANOSECONDS_PER_MICROSECOND + ); - return utime( path, ); + 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
[PATCH v4 5/5] Change filesystem utime_h handler to utimens_h
Also updated licenses. Closes #4400 --- bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 4 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 35 - cpukit/include/rtems/libio.h| 55 +-- cpukit/libcsupport/src/__usrenv.c | 39 +-- cpukit/libcsupport/src/futimens.c | 2 +- cpukit/libcsupport/src/utimensat.c | 2 +- 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 | 48 cpukit/libfs/src/ftpfs/ftpfs.c | 44 -- cpukit/libfs/src/ftpfs/tftpDriver.c | 28 +++--- 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 spec/build/cpukit/librtemscpu.yml | 4 +- 20 files changed, 345 insertions(+), 193 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 diff --git a/bsps/arm/csb337/umon/tfsDriver.c b/bsps/arm/csb337/umon/tfsDriver.c index 0195346..caf3a4b 100644 --- a/bsps/arm/csb337/umon/tfsDriver.c +++ b/bsps/arm/csb337/umon/tfsDriver.c @@ -657,7 +657,7 @@ static const rtems_filesystem_operations_table rtems_tfs_ops = { .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/Makefile.am b/cpukit/Makefile.am index 29b4207..c144773 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -377,7 +377,7 @@ librtemscpu_a_SOURCES += libfs/src/defaults/default_rmnod.c librtemscpu_a_SOURCES += libfs/src/defaults/default_statvfs.c librtemscpu_a_SOURCES += libfs/src/defaults/default_symlink.c librtemscpu_a_SOURCES += libfs/src/defaults/default_unmount.c -librtemscpu_a_SOURCES += libfs/src/defaults/default_utime.c +librtemscpu_a_SOURCES += libfs/src/defaults/default_utimens.c librtemscpu_a_SOURCES += libfs/src/defaults/default_write.c librtemscpu_a_SOURCES += libfs/src/defaults/default_writev.c librtemscpu_a_SOURCES += libfs/src/dosfs/fat.c @@ -434,7 +434,7 @@ librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat_file.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_symlink.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_unmount.c -librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utime.c +librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utimens.c librtemscpu_a_SOURCES += libfs/src/imfs/ioman.c librtemscpu_a_SOURCES += libfs/src/pipe/fifo.c librtemscpu_a_SOURCES += libfs/src/pipe/pipe.c diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h index 16a4fb69..1b84f8c 100644 --- a/cpukit/include/rtems/confdefs/libio.h +++ b/cpukit/include/rtems/confdefs/libio.h @@ -231,9 +231,9 @@ static const rtems_filesystem_operations_table IMFS_root_ops = { #endif rtems_filesystem_default_fsunmount, #ifdef CONFIGURE_IMFS_DISABLE_UTIME -rtems_filesystem_default_utime, +rtems_filesystem_default_utimens, #else -IMFS_utime, +IMFS_utimens, #endif #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK rtems_filesystem_default_symlink, diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index b2a9868..57c498c 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -5,12 +7,28 @@ */ /* - * COPYRIGHT (c) 1989-2011. - * 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. + * 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. +
RE: [PATCH v2 1/5] libcsupport: Added futimens() and utimensat()
-Original Message- From: Gedare Bloom Sent: Monday, May 10, 2021 11:50 PM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH v2 1/5] libcsupport: Added futimens() and utimensat() On Mon, May 10, 2021 at 3:16 PM Ryan Long wrote: > > Reply is below. > > -Original Message- > From: Gedare Bloom > Sent: Monday, May 10, 2021 12:36 PM > To: Ryan Long > Cc: devel@rtems.org > Subject: Re: [PATCH v2 1/5] libcsupport: Added futimens() and > utimensat() > > On Thu, May 6, 2021 at 1:51 PM Ryan Long wrote: > > > > Created futimens.c and utimensat.c to add support for the POSIX > > methods futimens() and utimensat(). > > > > utime() and utimes() are considered obsolote by POSIX, but RTEMS > > will continue to support them. > > > > Closes #4396 > > --- > > cpukit/Makefile.am | 2 + > > cpukit/include/rtems/libio_.h | 60 +- > > cpukit/libcsupport/src/futimens.c | 87 ++ > > cpukit/libcsupport/src/utimensat.c | 239 > > + > > spec/build/cpukit/librtemscpu.yml | 2 + > > 5 files changed, 387 insertions(+), 3 deletions(-) create mode > > 100644 cpukit/libcsupport/src/futimens.c create mode 100644 > > cpukit/libcsupport/src/utimensat.c > > > > diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index > > b0df610..29b4207 100644 > > --- a/cpukit/Makefile.am > > +++ b/cpukit/Makefile.am > > @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += > > libcsupport/src/unmount.c librtemscpu_a_SOURCES += > > libcsupport/src/__usrenv.c librtemscpu_a_SOURCES += > > libcsupport/src/utime.c librtemscpu_a_SOURCES += > > libcsupport/src/utimes.c > > +librtemscpu_a_SOURCES += libcsupport/src/futimens.c > > +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c > > librtemscpu_a_SOURCES += libcsupport/src/utsname.c > > librtemscpu_a_SOURCES += libcsupport/src/vprintk.c > > librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git > > a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h > > index > > e9eb462..7a0a169 100644 > > --- a/cpukit/include/rtems/libio_.h > > +++ b/cpukit/include/rtems/libio_.h > > @@ -2,13 +2,12 @@ > > * @file > > * > > * @brief LibIO Internal Interface > > - * > > + * > > * This file is the libio internal interface. > > */ > > > > /* > > - * COPYRIGHT (c) 1989-2011. > > - * On-Line Applications Research Corporation (OAR). > > + * COPYRIGHT (C) 1989, 2021 On-Line Applications Research Corporation > > (OAR). > > * > > * Modifications to support reference counting in the file system are > > * Copyright (c) 2012 embedded brains GmbH. > > @@ -357,6 +356,61 @@ static inline void rtems_filesystem_instance_unlock( > >(*mt_entry->ops->unlock_h)( mt_entry ); } > > > > +/* Prototypes for functions used between utimensat() and futimens() > > +*/ > > + > We don't usually have this kind of separator comment. > > > +/** > > + * @brief Checks the tv_sec member of a timespec struct > > + * > > + * @param[in] time The timespec struct to be validated > > + * > > + * Ensures that the value in the tv_sec member is non-negative. > > + * > > + * @retval Returns true if the tv_sec member is a valid value, otherwise > > false. > > + */ > > +bool rtems_filesystem_utime_tv_sec_valid( struct timespec time ); > > + > Should this be a timespec helper instead? It seems like a straightforward > helper. > [Ryan Long] Do you mean just change the name of the function to > "timespec_helper_tv_sec_valid" or what? > I was thinking along the lines of the functions in include/rtems/score/timespec.h You might consider whether _Timespec_Is_non_negative() should be added. Speaking of which, you could probably use those helpers in a few places to simplify your code, e.g., _Timespec_Set( times[0], 0, UTIME_NOW); [Ryan Long] Both of those changes will be in the next version. > > +/** > > + * @brief Checks the tv_nsec member of a timespec struct > > + * > > + * Ensures that the value in the tv_nsec member is equal to either > > + * UTIME_NOW, UTIME_OMIT, or a value greater-than or equal to zero > > + * and less than a billion. > > + * > > + * @param[in] time The timespec struct to be validated > > + * > > + * @retval Returns true if tv_nsec member is a valid value, otherwise > > false. > > + */ > > +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); > > + > > +/** > > + * @b
[PATCH v1 1/4] rtems-fdt.c: Fix Resource leak (CID #1437645)
CID 1437645: Resource leak in rtems_fdt_load(). Closes #4297 --- cpukit/libmisc/rtems-fdt/rtems-fdt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt.c b/cpukit/libmisc/rtems-fdt/rtems-fdt.c index 7747ba9..dc5393c 100644 --- a/cpukit/libmisc/rtems-fdt/rtems-fdt.c +++ b/cpukit/libmisc/rtems-fdt/rtems-fdt.c @@ -611,6 +611,7 @@ rtems_fdt_load (const char* filename, rtems_fdt_handle* handle) return fe; } + close (bf); return 0; } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 0/4] Acked patches
Hi, These patches are from various patch sets to fix Coverity issues. These were previously acked, but other patches in the corresponding patch sets prevented them from getting pushed. Thanks, Ryan Ryan Long (4): rtems-fdt.c: Fix Resource leak (CID #1437645) main_rtrace.c: Add error return when malloc fails objectextendinformation.c: Ensure information->object_blocks is not NULL rtl-allocator.c: Put dereferences after nullcheck cpukit/libdl/rtl-allocator.c | 7 +-- cpukit/libmisc/rtems-fdt/rtems-fdt.c | 1 + cpukit/libmisc/shell/main_rtrace.c | 1 + cpukit/score/src/objectextendinformation.c | 11 +++ 4 files changed, 18 insertions(+), 2 deletions(-) -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 2/4] main_rtrace.c: Add error return when malloc fails
CID 1399709: Dereference after null check in rtems_trace_buffering_shell_save(). Closes #4329 --- cpukit/libmisc/shell/main_rtrace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpukit/libmisc/shell/main_rtrace.c b/cpukit/libmisc/shell/main_rtrace.c index 753ab9d..e4f59c4 100644 --- a/cpukit/libmisc/shell/main_rtrace.c +++ b/cpukit/libmisc/shell/main_rtrace.c @@ -473,6 +473,7 @@ rtems_trace_buffering_shell_save (int argc, char *argv[]) { close (out); printf ("error: no memory\n"); +return 1; } memset (buf, 0, SAVE_BUF_SIZE); -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 4/4] rtl-allocator.c: Put dereferences after nullcheck
CID 1444139: Dereference null return value in rtems_rtl_alloc_hook(). Closes #4333 --- cpukit/libdl/rtl-allocator.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cpukit/libdl/rtl-allocator.c b/cpukit/libdl/rtl-allocator.c index 647c0c8..861754e 100644 --- a/cpukit/libdl/rtl-allocator.c +++ b/cpukit/libdl/rtl-allocator.c @@ -162,8 +162,11 @@ rtems_rtl_allocator rtems_rtl_alloc_hook (rtems_rtl_allocator handler) { rtems_rtl_data* rtl = rtems_rtl_lock (); - rtems_rtl_allocator previous = rtl->allocator.allocator; - rtl->allocator.allocator = handler; + rtems_rtl_allocator previous = NULL; + if (rtl != NULL) { +previous = rtl->allocator.allocator; +rtl->allocator.allocator = handler; + } rtems_rtl_unlock (); return previous; } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 3/4] objectextendinformation.c: Ensure information->object_blocks is not NULL
CID 26033: Dereference after null check in _Objects_Extend_information(). Closes #4326 --- cpukit/score/src/objectextendinformation.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c index 9796eb9..c669301 100644 --- a/cpukit/score/src/objectextendinformation.c +++ b/cpukit/score/src/objectextendinformation.c @@ -171,6 +171,17 @@ Objects_Maximum _Objects_Extend_information( if ( old_maximum > extend_count ) { /* + * Coverity thinks there is a way for this to be NULL (CID #26033). + * After much time spent analyzing this, no one has identified the + * conditions where this can actually occur. Adding this _Assert ensures + * that it is never NULL. If this assert is triggered, condition + * generating this case will have been identified and it can be revisted. + * This is being done out of an abundance of caution since we could have + * easily flagged this as a false positive and ignored it completely. + */ + _Assert(information->object_blocks != NULL); + + /* * Copy each section of the table over. This has to be performed as * separate parts as size of each block has changed. */ -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 6/6] ReportsBase.cc: Fix Resource leak
CID 1503711: Resource leak in WriteSummaryReport(). Closes #4422 --- tester/covoar/ReportsBase.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index d904f8d..b4a755c 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -551,6 +551,8 @@ void ReportsBase::WriteSummaryReport( 100.0 - percentageBranches ); } + + fclose( report ); } void GenerateReports(const std::string& symbolSetName) -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 5/6] DesiredSymbols.cc: Fix resource leak
CID 1503018: Resource leak in load(). Closes #4421 --- tester/covoar/DesiredSymbols.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tester/covoar/DesiredSymbols.cc b/tester/covoar/DesiredSymbols.cc index 2866dbe..5278891 100644 --- a/tester/covoar/DesiredSymbols.cc +++ b/tester/covoar/DesiredSymbols.cc @@ -101,7 +101,7 @@ namespace Coverage { for (auto& kv : symbols.globals()) { const rld::symbols::symbol& sym = *(kv.second); if (sym.type() == sym.st_func) { - set[sym.name()] = *(new SymbolInformation); + set[sym.name()] = SymbolInformation(); setNamesToSymbols[setName].push_back(sym.name()); } } @@ -109,7 +109,7 @@ namespace Coverage { for (auto& kv : symbols.weaks()) { const rld::symbols::symbol& sym = *(kv.second); if (sym.type() == sym.st_func) { - set[sym.name()] = *(new SymbolInformation); + set[sym.name()] = SymbolInformation(); setNamesToSymbols[setName].push_back(sym.name()); } } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 3/6] GcovData.cc: Fix resource leak
CID 1399610: Resource leak in readFrame(). Closes #4418 --- tester/covoar/GcovData.cc | 40 ++-- tester/covoar/GcovData.h | 4 ++-- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/tester/covoar/GcovData.cc b/tester/covoar/GcovData.cc index 5175fb3..e8b8573 100644 --- a/tester/covoar/GcovData.cc +++ b/tester/covoar/GcovData.cc @@ -151,13 +151,13 @@ namespace Gcov { fprintf( stderr, "Error while writing function announcement to a file %s\n", gcdaFileName ); //Write function id - buffer = (*currentFunction)->getId(); + buffer = (*currentFunction).getId(); status = fwrite (, sizeof( buffer ), 1, gcdaFile ); if ( status != 1 ) fprintf( stderr, "Error while writing function id to a file %s\n", gcdaFileName ); //Write function checksum - buffer = (*currentFunction)->getChecksum(); + buffer = (*currentFunction).getChecksum(); status = fwrite (, sizeof( buffer ), 1, gcdaFile ); if ( status != 1 ) fprintf( stderr, "Error while writing function checksum to a file %s\n", gcdaFileName ); @@ -165,7 +165,7 @@ namespace Gcov { // Determine how many counters there are // and store their counts in buffer countersFound = 0; - (*currentFunction)->getCounters( llBuffer, countersFound, countersSum, countersMax ); + (*currentFunction).getCounters( llBuffer, countersFound, countersSum, countersMax ); countersFoundSum += countersFound; //Write info about counters @@ -232,7 +232,6 @@ namespace Gcov { uint32_ttempBlockId; blocks_iterator_t tempBlockIterator; int status; -GcovFunctionData* newFunction; status = readFrameHeader( , gcovFile); @@ -246,13 +245,18 @@ namespace Gcov { case GCOV_TAG_FUNCTION: -numberOfFunctions++; -newFunction = new GcovFunctionData; -if ( !readFunctionFrame(header, gcovFile, newFunction) ){ - fprintf( stderr, "Error while reading FUNCTION from gcov file...\n" ); - return false; +{ + numberOfFunctions++; + GcovFunctionData newFunction; + + if ( !readFunctionFrame(header, gcovFile, ) ){ +fprintf( stderr, "Error while reading FUNCTION from gcov file...\n" ); +return false; + } + + functions.push_back(newFunction); } -functions.push_back(newFunction); + break; case GCOV_TAG_BLOCKS: @@ -269,7 +273,7 @@ namespace Gcov { } for( uint32_t i = 0; i < header.length; i++ ) - functions.back()->addBlock(i, intBuffer[i], ""); + functions.back().addBlock(i, intBuffer[i], ""); break; @@ -281,7 +285,7 @@ namespace Gcov { } for ( int i = 1; i < (int) header.length; i += 2 ) - functions.back()->addArc(intBuffer[0], intBuffer[i], intBuffer[i+1]); + functions.back().addArc(intBuffer[0], intBuffer[i], intBuffer[i+1]); break; @@ -299,10 +303,10 @@ namespace Gcov { header.length -= 2; // Find the right block -tempBlockIterator =functions.back()->findBlockById(tempBlockId); +tempBlockIterator =functions.back().findBlockById(tempBlockId); header.length -= readString(buffer, gcovFile); -functions.back()->setBlockFileName( tempBlockIterator, buffer ); +functions.back().setBlockFileName( tempBlockIterator, buffer ); status = fread( , 4, header.length, gcovFile ); if (status != (int) header.length){ @@ -312,7 +316,7 @@ namespace Gcov { else for (int i = 0; i < (int) (header.length - 2); i++) -functions.back()->addBlockLine( tempBlockIterator, intBuffer[i] ); +functions.back().addBlockLine( tempBlockIterator, intBuffer[i] ); break; @@ -449,8 +453,8 @@ namespace Gcov { currentFunction++ ) { - (*currentFunction)->printFunctionInfo( textFile, i ); - (*currentFunction)->printCoverageInfo( textFile, i ); + (*currentFunction).printFunctionInfo( textFile, i ); + (*currentFunction).printCoverageInfo( textFile, i ); i++; } @@ -497,7 +501,7 @@ namespace Gcov { currentFunction++ ) { - if ( !(*currentFunction)->processFunctionCounters( ) ) + if ( !(*currentFunction).processFunctionCounters( ) ) status = false; } diff --git a/tester/covoar/GcovData.h b/tester/covoar/GcovData.h index 94f5331..0e74b02 100644 --- a/tester/covoar/GcovData.h +++ b/tester/covoar/GcovData.h @@ -30,8 +30,8 @@ namespace Gcov { #define GCOV_TAG_PROGRAM_SUMMARY((uint32_t)0xa300) -typedef std::list functions_t; -typedef std::list::iteratorfunctions_iterator_t; +typedef std::list functions_t; +typedef std::list::iteratorfunctions_iterator_t; struct gcov_preamble { --
[PATCH v1 2/6] TraceReaderLogQEMU.cc: Fix resource leak
CID 1399615: Resource leak in processFile(). Closes #4419 --- tester/covoar/TraceReaderLogQEMU.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tester/covoar/TraceReaderLogQEMU.cc b/tester/covoar/TraceReaderLogQEMU.cc index 508074a..b64a149 100644 --- a/tester/covoar/TraceReaderLogQEMU.cc +++ b/tester/covoar/TraceReaderLogQEMU.cc @@ -109,12 +109,12 @@ namespace Trace { return false; } - // // Discard Header section // if (! ReadUntilFound( logFile, QEMU_LOG_SECTION_END ) ) { fprintf( stderr, "Unable to locate end of log file header\n" ); + fclose( logFile ); return false; } @@ -123,6 +123,7 @@ namespace Trace { // if (! ReadUntilFound( logFile, QEMU_LOG_IN_KEY )){ fprintf(stderr,"Error: Unable to locate first IN: Block in Log file \n"); + fclose( logFile ); return false; } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 0/6] rtems-tools resource leak patches
Hi, In these patches, I added missing fclose()'s and converted some pointers to be of the data type that they were pointing to. Thanks, Ryan Ryan Long (6): Explanations.cc: Fix resource leaks TraceReaderLogQEMU.cc: Fix resource leak GcovData.cc: Fix resource leak TraceWriterQEMU.cc: Fix resource leak DesiredSymbols.cc: Fix resource leak ReportsBase.cc: Fix Resource leak tester/covoar/DesiredSymbols.cc | 4 ++-- tester/covoar/Explanations.cc | 18 ++--- tester/covoar/GcovData.cc | 40 - tester/covoar/GcovData.h| 4 ++-- tester/covoar/ReportsBase.cc| 2 ++ tester/covoar/TraceReaderLogQEMU.cc | 3 ++- tester/covoar/TraceWriterQEMU.cc| 1 + 7 files changed, 42 insertions(+), 30 deletions(-) -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 1/6] Explanations.cc: Fix resource leaks
CID 1399608: Resource leak in load(). CID 1399611: Resource leak in load(). Closes #4417 --- tester/covoar/Explanations.cc | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tester/covoar/Explanations.cc b/tester/covoar/Explanations.cc index 12bd809..d94cd2e 100644 --- a/tester/covoar/Explanations.cc +++ b/tester/covoar/Explanations.cc @@ -32,7 +32,7 @@ namespace Coverage { #define MAX_LINE_LENGTH 512 FILE *explain; char*cStatus; -Explanation *e; +Explanation e; int line = 1; if (!explanations) @@ -46,7 +46,6 @@ namespace Coverage { } while ( 1 ) { - e = new Explanation; // Read the starting line of this explanation and // skip blank lines between do { @@ -65,12 +64,13 @@ namespace Coverage { what << "line " << line << "contains a duplicate explanation (" << inputBuffer << ")"; +fclose( explain ); throw rld::error( what, "Explanations::load" ); } // Add the starting line and file - e->startingPoint = std::string(inputBuffer); - e->found = false; + e.startingPoint = std::string(inputBuffer); + e.found = false; // Get the classification cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain ); @@ -78,10 +78,11 @@ namespace Coverage { std::ostringstream what; what << "line " << line << "out of sync at the classification"; +fclose( explain ); throw rld::error( what, "Explanations::load" ); } inputBuffer[ strlen(inputBuffer) - 1] = '\0'; - e->classification = inputBuffer; + e.classification = inputBuffer; line++; // Get the explanation @@ -92,6 +93,7 @@ namespace Coverage { std::ostringstream what; what << "line " << line << "out of sync at the explanation"; + fclose( explain ); throw rld::error( what, "Explanations::load" ); } inputBuffer[ strlen(inputBuffer) - 1] = '\0'; @@ -102,15 +104,17 @@ namespace Coverage { break; } // XXX only taking last line. Needs to be a vector -e->explanation.push_back( inputBuffer ); +e.explanation.push_back( inputBuffer ); } // Add this to the set of Explanations - set[ e->startingPoint ] = *e; + set[ e.startingPoint ] = e; } done: ; +fclose( explain ); + #undef MAX_LINE_LENGTH } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 4/6] TraceWriterQEMU.cc: Fix resource leak
CID 1399621: Resource leak in writeFile(). Closes #4420 --- tester/covoar/TraceWriterQEMU.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/tester/covoar/TraceWriterQEMU.cc b/tester/covoar/TraceWriterQEMU.cc index 4bc9667..26447af 100644 --- a/tester/covoar/TraceWriterQEMU.cc +++ b/tester/covoar/TraceWriterQEMU.cc @@ -116,6 +116,7 @@ namespace Trace { status = ::fwrite( , sizeof(trace_header), 1, traceFile ); if (status != 1) { std::cerr << "Unable to write header to " << file << std::endl; + ::fclose( traceFile ); return false; } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH 1/2] rtl-obj.c: Added an early return if rtl lock fails
-Original Message- From: Chris Johns Sent: Monday, April 5, 2021 6:46 PM To: Ryan Long ; Gedare Bloom Cc: devel@rtems.org Subject: Re: [PATCH 1/2] rtl-obj.c: Added an early return if rtl lock fails On 5/4/21 11:11 pm, Ryan Long wrote: > When you say "allocating the main data structure", are you referring to the > Run-Time Link Editor (rtl)? If so, rtems_rtl_data_init() is allocating memory > for it. If it fails then rtems_rtl_data_init() returns false. Then, this > causes rtems_rtl_lock() to return NULL. I would need to look at this in much more detail to completely resolve what happens at an architectural level. That is something else to this patch. > > -Original Message- > From: Chris Johns > Sent: Tuesday, March 30, 2021 11:31 PM > To: Gedare Bloom ; Ryan Long > Cc: devel@rtems.org > Subject: Re: [PATCH 1/2] rtl-obj.c: Added an early return if rtl lock > fails > > On 31/3/21 4:08 am, Gedare Bloom wrote: >> This looks ok. I'm wondering however if these rtems_rtl_lock () ever >> should fail in practice, should it be an assert? Just wondering. > > Good question, I cannot remember. Maybe a better solution is to move to a > statically allocated lock using the newer interface Sebastian has added and > removing the check? > > However is the lock also allocating the main data structure and also > returning the status of that? I do this as a way of not uses resources until > the service is used. If that is the case the change maybe OK but the name of > the call is a bit average. > > Ryan, are you able to take have a closer look. > > Thanks > Chris > >> >> On Tue, Mar 30, 2021 at 10:58 AM Ryan Long wrote: >>> >>> ping >>> >>> -Original Message- >>> From: Ryan Long >>> Sent: Monday, March 22, 2021 12:08 PM >>> To: devel@rtems.org >>> Cc: Ryan Long >>> Subject: [PATCH 1/2] rtl-obj.c: Added an early return if rtl lock >>> fails >>> >>> CID 1444138: Dereference null return value in rtems_rtl_obj_find_file(). >>> >>> Closes #4332 >>> --- >>> cpukit/libdl/rtl-obj.c | 4 >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/cpukit/libdl/rtl-obj.c b/cpukit/libdl/rtl-obj.c index >>> a7dd740..d5a867e 100644 >>> --- a/cpukit/libdl/rtl-obj.c >>> +++ b/cpukit/libdl/rtl-obj.c >>> @@ -409,6 +409,10 @@ rtems_rtl_obj_find_file (rtems_rtl_obj* obj, >>> const char* name) >>> >>> rtl = rtems_rtl_lock (); >>> >>> + if (rtl == NULL) { >>> +return false; >>> + } An error should be set here before returning or the caller will not know whhy that got an error. >>> + >>>if (!rtems_rtl_find_file (pname, rtl->paths, >fname, >fsize)) >>>{ >>> rtems_rtl_set_error (ENOENT, "file not found"); Here is an example. [Ryan Long] Would this patch be good to merge with this addition? If not, what is the preferred solution path? Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v2] legacy nfs.c: Change filesystem utime_h handler to utimens_h
ping -Original Message- From: Ryan Long Sent: Monday, May 3, 2021 1:41 PM To: devel@rtems.org Cc: Ryan Long Subject: [PATCH v2] legacy nfs.c: Change filesystem utime_h handler to utimens_h Changed nfs_utime() to nfs_utimens(), changed the arguments to use a timespec array instead of individual variables for access and modified time. Updates #4400 --- nfsclient/src/nfs.c | 50 +- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/nfsclient/src/nfs.c b/nfsclient/src/nfs.c index bc9a2c6..72fefb9 100644 --- a/nfsclient/src/nfs.c +++ b/nfsclient/src/nfs.c @@ -2050,19 +2050,19 @@ static int nfs_rmnod( return rv; } -static int nfs_utime( +static int nfs_utimens( const rtems_filesystem_location_info_t *pathloc, /* IN */ - time_t actime, /* IN */ - time_t modtime /* IN */ + struct timespec times[2] /* IN */ + ) { sattr arg; /* TODO: add rtems EPOCH - UNIX EPOCH seconds */ - arg.atime.seconds = actime; - arg.atime.useconds = 0; - arg.mtime.seconds = modtime; - arg.mtime.useconds = 0; + arg.atime.seconds = times[0].tv_sec; + arg.atime.useconds = times[0].tv_nsec / 1000; + arg.mtime.seconds = times[1].tv_sec; + arg.mtime.useconds = times[1].tv_nsec / 1000; return nfs_sattr(pathloc->node_access, , SATTR_ATIME | SATTR_MTIME); } @@ -2254,25 +2254,25 @@ sattr arg; } const struct _rtems_filesystem_operations_table nfs_fs_ops = { - .lock_h = nfs_lock, - .unlock_h = nfs_unlock, - .eval_path_h= nfs_eval_path, - .link_h = nfs_link, + .lock_h= nfs_lock, + .unlock_h = nfs_unlock, + .eval_path_h = nfs_eval_path, + .link_h= nfs_link, .are_nodes_equal_h = nfs_are_nodes_equal, - .mknod_h= nfs_mknod, - .rmnod_h= nfs_rmnod, - .fchmod_h = nfs_fchmod, - .chown_h= nfs_chown, - .clonenod_h = nfs_clonenode, - .freenod_h = nfs_freenode, - .mount_h= rtems_filesystem_default_mount, - .unmount_h = rtems_filesystem_default_unmount, - .fsunmount_me_h = nfs_fsunmount_me, - .utime_h= nfs_utime, - .symlink_h = nfs_symlink, - .readlink_h = nfs_readlink, - .rename_h = nfs_rename, - .statvfs_h = rtems_filesystem_default_statvfs + .mknod_h = nfs_mknod, + .rmnod_h = nfs_rmnod, + .fchmod_h = nfs_fchmod, + .chown_h = nfs_chown, + .clonenod_h= nfs_clonenode, + .freenod_h = nfs_freenode, + .mount_h = rtems_filesystem_default_mount, + .unmount_h = rtems_filesystem_default_unmount, + .fsunmount_me_h= nfs_fsunmount_me, + .utimens_h = nfs_utimens, + .symlink_h = nfs_symlink, + .readlink_h= nfs_readlink, + .rename_h = nfs_rename, + .statvfs_h = rtems_filesystem_default_statvfs }; /* -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v2] libbsd nfs.c: Change filesystem utime_h handler to utimens_h
ping -Original Message- From: Ryan Long Sent: Monday, May 3, 2021 1:41 PM To: devel@rtems.org Cc: Ryan Long Subject: [PATCH v2] libbsd nfs.c: Change filesystem utime_h handler to utimens_h Changed nfs_utime() to nfs_utimens(), changed the arguments to use a timespec array instead of individual variables for access and modified time. Updates #4400 --- rtemsbsd/nfsclient/nfs.c | 50 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/rtemsbsd/nfsclient/nfs.c b/rtemsbsd/nfsclient/nfs.c index 3b8a592..baada6c 100644 --- a/rtemsbsd/nfsclient/nfs.c +++ b/rtemsbsd/nfsclient/nfs.c @@ -2058,19 +2058,19 @@ static int nfs_rmnod( return rv; } -static int nfs_utime( +static int nfs_utimens( const rtems_filesystem_location_info_t *pathloc, /* IN */ - time_t actime, /* IN */ - time_t modtime /* IN */ + struct timespec times[2] /* IN */ + ) { sattr arg; /* TODO: add rtems EPOCH - UNIX EPOCH seconds */ - arg.atime.seconds = actime; - arg.atime.useconds = 0; - arg.mtime.seconds = modtime; - arg.mtime.useconds = 0; + arg.atime.seconds = times[0].tv_sec; + arg.atime.useconds = times[0].tv_nsec / 1000; + arg.mtime.seconds = times[1].tv_sec; + arg.mtime.useconds = times[1].tv_nsec / 1000; return nfs_sattr(pathloc->node_access, , SATTR_ATIME | SATTR_MTIME); } @@ -2262,25 +2262,25 @@ sattr arg; } const struct _rtems_filesystem_operations_table nfs_fs_ops = { - .lock_h = nfs_lock, - .unlock_h = nfs_unlock, - .eval_path_h= nfs_eval_path, - .link_h = nfs_link, + .lock_h= nfs_lock, + .unlock_h = nfs_unlock, + .eval_path_h = nfs_eval_path, + .link_h= nfs_link, .are_nodes_equal_h = nfs_are_nodes_equal, - .mknod_h= nfs_mknod, - .rmnod_h= nfs_rmnod, - .fchmod_h = nfs_fchmod, - .chown_h= nfs_chown, - .clonenod_h = nfs_clonenode, - .freenod_h = nfs_freenode, - .mount_h= rtems_filesystem_default_mount, - .unmount_h = rtems_filesystem_default_unmount, - .fsunmount_me_h = nfs_fsunmount_me, - .utime_h= nfs_utime, - .symlink_h = nfs_symlink, - .readlink_h = nfs_readlink, - .rename_h = nfs_rename, - .statvfs_h = rtems_filesystem_default_statvfs + .mknod_h = nfs_mknod, + .rmnod_h = nfs_rmnod, + .fchmod_h = nfs_fchmod, + .chown_h = nfs_chown, + .clonenod_h= nfs_clonenode, + .freenod_h = nfs_freenode, + .mount_h = rtems_filesystem_default_mount, + .unmount_h = rtems_filesystem_default_unmount, + .fsunmount_me_h= nfs_fsunmount_me, + .utimens_h = nfs_utimens, + .symlink_h = nfs_symlink, + .readlink_h= nfs_readlink, + .rename_h = nfs_rename, + .statvfs_h = rtems_filesystem_default_statvfs }; /* -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH] sysconf: Removed sysconf(515)
GCC originally needed this 20 years ago. No longer needed, so it is being removed. Closes #4391 --- cpukit/posix/src/sysconf.c| 4 testsuites/psxtests/psxsysconf/init.c | 8 2 files changed, 12 deletions(-) diff --git a/cpukit/posix/src/sysconf.c b/cpukit/posix/src/sysconf.c index 1696ec5..439a27e 100644 --- a/cpukit/posix/src/sysconf.c +++ b/cpukit/posix/src/sysconf.c @@ -54,10 +54,6 @@ long sysconf( return (long) rtems_scheduler_get_processor_maximum(); case _SC_POSIX_26_VERSION: return (long) _POSIX_26_VERSION; -#if defined(__sparc__) -case 515: /* Solaris _SC_STACK_PROT */ - return 0; -#endif default: rtems_set_errno_and_return_minus_one( EINVAL ); } diff --git a/testsuites/psxtests/psxsysconf/init.c b/testsuites/psxtests/psxsysconf/init.c index a008af3..66d6dd3 100644 --- a/testsuites/psxtests/psxsysconf/init.c +++ b/testsuites/psxtests/psxsysconf/init.c @@ -83,14 +83,6 @@ void *POSIX_Init( == (long) rtems_scheduler_get_processor_maximum() ); -#if defined(__sparc__) - /* Solaris _SC_STACK_PROT - 515 */ - sc = sysconf( _SC_PAGESIZE ); - printf( "sysconf - (SPARC only) _SC_STACK_PROT=%ld\n", sc ); - if ( sc == -1 ) - rtems_test_exit(0); -#endif - TEST_END(); rtems_test_exit( 0 ); -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2] sysconf: Remove sysconf(515)
GCC originally needed this 20 years ago. No longer needed, so it is being removed. Closes #4391 --- cpukit/posix/src/sysconf.c| 4 testsuites/psxtests/psxsysconf/init.c | 8 2 files changed, 12 deletions(-) diff --git a/cpukit/posix/src/sysconf.c b/cpukit/posix/src/sysconf.c index 1696ec5..439a27e 100644 --- a/cpukit/posix/src/sysconf.c +++ b/cpukit/posix/src/sysconf.c @@ -54,10 +54,6 @@ long sysconf( return (long) rtems_scheduler_get_processor_maximum(); case _SC_POSIX_26_VERSION: return (long) _POSIX_26_VERSION; -#if defined(__sparc__) -case 515: /* Solaris _SC_STACK_PROT */ - return 0; -#endif default: rtems_set_errno_and_return_minus_one( EINVAL ); } diff --git a/testsuites/psxtests/psxsysconf/init.c b/testsuites/psxtests/psxsysconf/init.c index a008af3..66d6dd3 100644 --- a/testsuites/psxtests/psxsysconf/init.c +++ b/testsuites/psxtests/psxsysconf/init.c @@ -83,14 +83,6 @@ void *POSIX_Init( == (long) rtems_scheduler_get_processor_maximum() ); -#if defined(__sparc__) - /* Solaris _SC_STACK_PROT - 515 */ - sc = sysconf( _SC_PAGESIZE ); - printf( "sysconf - (SPARC only) _SC_STACK_PROT=%ld\n", sc ); - if ( sc == -1 ) - rtems_test_exit(0); -#endif - TEST_END(); rtems_test_exit( 0 ); -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v1 1/6] Explanations.cc: Fix resource leaks
We'll submit the C++ conversions as separate patches since they are larger. That patch will be submitted shortly. -Original Message- From: Chris Johns Sent: Friday, May 28, 2021 8:05 PM To: Ryan Long ; devel@rtems.org Subject: Re: [PATCH v1 1/6] Explanations.cc: Fix resource leaks On 29/5/21 8:08 am, Ryan Long wrote: > CID 1399608: Resource leak in load(). > CID 1399611: Resource leak in load(). > > Closes #4417 > --- > tester/covoar/Explanations.cc | 18 +++--- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/tester/covoar/Explanations.cc > b/tester/covoar/Explanations.cc index 12bd809..d94cd2e 100644 > --- a/tester/covoar/Explanations.cc > +++ b/tester/covoar/Explanations.cc > @@ -32,7 +32,7 @@ namespace Coverage { > #define MAX_LINE_LENGTH 512 > FILE *explain; > char*cStatus; > -Explanation *e; > +Explanation e; > int line = 1; > > if (!explanations) > @@ -46,7 +46,6 @@ namespace Coverage { > } > > while ( 1 ) { > - e = new Explanation; >// Read the starting line of this explanation and >// skip blank lines between >do { > @@ -65,12 +64,13 @@ namespace Coverage { > what << "line " << line > << "contains a duplicate explanation (" > << inputBuffer << ")"; > +fclose( explain ); > throw rld::error( what, "Explanations::load" ); If you used a std::ostream type object it would be automatically closed when that object destructs via any exit path. While this patch fixes the bug(s) the mixing of C here is generating these issues and effort cleaning that up will reward you. Chris >} > >// Add the starting line and file > - e->startingPoint = std::string(inputBuffer); > - e->found = false; > + e.startingPoint = std::string(inputBuffer); > + e.found = false; > >// Get the classification >cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain ); @@ > -78,10 +78,11 @@ namespace Coverage { > std::ostringstream what; > what << "line " << line > << "out of sync at the classification"; > +fclose( explain ); > throw rld::error( what, "Explanations::load" ); >} >inputBuffer[ strlen(inputBuffer) - 1] = '\0'; > - e->classification = inputBuffer; > + e.classification = inputBuffer; >line++; > >// Get the explanation > @@ -92,6 +93,7 @@ namespace Coverage { >std::ostringstream what; >what << "line " << line > << "out of sync at the explanation"; > + fclose( explain ); >throw rld::error( what, "Explanations::load" ); > } > inputBuffer[ strlen(inputBuffer) - 1] = '\0'; @@ -102,15 > +104,17 @@ namespace Coverage { >break; > } > // XXX only taking last line. Needs to be a vector > -e->explanation.push_back( inputBuffer ); > +e.explanation.push_back( inputBuffer ); >} > >// Add this to the set of Explanations > - set[ e->startingPoint ] = *e; > + set[ e.startingPoint ] = e; > } > done: > ; > > +fclose( explain ); > + > #undef MAX_LINE_LENGTH >} > > ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1] Explanations.cc: Convert to c++ file handling
--- tester/covoar/Explanations.cc | 45 --- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/tester/covoar/Explanations.cc b/tester/covoar/Explanations.cc index d94cd2e..1449fb2 100644 --- a/tester/covoar/Explanations.cc +++ b/tester/covoar/Explanations.cc @@ -10,6 +10,8 @@ #include #include +#include + #include #include "Explanations.h" @@ -30,15 +32,14 @@ namespace Coverage { ) { #define MAX_LINE_LENGTH 512 -FILE *explain; -char*cStatus; -Explanation e; -int line = 1; +std::ifstream explain; +Explanatione; +intline = 1; if (!explanations) return; -explain = ::fopen( explanations, "r" ); +explain.open( explanations ); if (!explain) { std::ostringstream what; what << "Unable to open " << explanations; @@ -50,9 +51,9 @@ namespace Coverage { // skip blank lines between do { inputBuffer[0] = '\0'; -cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain ); -if (cStatus == NULL) { - goto done; +explain.getline( inputBuffer, MAX_LINE_LENGTH ); +if (explain.fail()) { + return; } inputBuffer[ strlen(inputBuffer) - 1] = '\0'; line++; @@ -64,7 +65,6 @@ namespace Coverage { what << "line " << line << "contains a duplicate explanation (" << inputBuffer << ")"; -fclose( explain ); throw rld::error( what, "Explanations::load" ); } @@ -73,12 +73,11 @@ namespace Coverage { e.found = false; // Get the classification - cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain ); - if (cStatus == NULL) { + explain.getline( inputBuffer, MAX_LINE_LENGTH ); + if (explain.fail()) { std::ostringstream what; what << "line " << line << "out of sync at the classification"; -fclose( explain ); throw rld::error( what, "Explanations::load" ); } inputBuffer[ strlen(inputBuffer) - 1] = '\0'; @@ -87,13 +86,12 @@ namespace Coverage { // Get the explanation while (1) { -cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain ); +explain.getline( inputBuffer, MAX_LINE_LENGTH ); // fprintf( stderr, "%d - %s\n", line, inputBuffer ); -if (cStatus == NULL) { +if (explain.fail()) { std::ostringstream what; what << "line " << line << "out of sync at the explanation"; - fclose( explain ); throw rld::error( what, "Explanations::load" ); } inputBuffer[ strlen(inputBuffer) - 1] = '\0'; @@ -110,10 +108,6 @@ namespace Coverage { // Add this to the set of Explanations set[ e.startingPoint ] = e; } -done: -; - -fclose( explain ); #undef MAX_LINE_LENGTH } @@ -137,14 +131,14 @@ done: const char* const fileName ) { -FILE* notFoundFile; +std::ofstream notFoundFile; bool notFoundOccurred = false; if (!fileName) return; -notFoundFile = fopen( fileName, "w" ); -if (notFoundFile == nullptr) { +notFoundFile.open( fileName ); +if (!notFoundFile) { std::ostringstream what; what << "Unable to open " << fileName << " out of sync at the explanation"; @@ -159,14 +153,9 @@ done: if (!e.found) { notFoundOccurred = true; -fprintf( - notFoundFile, - "%s\n", - e.startingPoint.c_str() -); +notFoundFile << e.startingPoint << std::endl; } } -fclose( notFoundFile ); if (!notFoundOccurred) { if (!unlink( fileName )) { -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v2] legacy nfs.c: Change filesystem utime_h handler to utimens_h
Reply is below. From: Joel Sherrill Sent: Friday, May 21, 2021 9:44 AM To: Gedare Bloom Cc: Ryan Long ; vi...@rtems.rog; rtems-de...@rtems.org Subject: Re: [PATCH v2] legacy nfs.c: Change filesystem utime_h handler to utimens_h As a warning, this and the corresponding libbsd patch are queued behind an RSB patch to get UTIME_NOW and UTIME_OMIT in newlib. That patch was merged into newlib. Then the RTEMS *utime* patch set and these two will go in at the same time. Otherwise, there will be breakage. On Fri, May 21, 2021 at 9:26 AM Gedare Bloom mailto:ged...@rtems.org>> wrote: On Mon, May 3, 2021 at 12:41 PM Ryan Long mailto:ryan.l...@oarcorp.com>> wrote: > > Changed nfs_utime() to nfs_utimens(), changed the arguments to use > a timespec array instead of individual variables for access and > modified time. > > Updates #4400 > --- > nfsclient/src/nfs.c | 50 +- > 1 file changed, 25 insertions(+), 25 deletions(-) > > diff --git a/nfsclient/src/nfs.c b/nfsclient/src/nfs.c > index bc9a2c6..72fefb9 100644 > --- a/nfsclient/src/nfs.c > +++ b/nfsclient/src/nfs.c > @@ -2050,19 +2050,19 @@ static int nfs_rmnod( > return rv; > } > > -static int nfs_utime( > +static int nfs_utimens( > const rtems_filesystem_location_info_t *pathloc, /* IN */ > - time_t actime, /* IN */ > - time_t modtime /* IN */ > + struct timespec times[2] /* IN */ > + > ) > { > sattr arg; > > /* TODO: add rtems EPOCH - UNIX EPOCH seconds */ > - arg.atime.seconds = actime; > - arg.atime.useconds = 0; > - arg.mtime.seconds = modtime; > - arg.mtime.useconds = 0; > + arg.atime.seconds = times[0].tv_sec; > + arg.atime.useconds = times[0].tv_nsec / 1000; Do we have a macro exposed for this, like in TOD_NANOSECONDS_PER_MICROSECOND? If not, this is fine I suppose. This wouldn't be public since it doesn't start with RTEMS_ and I don't see any of the TOD_ constants redefined in the RTEMS namespace. > + arg.mtime.seconds = times[1].tv_sec; > + arg.mtime.useconds = times[1].tv_nsec / 1000; > > return nfs_sattr(pathloc->node_access, , SATTR_ATIME | > SATTR_MTIME); > } > @@ -2254,25 +2254,25 @@ sattr arg; > } > > const struct _rtems_filesystem_operations_table nfs_fs_ops = { > - .lock_h = nfs_lock, > - .unlock_h = nfs_unlock, > - .eval_path_h= nfs_eval_path, > - .link_h = nfs_link, > + .lock_h= nfs_lock, > + .unlock_h = nfs_unlock, > + .eval_path_h = nfs_eval_path, > + .link_h= nfs_link, > .are_nodes_equal_h = nfs_are_nodes_equal, > - .mknod_h= nfs_mknod, > - .rmnod_h= nfs_rmnod, > - .fchmod_h = nfs_fchmod, > - .chown_h= nfs_chown, > - .clonenod_h = nfs_clonenode, > - .freenod_h = nfs_freenode, > - .mount_h= rtems_filesystem_default_mount, > - .unmount_h = rtems_filesystem_default_unmount, > - .fsunmount_me_h = nfs_fsunmount_me, > - .utime_h= nfs_utime, > - .symlink_h = nfs_symlink, > - .readlink_h = nfs_readlink, > - .rename_h = nfs_rename, > - .statvfs_h = rtems_filesystem_default_statvfs > + .mknod_h = nfs_mknod, > + .rmnod_h = nfs_rmnod, > + .fchmod_h = nfs_fchmod, > + .chown_h = nfs_chown, > + .clonenod_h= nfs_clonenode, > + .freenod_h = nfs_freenode, > + .mount_h = rtems_filesystem_default_mount, > + .unmount_h = rtems_filesystem_default_unmount, > + .fsunmount_me_h= nfs_fsunmount_me, > + .utimens_h = nfs_utimens, > + .symlink_h = nfs_symlink, > + .readlink_h= nfs_readlink, > + .rename_h = nfs_rename, > + .statvfs_h = rtems_filesystem_default_statvfs Why so many additional whitespace changes? [Ryan Long] When I changed utime_h to utimens_h, it got everything out of alignment, so I moved everything over. > }; > > /* > -- > 1.8.3.1 > > ___ > devel mailing list > devel@rtems.org<mailto:devel@rtems.org> > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org<mailto:devel@rtems.org> http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v2 3/3] main_help.c: Do not care what char is returned by getchar()
You acked them, and I sent the tarball with the patches to Joel. So I think Joel just forgot to put them in. -Original Message- From: Gedare Bloom Sent: Friday, May 28, 2021 9:55 AM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH v2 3/3] main_help.c: Do not care what char is returned by getchar() Are these three still pending? If so, can you ping the other 2 or advise what is blocking? On Mon, Apr 5, 2021 at 7:28 AM Ryan Long wrote: > > CID 1437650: Unchecked return value from library in rtems_shell_help(). > > Closes #4291 > --- > cpukit/libmisc/shell/main_help.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/cpukit/libmisc/shell/main_help.c > b/cpukit/libmisc/shell/main_help.c > index 9f59e9d..564bc30 100644 > --- a/cpukit/libmisc/shell/main_help.c > +++ b/cpukit/libmisc/shell/main_help.c > @@ -148,7 +148,7 @@ static int rtems_shell_help( > line+= rtems_shell_help_cmd(shell_cmd); >if (lines && (line > lines)) { > printf("Press any key to continue..."); > -getchar(); > +(void) getchar(); > printf("\n"); > line = 0; >} > -- > 1.8.3.1 > > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH] Reports: Convert to C++
I'll get those pointers changed to references, and remove the whitespace changes. Is there a particular reason to not use '\n' instead of std::endl? I read that std::endl is slower since it's flushing the buffer each time that it is used. -Original Message- From: Chris Johns Sent: Tuesday, July 6, 2021 7:13 PM To: Ryan Long ; devel@rtems.org Subject: Re: [PATCH] Reports: Convert to C++ On 7/7/21 1:53 am, Ryan Long wrote: > Made formatting consistent and converted C code to C++. > --- > tester/covoar/ReportsBase.cc | 525 +-- > tester/covoar/ReportsBase.h | 156 +++--- > tester/covoar/ReportsHtml.cc | 1183 > +- > tester/covoar/ReportsHtml.h | 141 ++--- > tester/covoar/ReportsText.cc | 348 ++--- > tester/covoar/ReportsText.h | 75 ++- > 6 files changed, 1041 insertions(+), 1387 deletions(-) > > diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc > index 328980d..3041df2 100644 > --- a/tester/covoar/ReportsBase.cc > +++ b/tester/covoar/ReportsBase.cc > @@ -4,6 +4,9 @@ > #include > #include > > +#include > +#include > + > #include "ReportsBase.h" > #include "app_common.h" > #include "CoverageRanges.h" > @@ -20,10 +23,12 @@ > > namespace Coverage { > > -ReportsBase::ReportsBase( time_t timestamp, std::string symbolSetName ): > - reportExtension_m(""), > - symbolSetName_m(symbolSetName), > - timestamp_m( timestamp ) > +ReportsBase::ReportsBase( > + time_t timestamp, > + const std::string& symbolSetName > +): reportExtension_m( "" ), > + symbolSetName_m( symbolSetName ), > + timestamp_m( timestamp ) > { > } > > @@ -31,14 +36,14 @@ ReportsBase::~ReportsBase() > { > } > > -FILE* ReportsBase::OpenFile( > - const char* const fileName, > - const char* const symbolSetName > +std::ofstream* ReportsBase::OpenFile( A raw pointer anywhere is a possible source of a leak and with exceptions it is hard to track all possible paths. > + const std::string& fileName, > + const std::string& symbolSetName Would having ... std::ostream& aFile as a referenced arguement work? > ) > { > - int sc; > - FILE*aFile; > - std::string file; > + intsc; > + std::ofstream* aFile = new std::ofstream; Please consider std::shared_ptr<> or std::unique_ptr<> for pointers or just avoid using them which I find simpler. > + std::stringfile; > >std::string symbolSetOutputDirectory; >rld::path::path_join( > @@ -51,136 +56,110 @@ FILE* ReportsBase::OpenFile( > #ifdef _WIN32 >sc = _mkdir( symbolSetOutputDirectory ); > #else > - sc = mkdir( symbolSetOutputDirectory.c_str(),0755 ); > + sc = mkdir( symbolSetOutputDirectory.c_str(), 0755 ); > #endif > - if ( (sc == -1) && (errno != EEXIST) ) { > -fprintf( > - stderr, > - "Unable to create output directory %s\n", > - symbolSetOutputDirectory.c_str() > -); > + if ( ( sc == -1 ) && ( errno != EEXIST ) ) { > +std::cerr << "Unable to create output directory " > + << symbolSetOutputDirectory << "\n"; Please do not use "\n", please use std::endl. Why not throw an exception? > return NULL; NULL should be nullptr in C++ but if this becomes 'void' it can be removed. >} > >file = symbolSetOutputDirectory; > - rld::path::path_join(file, fileName, file); > + rld::path::path_join( file, fileName, file ); > >// Open the file. > - aFile = fopen( file.c_str(), "w" ); > - if ( !aFile ) { > -fprintf( stderr, "Unable to open %s\n", file.c_str() ); > + aFile->open( file ); > + if ( !aFile->is_open() ) { > +std::cerr << "Unable to open " << file << "\n"; >} > + >return aFile; > } > > -void ReportsBase::WriteIndex( > - const char* const fileName > -) > +void ReportsBase::WriteIndex( const std::string& fileName ) > { > } > > -FILE* ReportsBase::OpenAnnotatedFile( > - const char* const fileName > -) > +std::ofstream* ReportsBase::OpenAnnotatedFile( const std::string& fileName ) .. and here .. > { > - return OpenFile(fileName, symbolSetName_m.c_str()); > + return OpenFile( fileName, symbolSetName_m ); > } > > -FILE* ReportsBase::OpenBranchFile( > - const char* const fileName, > - bool hasBranches > +std::ofstream* ReportsBase::OpenBranchFile( ... and here ... > + const std::string& fileName, > +
RE: [PATCH v1 1/2] ReportsBase.cc: Remove possible division by zero
No good reason. I'll make those changes and send V2. -Original Message- From: Gedare Bloom Sent: Tuesday, June 29, 2021 12:13 PM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH v1 1/2] ReportsBase.cc: Remove possible division by zero On Tue, Jun 29, 2021 at 11:06 AM Ryan Long wrote: > > CID 1503709: Division or modulo by float zero > > Closes #4415 > --- > tester/covoar/ReportsBase.cc | 10 +++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/tester/covoar/ReportsBase.cc > b/tester/covoar/ReportsBase.cc index b4a755c..31dc429 100644 > --- a/tester/covoar/ReportsBase.cc > +++ b/tester/covoar/ReportsBase.cc > @@ -482,9 +482,13 @@ void ReportsBase::WriteSummaryReport( > } >} > > - percentage = (double) notExecuted; > - percentage /= (double) totalBytes; > - percentage *= 100.0; > + if (totalBytes == 0) { > +percentage = 0; > + } else { > +percentage = (double) notExecuted; > +percentage /= (double) totalBytes; > +percentage *= 100.0; ok, any good reason not to use one line? Just curious. percentage = 100.0 * (double) notExecuted / totalBytes; > + } > >percentageBranches = (double) ( > SymbolsToAnalyze->getNumberBranchesAlwaysTaken(symbolSetName) + > -- > 1.8.3.1 > > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 1/2] ReportsBase.cc: Remove possible division by zero
CID 1503709: Division or modulo by float zero Closes #4415 --- tester/covoar/ReportsBase.cc | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index b4a755c..31dc429 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -482,9 +482,13 @@ void ReportsBase::WriteSummaryReport( } } - percentage = (double) notExecuted; - percentage /= (double) totalBytes; - percentage *= 100.0; + if (totalBytes == 0) { +percentage = 0; + } else { +percentage = (double) notExecuted; +percentage /= (double) totalBytes; +percentage *= 100.0; + } percentageBranches = (double) ( SymbolsToAnalyze->getNumberBranchesAlwaysTaken(symbolSetName) + -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 2/2] rtems-exeinfo.cpp: Fix division by zero errors
CID 1503008: Division or modulo by zero CID 1503015: Division or modulo by zero Closes #4416 --- linkers/rtems-exeinfo.cpp| 20 tester/covoar/ReportsBase.cc | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp index 1e6d4b4..ec51597 100644 --- a/linkers/rtems-exeinfo.cpp +++ b/linkers/rtems-exeinfo.cpp @@ -755,6 +755,8 @@ namespace rld size_t total = 0; size_t total_size = 0; size_t inlined_size = 0; + double percentage; + double percentage_size; dwarf::functions funcs_inlined; dwarf::functions funcs_not_inlined; func_counts counts; @@ -798,14 +800,24 @@ namespace rld } } + if ( total == 0 ) { +percentage = 0; + } else { +percentage = ( funcs_inlined.size() * 100 ) / total; + } + + if ( total_size == 0 ) { +percentage_size = 0; + } else { +percentage_size = ( inlined_size * 100 ) / total_size; + } + std::cout << "inlined funcs : " << funcs_inlined.size () << std::endl << "total funcs : " << total << std::endl -<< " % inline funcs : " << (funcs_inlined.size () * 100) / total << '%' -<< std::endl +<< " % inline funcs : " << percentage << '%' << std::endl << " total size : " << total_size << std::endl << "inline size : " << inlined_size << std::endl -<< " % inline size : " << (inlined_size * 100) / total_size << '%' -<< std::endl; +<< " % inline size : " << percentage_size << '%' << std::endl; auto count_compare = [](func_count const & a, func_count const & b) { return a.size != b.size? a.size < b.size : a.count > b.count; diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index 31dc429..b54f550 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -482,7 +482,7 @@ void ReportsBase::WriteSummaryReport( } } - if (totalBytes == 0) { + if ( totalBytes == 0 ) { percentage = 0; } else { percentage = (double) notExecuted; -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 2/2] rtems-exeinfo.cpp: Fix division by zero errors
CID 1503008: Division or modulo by zero CID 1503015: Division or modulo by zero Closes #4416 --- linkers/rtems-exeinfo.cpp | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp index 1e6d4b4..ec51597 100644 --- a/linkers/rtems-exeinfo.cpp +++ b/linkers/rtems-exeinfo.cpp @@ -755,6 +755,8 @@ namespace rld size_t total = 0; size_t total_size = 0; size_t inlined_size = 0; + double percentage; + double percentage_size; dwarf::functions funcs_inlined; dwarf::functions funcs_not_inlined; func_counts counts; @@ -798,14 +800,24 @@ namespace rld } } + if ( total == 0 ) { +percentage = 0; + } else { +percentage = ( funcs_inlined.size() * 100 ) / total; + } + + if ( total_size == 0 ) { +percentage_size = 0; + } else { +percentage_size = ( inlined_size * 100 ) / total_size; + } + std::cout << "inlined funcs : " << funcs_inlined.size () << std::endl << "total funcs : " << total << std::endl -<< " % inline funcs : " << (funcs_inlined.size () * 100) / total << '%' -<< std::endl +<< " % inline funcs : " << percentage << '%' << std::endl << " total size : " << total_size << std::endl << "inline size : " << inlined_size << std::endl -<< " % inline size : " << (inlined_size * 100) / total_size << '%' -<< std::endl; +<< " % inline size : " << percentage_size << '%' << std::endl; auto count_compare = [](func_count const & a, func_count const & b) { return a.size != b.size? a.size < b.size : a.count > b.count; -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 1/2] ReportsBase.cc: Remove possible division by zero
CID 1503709: Division or modulo by float zero Closes #4415 --- tester/covoar/ReportsBase.cc | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index b4a755c..328980d 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -482,9 +482,11 @@ void ReportsBase::WriteSummaryReport( } } - percentage = (double) notExecuted; - percentage /= (double) totalBytes; - percentage *= 100.0; + if ( totalBytes == 0 ) { +percentage = 0; + } else { +percentage = 100.0 * (double) notExecuted / totalBytes; + } percentageBranches = (double) ( SymbolsToAnalyze->getNumberBranchesAlwaysTaken(symbolSetName) + -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v3 2/2] rtems-exeinfo.cpp: Fix division by zero errors
CID 1503008: Division or modulo by zero CID 1503015: Division or modulo by zero Closes #4416 --- linkers/rtems-exeinfo.cpp | 20 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp index 1e6d4b4..6e92206 100644 --- a/linkers/rtems-exeinfo.cpp +++ b/linkers/rtems-exeinfo.cpp @@ -755,6 +755,8 @@ namespace rld size_t total = 0; size_t total_size = 0; size_t inlined_size = 0; + double percentage; + double percentage_size; dwarf::functions funcs_inlined; dwarf::functions funcs_not_inlined; func_counts counts; @@ -798,14 +800,24 @@ namespace rld } } + if ( total == 0 ) { +percentage = 0; + } else { +percentage = (double) ( funcs_inlined.size() * 100 ) / total; + } + + if ( total_size == 0 ) { +percentage_size = 0; + } else { +percentage_size = (double) ( inlined_size * 100 ) / total_size; + } + std::cout << "inlined funcs : " << funcs_inlined.size () << std::endl << "total funcs : " << total << std::endl -<< " % inline funcs : " << (funcs_inlined.size () * 100) / total << '%' -<< std::endl +<< " % inline funcs : " << percentage << '%' << std::endl << " total size : " << total_size << std::endl << "inline size : " << inlined_size << std::endl -<< " % inline size : " << (inlined_size * 100) / total_size << '%' -<< std::endl; +<< " % inline size : " << percentage_size << '%' << std::endl; auto count_compare = [](func_count const & a, func_count const & b) { return a.size != b.size? a.size < b.size : a.count > b.count; -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v3 1/2] ReportsBase.cc: Remove possible division by zero
CID 1503709: Division or modulo by float zero Closes #4415 --- tester/covoar/ReportsBase.cc | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index b4a755c..328980d 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -482,9 +482,11 @@ void ReportsBase::WriteSummaryReport( } } - percentage = (double) notExecuted; - percentage /= (double) totalBytes; - percentage *= 100.0; + if ( totalBytes == 0 ) { +percentage = 0; + } else { +percentage = 100.0 * (double) notExecuted / totalBytes; + } percentageBranches = (double) ( SymbolsToAnalyze->getNumberBranchesAlwaysTaken(symbolSetName) + -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v2 2/2] rtems-exeinfo.cpp: Fix division by zero errors
I'll cast those. Sorry I missed that. -Original Message- From: Gedare Bloom Sent: Tuesday, June 29, 2021 2:03 PM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH v2 2/2] rtems-exeinfo.cpp: Fix division by zero errors On Tue, Jun 29, 2021 at 11:50 AM Ryan Long wrote: > > CID 1503008: Division or modulo by zero CID 1503015: Division or > modulo by zero > > Closes #4416 > --- > linkers/rtems-exeinfo.cpp | 20 > 1 file changed, 16 insertions(+), 4 deletions(-) > > diff --git a/linkers/rtems-exeinfo.cpp b/linkers/rtems-exeinfo.cpp > index 1e6d4b4..ec51597 100644 > --- a/linkers/rtems-exeinfo.cpp > +++ b/linkers/rtems-exeinfo.cpp > @@ -755,6 +755,8 @@ namespace rld >size_t total = 0; >size_t total_size = 0; >size_t inlined_size = 0; > + double percentage; > + double percentage_size; >dwarf::functions funcs_inlined; >dwarf::functions funcs_not_inlined; >func_counts counts; > @@ -798,14 +800,24 @@ namespace rld > } >} > > + if ( total == 0 ) { > +percentage = 0; > + } else { > +percentage = ( funcs_inlined.size() * 100 ) / total; > + } > + > + if ( total_size == 0 ) { > +percentage_size = 0; > + } else { > +percentage_size = ( inlined_size * 100 ) / total_size; These are still integer results. If you want double, you should cast, if you want integer, you should use int type for the percentage and percentage_size variables. > + } > + >std::cout << "inlined funcs : " << funcs_inlined.size () << std::endl > << "total funcs : " << total << std::endl > -<< " % inline funcs : " << (funcs_inlined.size () * 100) / > total << '%' > -<< std::endl > +<< " % inline funcs : " << percentage << '%' << > + std::endl > << " total size : " << total_size << std::endl > << "inline size : " << inlined_size << std::endl > -<< " % inline size : " << (inlined_size * 100) / total_size > << '%' > -<< std::endl; > +<< " % inline size : " << percentage_size << '%' << > + std::endl; > >auto count_compare = [](func_count const & a, func_count const & b) { > return a.size != b.size? a.size < b.size : a.count > > b.count; > -- > 1.8.3.1 > > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1] Reports: Convert to C++
--- tester/covoar/ReportsBase.cc | 296 ++-- tester/covoar/ReportsBase.h | 118 +++-- tester/covoar/ReportsHtml.cc | 1074 +- tester/covoar/ReportsHtml.h | 94 ++-- tester/covoar/ReportsText.cc | 261 +- tester/covoar/ReportsText.h | 34 +- 6 files changed, 838 insertions(+), 1039 deletions(-) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index 328980d..7fd3422 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -4,6 +4,9 @@ #include #include +#include +#include + #include "ReportsBase.h" #include "app_common.h" #include "CoverageRanges.h" @@ -20,7 +23,7 @@ namespace Coverage { -ReportsBase::ReportsBase( time_t timestamp, std::string symbolSetName ): +ReportsBase::ReportsBase( time_t timestamp, const std::string& symbolSetName ): reportExtension_m(""), symbolSetName_m(symbolSetName), timestamp_m( timestamp ) @@ -31,13 +34,13 @@ ReportsBase::~ReportsBase() { } -FILE* ReportsBase::OpenFile( - const char* const fileName, - const char* const symbolSetName +void ReportsBase::OpenFile( + const std::string& fileName, + const std::string& symbolSetName, + std::ofstream& aFile ) { int sc; - FILE*aFile; std::string file; std::string symbolSetOutputDirectory; @@ -54,120 +57,131 @@ FILE* ReportsBase::OpenFile( sc = mkdir( symbolSetOutputDirectory.c_str(),0755 ); #endif if ( (sc == -1) && (errno != EEXIST) ) { -fprintf( - stderr, - "Unable to create output directory %s\n", - symbolSetOutputDirectory.c_str() +throw rld::error( + "Unable to create output directory", + "ReportsBase::OpenFile" ); -return NULL; +return; } file = symbolSetOutputDirectory; rld::path::path_join(file, fileName, file); // Open the file. - aFile = fopen( file.c_str(), "w" ); - if ( !aFile ) { -fprintf( stderr, "Unable to open %s\n", file.c_str() ); + aFile.open( file ); + if ( !aFile.is_open() ) { +std::cerr << "Unable to open " << file << std::endl; } - return aFile; + return; } void ReportsBase::WriteIndex( - const char* const fileName + const std::string& fileName ) { } -FILE* ReportsBase::OpenAnnotatedFile( - const char* const fileName +void ReportsBase::OpenAnnotatedFile( + const std::string& fileName, + std::ofstream& aFile ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + OpenFile(fileName, symbolSetName_m, aFile); + return; } -FILE* ReportsBase::OpenBranchFile( - const char* const fileName, - bool hasBranches +void ReportsBase::OpenBranchFile( + const std::string& fileName, + bool hasBranches, + std::ofstream& aFile ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + OpenFile(fileName, symbolSetName_m, aFile); + return; } -FILE* ReportsBase::OpenCoverageFile( - const char* const fileName +void ReportsBase::OpenCoverageFile( + const std::string& fileName, + std::ofstream& aFile ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + OpenFile(fileName, symbolSetName_m, aFile); + return; } -FILE* ReportsBase::OpenNoRangeFile( - const char* const fileName +void ReportsBase::OpenNoRangeFile( + const std::string& fileName, + std::ofstream& aFile ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + OpenFile(fileName, symbolSetName_m, aFile); + return; } -FILE* ReportsBase::OpenSizeFile( - const char* const fileName +void ReportsBase::OpenSizeFile( + const std::string& fileName, + std::ofstream& aFile ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + OpenFile(fileName, symbolSetName_m, aFile); + return; } -FILE* ReportsBase::OpenSymbolSummaryFile( - const char* const fileName +void ReportsBase::OpenSymbolSummaryFile( + const std::string& fileName, + std::ofstream& aFile ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + OpenFile(fileName, symbolSetName_m, aFile); + return; } void ReportsBase::CloseFile( - FILE* aFile + std::ofstream& aFile ) { - fclose( aFile ); + aFile.close(); } void ReportsBase::CloseAnnotatedFile( - FILE* aFile + std::ofstream& aFile ) { CloseFile( aFile ); } void ReportsBase::CloseBranchFile( - FILE* aFile, - bool hasBranches + std::ofstream& aFile, + bool hasBranches ) { CloseFile( aFile ); } void ReportsBase::CloseCoverageFile( - FILE* aFile + std::ofstream& aFile ) { CloseFile( aFile ); } void ReportsBase::CloseNoRangeFile( - FILE* aFile + std::ofstream& aFile ) { CloseFile( aFile ); } void ReportsBase::CloseSizeFile( - FILE* aFile + std::ofstream& aFile ) { CloseFile( aFile ); } void ReportsBase::CloseSymbolSummaryFile( - FILE* aFile + std::ofstream& aFile ) { CloseFile( aFile ); @@ -195,18 +209,23 @@ std::string expand_tabs(const std::string& in) { * Write annotated
[PATCH] Reports: Convert to C++
Made formatting consistent and converted C code to C++. --- tester/covoar/ReportsBase.cc | 525 +-- tester/covoar/ReportsBase.h | 156 +++--- tester/covoar/ReportsHtml.cc | 1183 +- tester/covoar/ReportsHtml.h | 141 ++--- tester/covoar/ReportsText.cc | 348 ++--- tester/covoar/ReportsText.h | 75 ++- 6 files changed, 1041 insertions(+), 1387 deletions(-) diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index 328980d..3041df2 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -4,6 +4,9 @@ #include #include +#include +#include + #include "ReportsBase.h" #include "app_common.h" #include "CoverageRanges.h" @@ -20,10 +23,12 @@ namespace Coverage { -ReportsBase::ReportsBase( time_t timestamp, std::string symbolSetName ): - reportExtension_m(""), - symbolSetName_m(symbolSetName), - timestamp_m( timestamp ) +ReportsBase::ReportsBase( + time_t timestamp, + const std::string& symbolSetName +): reportExtension_m( "" ), + symbolSetName_m( symbolSetName ), + timestamp_m( timestamp ) { } @@ -31,14 +36,14 @@ ReportsBase::~ReportsBase() { } -FILE* ReportsBase::OpenFile( - const char* const fileName, - const char* const symbolSetName +std::ofstream* ReportsBase::OpenFile( + const std::string& fileName, + const std::string& symbolSetName ) { - int sc; - FILE*aFile; - std::string file; + intsc; + std::ofstream* aFile = new std::ofstream; + std::stringfile; std::string symbolSetOutputDirectory; rld::path::path_join( @@ -51,136 +56,110 @@ FILE* ReportsBase::OpenFile( #ifdef _WIN32 sc = _mkdir( symbolSetOutputDirectory ); #else - sc = mkdir( symbolSetOutputDirectory.c_str(),0755 ); + sc = mkdir( symbolSetOutputDirectory.c_str(), 0755 ); #endif - if ( (sc == -1) && (errno != EEXIST) ) { -fprintf( - stderr, - "Unable to create output directory %s\n", - symbolSetOutputDirectory.c_str() -); + if ( ( sc == -1 ) && ( errno != EEXIST ) ) { +std::cerr << "Unable to create output directory " + << symbolSetOutputDirectory << "\n"; return NULL; } file = symbolSetOutputDirectory; - rld::path::path_join(file, fileName, file); + rld::path::path_join( file, fileName, file ); // Open the file. - aFile = fopen( file.c_str(), "w" ); - if ( !aFile ) { -fprintf( stderr, "Unable to open %s\n", file.c_str() ); + aFile->open( file ); + if ( !aFile->is_open() ) { +std::cerr << "Unable to open " << file << "\n"; } + return aFile; } -void ReportsBase::WriteIndex( - const char* const fileName -) +void ReportsBase::WriteIndex( const std::string& fileName ) { } -FILE* ReportsBase::OpenAnnotatedFile( - const char* const fileName -) +std::ofstream* ReportsBase::OpenAnnotatedFile( const std::string& fileName ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + return OpenFile( fileName, symbolSetName_m ); } -FILE* ReportsBase::OpenBranchFile( - const char* const fileName, - bool hasBranches +std::ofstream* ReportsBase::OpenBranchFile( + const std::string& fileName, + bool hasBranches ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + return OpenFile( fileName, symbolSetName_m ); } -FILE* ReportsBase::OpenCoverageFile( - const char* const fileName -) +std::ofstream* ReportsBase::OpenCoverageFile( const std::string& fileName ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + return OpenFile( fileName, symbolSetName_m ); } -FILE* ReportsBase::OpenNoRangeFile( - const char* const fileName -) +std::ofstream* ReportsBase::OpenNoRangeFile( const std::string& fileName ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + return OpenFile( fileName, symbolSetName_m ); } -FILE* ReportsBase::OpenSizeFile( - const char* const fileName -) +std::ofstream* ReportsBase::OpenSizeFile( const std::string& fileName ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + return OpenFile( fileName, symbolSetName_m ); } -FILE* ReportsBase::OpenSymbolSummaryFile( - const char* const fileName +std::ofstream* ReportsBase::OpenSymbolSummaryFile( + const std::string& fileName ) { - return OpenFile(fileName, symbolSetName_m.c_str()); + return OpenFile( fileName, symbolSetName_m ); } -void ReportsBase::CloseFile( - FILE* aFile -) +void ReportsBase::CloseFile( std::ofstream* aFile ) { - fclose( aFile ); + aFile->close(); } -void ReportsBase::CloseAnnotatedFile( - FILE* aFile -) +void ReportsBase::CloseAnnotatedFile( std::ofstream* aFile ) { CloseFile( aFile ); } -void ReportsBase::CloseBranchFile( - FILE* aFile, - bool hasBranches -) +void ReportsBase::CloseBranchFile( std::ofstream* aFile, bool hasBranches ) { CloseFile( aFile ); } -void ReportsBase::CloseCoverageFile( - FILE* aFile -) +void ReportsBase::CloseCoverageFile(
[PATCH] rtems-bsp-builder: Change to waf build system
Closes #4124 --- config/rtems-bsps.ini | 28 ++-- tester/rt/check.py| 35 ++- 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/config/rtems-bsps.ini b/config/rtems-bsps.ini index 93156fb..d5de667 100644 --- a/config/rtems-bsps.ini +++ b/config/rtems-bsps.ini @@ -156,23 +156,23 @@ smp-network-debug = config:base, config:smp, config:network, config:debug # # Base set of configure options every build needs. # -base = --target=@ARCH@-rtems@RTEMS_VERSION@ - --enable-rtemsbsp=@BSP@ - --prefix=@PREFIX@ +base = --prefix=@PREFIX@ + --top=@RTEMS@ + --rtems-config=config-@ARCH@-@BSP@-@BUILD@.ini # # Tests. # -tests = --enable-tests +tests = BUILD_TESTS=True # # The options for each varations. # -debug = --enable-rtems-debug -no-debug = --disable-rtems-debug -profiling = --enable-profiling -no-profiling = --disable-profiling -smp = --enable-smp -no-smp= --disable-smp -posix = --enable-posix -no-posix = --disable-posix -network = --enable-networking -no-network= --disable-networking +debug = RTEMS_DEBUG=True +no-debug = RTEMS_DEBUG=False +profiling = RTEMS_PROFILING=True +no-profiling = RTEMS_PROFILING=False +smp = RTEMS_SMP=True +no-smp= RTEMS_SMP=False +posix = RTEMS_POSIX_API=True +no-posix = RTEMS_POSIX_API=False +network = RTEMS_NETWORKING=True +no-network= RTEMS_NETWORKING=False diff --git a/tester/rt/check.py b/tester/rt/check.py index 2a38d99..95fa47e 100755 --- a/tester/rt/check.py +++ b/tester/rt/check.py @@ -906,7 +906,9 @@ class build_jobs: remove += [b for b in self.builds if e in b.split('-')] self.builds = [b for b in self.builds if b not in remove] self.build_set = { } -exclude_options = ' ' + config.exclude_options(self.arch, self.bsp) +exclude_options = config.exclude_options(self.arch, self.bsp) +if exclude_options != '': +exclude_options = ' ' + exclude_options for build in self.builds: self.build_set[build] = config.build_options(build) + exclude_options @@ -938,9 +940,7 @@ class builder: 'BSP' : '.*libbsp/.*', 'LibCPU' : '.*libcpu/.*', 'Shared' : '.*shared/.*' }) -if not path.exists(path.join(rtems, 'configure')) or \ - not path.exists(path.join(rtems, 'Makefile.in')) or \ - not path.exists(path.join(rtems, 'cpukit')): +if not path.exists(path.join(rtems, 'waf')): raise error.general('RTEMS source path does not look like RTEMS') def _bsps(self, arch): @@ -952,15 +952,30 @@ class builder: job_index = 1 for job in jobs: tag = '%*d/%d' % (max_job_size, job_index, len(jobs)) +commands = self._commands(job, build_job_count) +self._create_config(job, commands) build_jobs += [arch_bsp_builder(self.results, job, -self._commands(job, build_job_count), +commands, self.build_dir, tag)] job_index += 1 set_max_build_label(build_jobs) return build_jobs +def _create_config(self, job, commands): +filename = 'config-%s-%s-%s.ini' % (job.arch, job.bsp, job.build) +cfg_file = open(path.join(self.rtems, filename),'w+') +cfg_file.write('[%s/%s]' + os.linsep() % (job.arch, job.bsp)) +new_cfg_cmds = [] +for option in commands['configure'].split(): +if 'waf' in option or '--' in option or 'configure' in option: +new_cfg_cmds += [option] +else: +cfg_file.write(option + os.linesep()) +commands['configure'] = ' '.join(new_cfg_cmds) +cfg_file.close() + def _commands(self, build, build_jobs): commands = { 'dry-run' : self.options['dry-run'], 'no-clean' : self.options['no-clean'], @@ -968,16 +983,18 @@ class builder: 'build': None } cmds = build.build_config.split() cmds += self.config.bspopts(build.arch, build.bsp) -cmd = [path.join(self.rtems, 'configure')] +cmd = [path.join(self.rtems, 'waf') + ' configure'] for c in cmds: c = c.replace('@PREFIX@', self.prefix) -c = c.replace('@RTEMS_VERSION@', str(self.rtems_version)) c = c.replace('@ARCH@', build.arch) c = c.replace('@BSP@', build.bsp) +c = c.replace('@RTEMS@', self.rtems) +c = c.replace('@BUILD@',
[PATCH v4] psx13: Reworked and relicensed
Changed the way the tests were structured, added rtems_test_assert()'s, updated psx13.scn and the license. Update #3899 --- testsuites/psxtests/psx13/main.c| 37 +- testsuites/psxtests/psx13/psx13.scn | 21 +- testsuites/psxtests/psx13/test.c| 852 3 files changed, 328 insertions(+), 582 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index 20788b3..f9e7907 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,14 +1,37 @@ -/* - * Simple test program -- simplified version of sample test hello. +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). + * @brief Simple test program -- simplified version of sample test hello. * - * 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. */ +/* + * COPYRIGHT (c) 1989-2009, 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" diff --git a/testsuites/psxtests/psx13/psx13.scn b/testsuites/psxtests/psx13/psx13.scn index 428a931..efa79c9 100644 --- a/testsuites/psxtests/psx13/psx13.scn +++ b/testsuites/psxtests/psx13/psx13.scn @@ -1,16 +1,7 @@ -*** POSIX TEST 13 *** +*** BEGIN OF TEST PSX 13 *** +*** TEST VERSION: 6.0.0.75f80242186af2dde0c5bc7272a119e3b78d7ba0 +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API +*** TEST TOOLS: 10.2.1 20210309 (RTEMS 6, RSB 5e449fb5c2cb6812a238f9f9764fd339cbbf05c2, Newlib d10d0d9) -Files initialized successfully. -Testing device_lseek()... Failed!!! -Testing dup() Failed!!! -Testing dup2()... Success. -Testing fdatasync().. Success. -Testing umask().. Success. -Testing utime().. Success. -Testing utimes().. Success. -Testing fsync().. Success. -Testing pathconf()... Success. -Testing fpathconf().. Success. -Testing sync().. - -*** END OF TEST PSX13 *** +*** END OF TEST PSX 13 *** diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index 79b24c2..a82242b 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,26 +1,49 @@ -/* - * Psx13 - * Chris Bond (working under Jennifer's account) +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * This test exercises the following routines: + * @brief This tests various file system functions. * - * device_lseek - test implemented - * dup - test implemented - * dup2 - test implemented - * fdatasync- test implemented - * fsync- test implemented - * pathconf - test implemented - * fpathconf- test implemented - * umask- test implemented - * utime- test implemented - * utimes - test implemented + * This test exercises the following routines: * - * COPYRIGHT (c) 1989-2009. + * - lseek() + * - dup() + * - dup2() + * - fdatasync() + * - fsync() + * - pathconf() + * - fpathconf() + * - umask() + * - utime() + * - utimes() + * - sync() + */ + +/* + * 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
[PATCH v3] psx13: Reworked and relicensed
Changed the way the tests were structured, added rtems_test_assert()'s, updated psx13.scn and the license. --- testsuites/psxtests/psx13/main.c| 37 +- testsuites/psxtests/psx13/psx13.scn | 21 +- testsuites/psxtests/psx13/test.c| 852 3 files changed, 328 insertions(+), 582 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index 20788b3..f9e7907 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,14 +1,37 @@ -/* - * Simple test program -- simplified version of sample test hello. +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). + * @brief Simple test program -- simplified version of sample test hello. * - * 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. */ +/* + * COPYRIGHT (c) 1989-2009, 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" diff --git a/testsuites/psxtests/psx13/psx13.scn b/testsuites/psxtests/psx13/psx13.scn index 428a931..efa79c9 100644 --- a/testsuites/psxtests/psx13/psx13.scn +++ b/testsuites/psxtests/psx13/psx13.scn @@ -1,16 +1,7 @@ -*** POSIX TEST 13 *** +*** BEGIN OF TEST PSX 13 *** +*** TEST VERSION: 6.0.0.75f80242186af2dde0c5bc7272a119e3b78d7ba0 +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API +*** TEST TOOLS: 10.2.1 20210309 (RTEMS 6, RSB 5e449fb5c2cb6812a238f9f9764fd339cbbf05c2, Newlib d10d0d9) -Files initialized successfully. -Testing device_lseek()... Failed!!! -Testing dup() Failed!!! -Testing dup2()... Success. -Testing fdatasync().. Success. -Testing umask().. Success. -Testing utime().. Success. -Testing utimes().. Success. -Testing fsync().. Success. -Testing pathconf()... Success. -Testing fpathconf().. Success. -Testing sync().. - -*** END OF TEST PSX13 *** +*** END OF TEST PSX 13 *** diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index 79b24c2..a82242b 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,26 +1,49 @@ -/* - * Psx13 - * Chris Bond (working under Jennifer's account) +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * This test exercises the following routines: + * @brief This tests various file system functions. * - * device_lseek - test implemented - * dup - test implemented - * dup2 - test implemented - * fdatasync- test implemented - * fsync- test implemented - * pathconf - test implemented - * fpathconf- test implemented - * umask- test implemented - * utime- test implemented - * utimes - test implemented + * This test exercises the following routines: * - * COPYRIGHT (c) 1989-2009. + * - lseek() + * - dup() + * - dup2() + * - fdatasync() + * - fsync() + * - pathconf() + * - fpathconf() + * - umask() + * - utime() + * - utimes() + * - sync() + */ + +/* + * 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
RE: [PATCH v3] psx13: Reworked and relicensed
Didn't realize I screwed up my rebase. I thought the "Update #3899" had been added. Sending again. -Original Message----- From: Ryan Long Sent: Monday, April 26, 2021 10:00 AM To: devel@rtems.org Cc: Ryan Long Subject: [PATCH v3] psx13: Reworked and relicensed Changed the way the tests were structured, added rtems_test_assert()'s, updated psx13.scn and the license. --- testsuites/psxtests/psx13/main.c| 37 +- testsuites/psxtests/psx13/psx13.scn | 21 +- testsuites/psxtests/psx13/test.c| 852 3 files changed, 328 insertions(+), 582 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index 20788b3..f9e7907 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,14 +1,37 @@ -/* - * Simple test program -- simplified version of sample test hello. +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). + * @brief Simple test program -- simplified version of sample test hello. * - * 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. */ +/* + * COPYRIGHT (c) 1989-2009, 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" diff --git a/testsuites/psxtests/psx13/psx13.scn b/testsuites/psxtests/psx13/psx13.scn index 428a931..efa79c9 100644 --- a/testsuites/psxtests/psx13/psx13.scn +++ b/testsuites/psxtests/psx13/psx13.scn @@ -1,16 +1,7 @@ -*** POSIX TEST 13 *** +*** BEGIN OF TEST PSX 13 *** +*** TEST VERSION: 6.0.0.75f80242186af2dde0c5bc7272a119e3b78d7ba0 +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API +*** TEST TOOLS: 10.2.1 20210309 (RTEMS 6, RSB +5e449fb5c2cb6812a238f9f9764fd339cbbf05c2, Newlib d10d0d9) -Files initialized successfully. -Testing device_lseek()... Failed!!! -Testing dup() Failed!!! -Testing dup2()... Success. -Testing fdatasync().. Success. -Testing umask().. Success. -Testing utime().. Success. -Testing utimes().. Success. -Testing fsync().. Success. -Testing pathconf()... Success. -Testing fpathconf().. Success. -Testing sync().. - -*** END OF TEST PSX13 *** +*** END OF TEST PSX 13 *** diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index 79b24c2..a82242b 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,26 +1,49 @@ -/* - * Psx13 - * Chris Bond (working under Jennifer's account) +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * This test exercises the following routines: + * @brief This tests various file system functions. * - * device_lseek - test implemented - * dup - test implemented - * dup2 - test implemented - * fdatasync- test implemented - * fsync- test implemented - * pathconf - test implemented - * fpathconf- test implemented - * umask- test implemented - * utime- test implemented - * utimes - test implemented + * This test exercises the following routines: * - * COPYRIGHT (c) 1989-2009. + * - lseek() + * - dup() + * - dup2() + * - fdatasync() + * - fsync() + * - pathconf() + * - fpathconf() + * - umask() + * - utime() + * - utimes() + * - sync() + */ + +/* + * COPYRIGHT (c) 1989-2009, 2021. *
[PATCH] psx13: Reworked and relicensed
Changed the way the tests were structured, added rtems_test_assert()'s, updated psx13.scn and the license. --- testsuites/psxtests/psx13/psx13.scn | 24 +- testsuites/psxtests/psx13/test.c| 879 +--- 2 files changed, 335 insertions(+), 568 deletions(-) diff --git a/testsuites/psxtests/psx13/psx13.scn b/testsuites/psxtests/psx13/psx13.scn index 428a931..ee99867 100644 --- a/testsuites/psxtests/psx13/psx13.scn +++ b/testsuites/psxtests/psx13/psx13.scn @@ -1,16 +1,16 @@ *** POSIX TEST 13 *** Files initialized successfully. -Testing device_lseek()... Failed!!! -Testing dup() Failed!!! -Testing dup2()... Success. -Testing fdatasync().. Success. -Testing umask().. Success. -Testing utime().. Success. -Testing utimes().. Success. -Testing fsync().. Success. -Testing pathconf()... Success. -Testing fpathconf().. Success. -Testing sync().. +Testing lseek() on device... Success. +Testing dup()... Success. +Testing dup2().. Success. +Testing fdatasync(). Success. +Testing umask(). Success. +Testing utime(). Success. +Testing utimes() Success. +Testing fsync(). Success. +Testing pathconf().. Success. +Testing fpathconf(). Success. +Testing sync().. Success. -*** END OF TEST PSX13 *** +*** END OF TEST PSX 13 *** diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index 79b24c2..2d25b02 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,26 +1,49 @@ -/* - * Psx13 - * Chris Bond (working under Jennifer's account) +/** + * @file + * + * @brief This tests various file system functions. * * This test exercises the following routines: * - * device_lseek - test implemented - * dup - test implemented - * dup2 - test implemented - * fdatasync- test implemented - * fsync- test implemented - * pathconf - test implemented - * fpathconf- test implemented - * umask- test implemented - * utime- test implemented - * utimes - test implemented + * - lseek() + * - dup() + * - dup2() + * - fdatasync() + * - fsync() + * - pathconf() + * - fpathconf() + * - umask() + * - utime() + * - utimes() + * - sync() + */ + +/* + * SPDX-License-Identifier: BSD-2-Clause * - * COPYRIGHT (c) 1989-2009. + * 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 @@ -34,6 +57,7 @@ #include #include #include +#include #include #include @@ -42,685 +66,428 @@ const char rtems_test_name[] = "PSX 13"; -int InitFiles(void); -int DeviceLSeekTest(void); -int DupTest(void); -int Dup2Test(void); -int FDataSyncTest(void); -int UMaskTest(void); -int UTimeTest(void); -int UTimesTest(void); -int PathConfTest(void); -int FPathConfTest(void); -int FSyncTest(void); - -/*--- - * InitFiles function - * - * Initializes the three files to be used in the test. - * - * arguments: none - * assumptions: fopen, fprintf, fwrite, FILE are available - * actions: creates testfile1, a text file with 'a'..'z' listed 4 times. - * creates testfile2, a text file with 'a'..'z' listed 4 times. - * creates testfile3, a binary file with
RE: [PATCH] psx13: Reworked and relicensed
What other file? From: Joel Sherrill Sent: Thursday, April 22, 2021 9:21 AM To: Sebastian Huber Cc: Gedare Bloom ; Ryan Long ; rtems-de...@rtems.org Subject: Re: [PATCH] psx13: Reworked and relicensed While you are updating the license on the OAR authored code, you should pick up the other file in this directory. On Thu, Apr 22, 2021, 9:09 AM Sebastian Huber mailto:sebastian.hu...@embedded-brains.de>> wrote: On 22/04/2021 15:44, Gedare Bloom wrote: >> + rv = close( fd1 ); >> + rtems_test_assert( rv == 0 ); >> > Just curious, why be inconsistent how you check for the return from > close? Above using != EOF, here using == 0. It doesn't matter greatly. Different APIs are tested. One uses 0, the other uses EOF. -- embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de<mailto: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<mailto:devel@rtems.org> http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v2] psx13: Reworked and relicensed
Forgot to put the #Updates statement in the commit message. Will resend as V3. -Original Message- From: Ryan Long Sent: Thursday, April 22, 2021 2:34 PM To: devel@rtems.org Cc: Ryan Long Subject: [PATCH v2] psx13: Reworked and relicensed Changed the way the tests were structured, added rtems_test_assert()'s, updated psx13.scn and the license. --- testsuites/psxtests/psx13/main.c| 37 +- testsuites/psxtests/psx13/psx13.scn | 21 +- testsuites/psxtests/psx13/test.c| 852 3 files changed, 328 insertions(+), 582 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index 20788b3..f9e7907 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,14 +1,37 @@ -/* - * Simple test program -- simplified version of sample test hello. +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). + * @brief Simple test program -- simplified version of sample test hello. * - * 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. */ +/* + * COPYRIGHT (c) 1989-2009, 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" diff --git a/testsuites/psxtests/psx13/psx13.scn b/testsuites/psxtests/psx13/psx13.scn index 428a931..efa79c9 100644 --- a/testsuites/psxtests/psx13/psx13.scn +++ b/testsuites/psxtests/psx13/psx13.scn @@ -1,16 +1,7 @@ -*** POSIX TEST 13 *** +*** BEGIN OF TEST PSX 13 *** +*** TEST VERSION: 6.0.0.75f80242186af2dde0c5bc7272a119e3b78d7ba0 +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API +*** TEST TOOLS: 10.2.1 20210309 (RTEMS 6, RSB +5e449fb5c2cb6812a238f9f9764fd339cbbf05c2, Newlib d10d0d9) -Files initialized successfully. -Testing device_lseek()... Failed!!! -Testing dup() Failed!!! -Testing dup2()... Success. -Testing fdatasync().. Success. -Testing umask().. Success. -Testing utime().. Success. -Testing utimes().. Success. -Testing fsync().. Success. -Testing pathconf()... Success. -Testing fpathconf().. Success. -Testing sync().. - -*** END OF TEST PSX13 *** +*** END OF TEST PSX 13 *** diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index 79b24c2..a82242b 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,26 +1,49 @@ -/* - * Psx13 - * Chris Bond (working under Jennifer's account) +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * This test exercises the following routines: + * @brief This tests various file system functions. * - * device_lseek - test implemented - * dup - test implemented - * dup2 - test implemented - * fdatasync- test implemented - * fsync- test implemented - * pathconf - test implemented - * fpathconf- test implemented - * umask- test implemented - * utime- test implemented - * utimes - test implemented + * This test exercises the following routines: * - * COPYRIGHT (c) 1989-2009. + * - lseek() + * - dup() + * - dup2() + * - fdatasync() + * - fsync() + * - pathconf() + * - fpathconf() + * - umask() + * - utime() + * - utimes() + * - sync() + */ + +/* + * COPYRIGHT (c) 1989-2009, 2021. * On-Line Applications Resea
[PATCH] pwdgrp.c: Removed unused variable
The 'sc' variable was originally storing the return value of mkdir(). This was causing an issue, so it was changed to make it to where we ignored the return value with (void). The 'sc' variable was left in by mistake. --- cpukit/libcsupport/src/pwdgrp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/cpukit/libcsupport/src/pwdgrp.c b/cpukit/libcsupport/src/pwdgrp.c index aac31f4..d686829 100644 --- a/cpukit/libcsupport/src/pwdgrp.c +++ b/cpukit/libcsupport/src/pwdgrp.c @@ -63,8 +63,6 @@ static void init_file(const char *name, const char *content) */ static void pwdgrp_init(void) { - int sc; - /* * Do the best to create this directory. * -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH] psx13: Reworked and relicensed
>> +#ifdef __sparc__ >What's this for? Joel said this was a special case, and that it needed to be put in, so I'm not sure. For the printf's in test_main(), I should take out all of the print statements saying "Testing .Success"? -Original Message- From: Gedare Bloom Sent: Thursday, April 22, 2021 8:45 AM To: Ryan Long Cc: devel@rtems.org Subject: Re: [PATCH] psx13: Reworked and relicensed See below for comments. This test suite might be a good candidate for conversion to T_TEST_CASE framework. At any rate, this refactor is a marked improvement. On Wed, Apr 21, 2021 at 2:57 PM Ryan Long wrote: > > Changed the way the tests were structured, added > rtems_test_assert()'s, updated psx13.scn and the license. relicense changes should generally Update #3899. > --- > testsuites/psxtests/psx13/psx13.scn | 24 +- > testsuites/psxtests/psx13/test.c| 879 > +--- > 2 files changed, 335 insertions(+), 568 deletions(-) > > diff --git a/testsuites/psxtests/psx13/psx13.scn > b/testsuites/psxtests/psx13/psx13.scn > index 428a931..ee99867 100644 > --- a/testsuites/psxtests/psx13/psx13.scn > +++ b/testsuites/psxtests/psx13/psx13.scn > @@ -1,16 +1,16 @@ > *** POSIX TEST 13 *** > > Files initialized successfully. > -Testing device_lseek()... Failed!!! > -Testing dup() Failed!!! > -Testing dup2()... Success. > -Testing fdatasync().. Success. > -Testing umask().. Success. > -Testing utime().. Success. > -Testing utimes().. Success. > -Testing fsync().. Success. > -Testing pathconf()... Success. > -Testing fpathconf().. Success. > -Testing sync().. > +Testing lseek() on device... Success. > +Testing dup()... Success. > +Testing dup2().. Success. > +Testing fdatasync(). Success. > +Testing umask(). Success. > +Testing utime(). Success. > +Testing utimes() Success. > +Testing fsync(). Success. > +Testing pathconf().. Success. > +Testing fpathconf(). Success. > +Testing sync().. Success. > > -*** END OF TEST PSX13 *** > +*** END OF TEST PSX 13 *** > diff --git a/testsuites/psxtests/psx13/test.c > b/testsuites/psxtests/psx13/test.c > index 79b24c2..2d25b02 100644 > --- a/testsuites/psxtests/psx13/test.c > +++ b/testsuites/psxtests/psx13/test.c > @@ -1,26 +1,49 @@ > -/* > - * Psx13 > - * Chris Bond (working under Jennifer's account) > +/** > + * @file > + * > + * @brief This tests various file system functions. > * > * This test exercises the following routines: > * > - * device_lseek - test implemented > - * dup - test implemented > - * dup2 - test implemented > - * fdatasync- test implemented > - * fsync- test implemented > - * pathconf - test implemented > - * fpathconf- test implemented > - * umask- test implemented > - * utime- test implemented > - * utimes - test implemented > + * - lseek() > + * - dup() > + * - dup2() > + * - fdatasync() > + * - fsync() > + * - pathconf() > + * - fpathconf() > + * - umask() > + * - utime() > + * - utimes() > + * - sync() > + */ > + While you're at it, please conform to https://docs.rtems.org/branches/master/eng/coding-file-hdr.html#c-c-header-file-template > +/* > + * SPDX-License-Identifier: BSD-2-Clause > * > - * COPYRIGHT (c) 1989-2009. > + * 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 O
[PATCH] nfs.c: Change filesystem utime_h handler to utimens_h
Changed nfs_utime() to nfs_utimens(), changed the arguments to use a timespec array instead of individual variables for access and modified time. Updates #4400 --- nfsclient/src/nfs.c | 50 +- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/nfsclient/src/nfs.c b/nfsclient/src/nfs.c index bc9a2c6..72fefb9 100644 --- a/nfsclient/src/nfs.c +++ b/nfsclient/src/nfs.c @@ -2050,19 +2050,19 @@ static int nfs_rmnod( return rv; } -static int nfs_utime( +static int nfs_utimens( const rtems_filesystem_location_info_t *pathloc, /* IN */ - time_t actime, /* IN */ - time_t modtime /* IN */ + struct timespec times[2] /* IN */ + ) { sattr arg; /* TODO: add rtems EPOCH - UNIX EPOCH seconds */ - arg.atime.seconds = actime; - arg.atime.useconds = 0; - arg.mtime.seconds = modtime; - arg.mtime.useconds = 0; + arg.atime.seconds = times[0].tv_sec; + arg.atime.useconds = times[0].tv_nsec / 1000; + arg.mtime.seconds = times[1].tv_sec; + arg.mtime.useconds = times[1].tv_nsec / 1000; return nfs_sattr(pathloc->node_access, , SATTR_ATIME | SATTR_MTIME); } @@ -2254,25 +2254,25 @@ sattr arg; } const struct _rtems_filesystem_operations_table nfs_fs_ops = { - .lock_h = nfs_lock, - .unlock_h = nfs_unlock, - .eval_path_h= nfs_eval_path, - .link_h = nfs_link, + .lock_h= nfs_lock, + .unlock_h = nfs_unlock, + .eval_path_h = nfs_eval_path, + .link_h= nfs_link, .are_nodes_equal_h = nfs_are_nodes_equal, - .mknod_h= nfs_mknod, - .rmnod_h= nfs_rmnod, - .fchmod_h = nfs_fchmod, - .chown_h= nfs_chown, - .clonenod_h = nfs_clonenode, - .freenod_h = nfs_freenode, - .mount_h= rtems_filesystem_default_mount, - .unmount_h = rtems_filesystem_default_unmount, - .fsunmount_me_h = nfs_fsunmount_me, - .utime_h= nfs_utime, - .symlink_h = nfs_symlink, - .readlink_h = nfs_readlink, - .rename_h = nfs_rename, - .statvfs_h = rtems_filesystem_default_statvfs + .mknod_h = nfs_mknod, + .rmnod_h = nfs_rmnod, + .fchmod_h = nfs_fchmod, + .chown_h = nfs_chown, + .clonenod_h= nfs_clonenode, + .freenod_h = nfs_freenode, + .mount_h = rtems_filesystem_default_mount, + .unmount_h = rtems_filesystem_default_unmount, + .fsunmount_me_h= nfs_fsunmount_me, + .utimens_h = nfs_utimens, + .symlink_h = nfs_symlink, + .readlink_h= nfs_readlink, + .rename_h = nfs_rename, + .statvfs_h = rtems_filesystem_default_statvfs }; /* -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v1 1/5] libcsupport: Added futimens() and utimensat()
Reply is below. -Original Message- From: Gedare Bloom Sent: Tuesday, May 4, 2021 11:27 AM To: Ryan Long Cc: Sebastian Huber ; devel@rtems.org Subject: Re: [PATCH v1 1/5] libcsupport: Added futimens() and utimensat() On Tue, May 4, 2021 at 10:04 AM Ryan Long wrote: > > > > -Original Message- > From: Sebastian Huber > Sent: Tuesday, May 4, 2021 12:04 AM > To: Ryan Long ; devel@rtems.org > Subject: Re: [PATCH v1 1/5] libcsupport: Added futimens() and > utimensat() > > On 03/05/2021 15:40, Ryan Long wrote: > > > Created futimens.c and utimensat.c to add support for the POSIX > > methods futimens() and utimensat(). > > > > utime() and utimes() are considered obsolote by POSIX, but RTEMS > > will continue to support them. > > > > Closes #4396 > > --- > > cpukit/Makefile.am | 2 + > > cpukit/include/rtems/libio_.h | 61 +- > > cpukit/libcsupport/src/futimens.c | 91 +++ > > cpukit/libcsupport/src/utimensat.c | 229 > > + > > spec/build/cpukit/librtemscpu.yml | 2 + > > 5 files changed, 384 insertions(+), 1 deletion(-) > > create mode 100644 cpukit/libcsupport/src/futimens.c > > create mode 100644 cpukit/libcsupport/src/utimensat.c > > > > diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index > > b0df610..29b4207 100644 > > --- a/cpukit/Makefile.am > > +++ b/cpukit/Makefile.am > > @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c > > librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c > > librtemscpu_a_SOURCES += libcsupport/src/utime.c > > librtemscpu_a_SOURCES += libcsupport/src/utimes.c > > +librtemscpu_a_SOURCES += libcsupport/src/futimens.c > > +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c > > librtemscpu_a_SOURCES += libcsupport/src/utsname.c > > librtemscpu_a_SOURCES += libcsupport/src/vprintk.c > > librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git > > a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h > > index > > e9eb462..fc7a1e4 100644 > > --- a/cpukit/include/rtems/libio_.h > > +++ b/cpukit/include/rtems/libio_.h > > @@ -7,7 +7,7 @@ > >*/ > > > > /* > > - * COPYRIGHT (c) 1989-2011. > > + * COPYRIGHT (c) 1989-2011, 2021. > >* On-Line Applications Research Corporation (OAR). > >* > >* Modifications to support reference counting in the file system > > are @@ -357,6 +357,65 @@ static inline void > > rtems_filesystem_instance_unlock( > > (*mt_entry->ops->unlock_h)( mt_entry ); > > } > > > > +/* Prototypes for functions used between utimensat() and futimens() > > +*/ > > + > > +/** > > + * @brief Checks the tv_sec member of a timespec struct > > + * > > + * @param[in] time The timespec struct to be validated > > + * > > + * Ensures that the value in the tv_sec member is non-negative. > > + * > > + * @retval true If the tv_sec member is a valid value > > + * @retval false If the tv_sec member is not a valid value */ bool > > +rtems_filesystem_utime_tv_sec_valid( struct timespec time ); > > + > > +/** > > + * @brief Checks the tv_nsec member of a timespec struct > > + * > > + * Ensures that the value in the tv_nsec member is equal to either > > + * UTIME_NOW, UTIME_OMIT, or a value greater-than or equal to zero > > + * and less than a billion. > > + * > > + * @param[in] time The timespec struct to be validated > > + * > > + * @retval true If the tv_nsec member is a valid value > > + * @retval false If the tv_nsec member is not a valid value */ > > +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); > > Are these two functions ever used individually? Do they modify the time? > Maybe we should add a standard phase for boolean type returns: > > @return Returns true, if the X is valid, otherwise false. > > [Ryan Long] These functions are only used in > rtems_filesystem_utime_check_times(). They don't modify the time, they just > ensure that the members of the timespec struct are valid values. Should the > arguments for those functions be changed to be a const since they're not > being modified? And sure, I can consolidate the @retval statements like that. > > > + > > +/** > > + * @brief Determines if the process has write permissions to a file > > + * > > + * Checks that the process has the same userID as the file and > > +whether the > > + * file has write permissions. > > + * > > + *
[PATCH] nfs.c: Change filesystem utime_h handler to utimens_h
Changed nfs_utime() to nfs_utimens(), changed the arguments to use a timespec array instead of individual variables for access and modified time. Updates #4400 --- rtemsbsd/nfsclient/nfs.c | 50 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/rtemsbsd/nfsclient/nfs.c b/rtemsbsd/nfsclient/nfs.c index 3b8a592..baada6c 100644 --- a/rtemsbsd/nfsclient/nfs.c +++ b/rtemsbsd/nfsclient/nfs.c @@ -2058,19 +2058,19 @@ static int nfs_rmnod( return rv; } -static int nfs_utime( +static int nfs_utimens( const rtems_filesystem_location_info_t *pathloc, /* IN */ - time_t actime, /* IN */ - time_t modtime /* IN */ + struct timespec times[2] /* IN */ + ) { sattr arg; /* TODO: add rtems EPOCH - UNIX EPOCH seconds */ - arg.atime.seconds = actime; - arg.atime.useconds = 0; - arg.mtime.seconds = modtime; - arg.mtime.useconds = 0; + arg.atime.seconds = times[0].tv_sec; + arg.atime.useconds = times[0].tv_nsec / 1000; + arg.mtime.seconds = times[1].tv_sec; + arg.mtime.useconds = times[1].tv_nsec / 1000; return nfs_sattr(pathloc->node_access, , SATTR_ATIME | SATTR_MTIME); } @@ -2262,25 +2262,25 @@ sattr arg; } const struct _rtems_filesystem_operations_table nfs_fs_ops = { - .lock_h = nfs_lock, - .unlock_h = nfs_unlock, - .eval_path_h= nfs_eval_path, - .link_h = nfs_link, + .lock_h= nfs_lock, + .unlock_h = nfs_unlock, + .eval_path_h = nfs_eval_path, + .link_h= nfs_link, .are_nodes_equal_h = nfs_are_nodes_equal, - .mknod_h= nfs_mknod, - .rmnod_h= nfs_rmnod, - .fchmod_h = nfs_fchmod, - .chown_h= nfs_chown, - .clonenod_h = nfs_clonenode, - .freenod_h = nfs_freenode, - .mount_h= rtems_filesystem_default_mount, - .unmount_h = rtems_filesystem_default_unmount, - .fsunmount_me_h = nfs_fsunmount_me, - .utime_h= nfs_utime, - .symlink_h = nfs_symlink, - .readlink_h = nfs_readlink, - .rename_h = nfs_rename, - .statvfs_h = rtems_filesystem_default_statvfs + .mknod_h = nfs_mknod, + .rmnod_h = nfs_rmnod, + .fchmod_h = nfs_fchmod, + .chown_h = nfs_chown, + .clonenod_h= nfs_clonenode, + .freenod_h = nfs_freenode, + .mount_h = rtems_filesystem_default_mount, + .unmount_h = rtems_filesystem_default_unmount, + .fsunmount_me_h= nfs_fsunmount_me, + .utimens_h = nfs_utimens, + .symlink_h = nfs_symlink, + .readlink_h= nfs_readlink, + .rename_h = nfs_rename, + .statvfs_h = rtems_filesystem_default_statvfs }; /* -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2] libbsd nfs.c: Change filesystem utime_h handler to utimens_h
Changed nfs_utime() to nfs_utimens(), changed the arguments to use a timespec array instead of individual variables for access and modified time. Updates #4400 --- rtemsbsd/nfsclient/nfs.c | 50 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/rtemsbsd/nfsclient/nfs.c b/rtemsbsd/nfsclient/nfs.c index 3b8a592..baada6c 100644 --- a/rtemsbsd/nfsclient/nfs.c +++ b/rtemsbsd/nfsclient/nfs.c @@ -2058,19 +2058,19 @@ static int nfs_rmnod( return rv; } -static int nfs_utime( +static int nfs_utimens( const rtems_filesystem_location_info_t *pathloc, /* IN */ - time_t actime, /* IN */ - time_t modtime /* IN */ + struct timespec times[2] /* IN */ + ) { sattr arg; /* TODO: add rtems EPOCH - UNIX EPOCH seconds */ - arg.atime.seconds = actime; - arg.atime.useconds = 0; - arg.mtime.seconds = modtime; - arg.mtime.useconds = 0; + arg.atime.seconds = times[0].tv_sec; + arg.atime.useconds = times[0].tv_nsec / 1000; + arg.mtime.seconds = times[1].tv_sec; + arg.mtime.useconds = times[1].tv_nsec / 1000; return nfs_sattr(pathloc->node_access, , SATTR_ATIME | SATTR_MTIME); } @@ -2262,25 +2262,25 @@ sattr arg; } const struct _rtems_filesystem_operations_table nfs_fs_ops = { - .lock_h = nfs_lock, - .unlock_h = nfs_unlock, - .eval_path_h= nfs_eval_path, - .link_h = nfs_link, + .lock_h= nfs_lock, + .unlock_h = nfs_unlock, + .eval_path_h = nfs_eval_path, + .link_h= nfs_link, .are_nodes_equal_h = nfs_are_nodes_equal, - .mknod_h= nfs_mknod, - .rmnod_h= nfs_rmnod, - .fchmod_h = nfs_fchmod, - .chown_h= nfs_chown, - .clonenod_h = nfs_clonenode, - .freenod_h = nfs_freenode, - .mount_h= rtems_filesystem_default_mount, - .unmount_h = rtems_filesystem_default_unmount, - .fsunmount_me_h = nfs_fsunmount_me, - .utime_h= nfs_utime, - .symlink_h = nfs_symlink, - .readlink_h = nfs_readlink, - .rename_h = nfs_rename, - .statvfs_h = rtems_filesystem_default_statvfs + .mknod_h = nfs_mknod, + .rmnod_h = nfs_rmnod, + .fchmod_h = nfs_fchmod, + .chown_h = nfs_chown, + .clonenod_h= nfs_clonenode, + .freenod_h = nfs_freenode, + .mount_h = rtems_filesystem_default_mount, + .unmount_h = rtems_filesystem_default_unmount, + .fsunmount_me_h= nfs_fsunmount_me, + .utimens_h = nfs_utimens, + .symlink_h = nfs_symlink, + .readlink_h= nfs_readlink, + .rename_h = nfs_rename, + .statvfs_h = rtems_filesystem_default_statvfs }; /* -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2] legacy nfs.c: Change filesystem utime_h handler to utimens_h
Changed nfs_utime() to nfs_utimens(), changed the arguments to use a timespec array instead of individual variables for access and modified time. Updates #4400 --- nfsclient/src/nfs.c | 50 +- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/nfsclient/src/nfs.c b/nfsclient/src/nfs.c index bc9a2c6..72fefb9 100644 --- a/nfsclient/src/nfs.c +++ b/nfsclient/src/nfs.c @@ -2050,19 +2050,19 @@ static int nfs_rmnod( return rv; } -static int nfs_utime( +static int nfs_utimens( const rtems_filesystem_location_info_t *pathloc, /* IN */ - time_t actime, /* IN */ - time_t modtime /* IN */ + struct timespec times[2] /* IN */ + ) { sattr arg; /* TODO: add rtems EPOCH - UNIX EPOCH seconds */ - arg.atime.seconds = actime; - arg.atime.useconds = 0; - arg.mtime.seconds = modtime; - arg.mtime.useconds = 0; + arg.atime.seconds = times[0].tv_sec; + arg.atime.useconds = times[0].tv_nsec / 1000; + arg.mtime.seconds = times[1].tv_sec; + arg.mtime.useconds = times[1].tv_nsec / 1000; return nfs_sattr(pathloc->node_access, , SATTR_ATIME | SATTR_MTIME); } @@ -2254,25 +2254,25 @@ sattr arg; } const struct _rtems_filesystem_operations_table nfs_fs_ops = { - .lock_h = nfs_lock, - .unlock_h = nfs_unlock, - .eval_path_h= nfs_eval_path, - .link_h = nfs_link, + .lock_h= nfs_lock, + .unlock_h = nfs_unlock, + .eval_path_h = nfs_eval_path, + .link_h= nfs_link, .are_nodes_equal_h = nfs_are_nodes_equal, - .mknod_h= nfs_mknod, - .rmnod_h= nfs_rmnod, - .fchmod_h = nfs_fchmod, - .chown_h= nfs_chown, - .clonenod_h = nfs_clonenode, - .freenod_h = nfs_freenode, - .mount_h= rtems_filesystem_default_mount, - .unmount_h = rtems_filesystem_default_unmount, - .fsunmount_me_h = nfs_fsunmount_me, - .utime_h= nfs_utime, - .symlink_h = nfs_symlink, - .readlink_h = nfs_readlink, - .rename_h = nfs_rename, - .statvfs_h = rtems_filesystem_default_statvfs + .mknod_h = nfs_mknod, + .rmnod_h = nfs_rmnod, + .fchmod_h = nfs_fchmod, + .chown_h = nfs_chown, + .clonenod_h= nfs_clonenode, + .freenod_h = nfs_freenode, + .mount_h = rtems_filesystem_default_mount, + .unmount_h = rtems_filesystem_default_unmount, + .fsunmount_me_h= nfs_fsunmount_me, + .utimens_h = nfs_utimens, + .symlink_h = nfs_symlink, + .readlink_h= nfs_readlink, + .rename_h = nfs_rename, + .statvfs_h = rtems_filesystem_default_statvfs }; /* -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
RE: [PATCH v1 1/5] libcsupport: Added futimens() and utimensat()
-Original Message- From: Sebastian Huber Sent: Tuesday, May 4, 2021 12:04 AM To: Ryan Long ; devel@rtems.org Subject: Re: [PATCH v1 1/5] libcsupport: Added futimens() and utimensat() On 03/05/2021 15:40, Ryan Long wrote: > Created futimens.c and utimensat.c to add support for the POSIX > methods futimens() and utimensat(). > > utime() and utimes() are considered obsolote by POSIX, but RTEMS will > continue to support them. > > Closes #4396 > --- > cpukit/Makefile.am | 2 + > cpukit/include/rtems/libio_.h | 61 +- > cpukit/libcsupport/src/futimens.c | 91 +++ > cpukit/libcsupport/src/utimensat.c | 229 > + > spec/build/cpukit/librtemscpu.yml | 2 + > 5 files changed, 384 insertions(+), 1 deletion(-) > create mode 100644 cpukit/libcsupport/src/futimens.c > create mode 100644 cpukit/libcsupport/src/utimensat.c > > diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index > b0df610..29b4207 100644 > --- a/cpukit/Makefile.am > +++ b/cpukit/Makefile.am > @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c > librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c > librtemscpu_a_SOURCES += libcsupport/src/utime.c > librtemscpu_a_SOURCES += libcsupport/src/utimes.c > +librtemscpu_a_SOURCES += libcsupport/src/futimens.c > +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c > librtemscpu_a_SOURCES += libcsupport/src/utsname.c > librtemscpu_a_SOURCES += libcsupport/src/vprintk.c > librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git > a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index > e9eb462..fc7a1e4 100644 > --- a/cpukit/include/rtems/libio_.h > +++ b/cpukit/include/rtems/libio_.h > @@ -7,7 +7,7 @@ >*/ > > /* > - * COPYRIGHT (c) 1989-2011. > + * COPYRIGHT (c) 1989-2011, 2021. >* On-Line Applications Research Corporation (OAR). >* >* Modifications to support reference counting in the file system > are @@ -357,6 +357,65 @@ static inline void rtems_filesystem_instance_unlock( > (*mt_entry->ops->unlock_h)( mt_entry ); > } > > +/* Prototypes for functions used between utimensat() and futimens() > +*/ > + > +/** > + * @brief Checks the tv_sec member of a timespec struct > + * > + * @param[in] time The timespec struct to be validated > + * > + * Ensures that the value in the tv_sec member is non-negative. > + * > + * @retval true If the tv_sec member is a valid value > + * @retval false If the tv_sec member is not a valid value */ bool > +rtems_filesystem_utime_tv_sec_valid( struct timespec time ); > + > +/** > + * @brief Checks the tv_nsec member of a timespec struct > + * > + * Ensures that the value in the tv_nsec member is equal to either > + * UTIME_NOW, UTIME_OMIT, or a value greater-than or equal to zero > + * and less than a billion. > + * > + * @param[in] time The timespec struct to be validated > + * > + * @retval true If the tv_nsec member is a valid value > + * @retval false If the tv_nsec member is not a valid value */ bool > +rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); Are these two functions ever used individually? Do they modify the time? Maybe we should add a standard phase for boolean type returns: @return Returns true, if the X is valid, otherwise false. [Ryan Long] These functions are only used in rtems_filesystem_utime_check_times(). They don't modify the time, they just ensure that the members of the timespec struct are valid values. Should the arguments for those functions be changed to be a const since they're not being modified? And sure, I can consolidate the @retval statements like that. > + > +/** > + * @brief Determines if the process has write permissions to a file > + * > + * Checks that the process has the same userID as the file and > +whether the > + * file has write permissions. > + * > + * @param[in] currentloc The current location to a file > + * @param[in] fstat_h The file handler of @currentloc Why is this an extra parameter? [Ryan Long] This was Joel's suggestion, but I didn't think about just using the currentloc argument. I'll change that in V2. > + * > + * @retval 0 If the process has write permissions > + * @retval -1 If the process does not have write permissions Why 0 and -1, what about errno? Is it set by the function or not? [Ryan Long] It's 0 and -1 because it uses the rtems_set_errno_and_return_minus_one() macro. > + */ > +int rtems_filesystem_utime_check_permissions( > + const rtems_filesystem_location_info_t *currentloc, > + rtems_filesystem_fstat_t fstat_h > +); > + > +/** > + * @brief Checks @times and updates @new_times > + * >
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
[PATCH v1 4/5] psx13: Added tests for utimensat() and futimens()
Improved tests for utime() and utimes(). Close #4399 --- testsuites/psxtests/psx13/main.c | 2 - testsuites/psxtests/psx13/test.c | 484 +-- 2 files changed, 471 insertions(+), 15 deletions(-) diff --git a/testsuites/psxtests/psx13/main.c b/testsuites/psxtests/psx13/main.c index f9e7907..44267bd 100644 --- a/testsuites/psxtests/psx13/main.c +++ b/testsuites/psxtests/psx13/main.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * diff --git a/testsuites/psxtests/psx13/test.c b/testsuites/psxtests/psx13/test.c index e98b03a..bb7a201 100644 --- a/testsuites/psxtests/psx13/test.c +++ b/testsuites/psxtests/psx13/test.c @@ -1,5 +1,3 @@ -/* SPDX-License-Identifier: BSD-2-Clause */ - /** * @file * @@ -17,6 +15,8 @@ * - umask() * - utime() * - utimes() + * - utimensat() + * - futimens() * - sync() */ @@ -210,8 +210,7 @@ static void Dup2Test( void ) } /** - * @brief Exercises fdatasync(). Does NOT test the functionality of the - *underlying fdatasync entry in the IMFS op table. + * @brief Exercises fdatasync(). */ static void FDataSyncTest( void ) { @@ -259,13 +258,13 @@ static void UMaskTest( void ) } /** - * @brief Exercises utime(). Does not test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utime(). */ static void UTimeTest( void ) { int rv; struct utimbuf time; + struct timespec current_time; struct stat fstat; /* First, an invalid filename. */ @@ -273,6 +272,57 @@ static void UTimeTest( void ) rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + + /* Change the owner of the file temporarily */ + rv = chown( "testfile1.tst", 123, fstat.st_gid ); + rtems_test_assert( rv == 0 ); + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = chown( "testfile1.tst", fstat.st_uid, fstat.st_gid ); + rtems_test_assert( rv == 0 ); + + /* Change file to be read-only */ + rv = chmod( "testfile1.tst", 06444 ); + rtems_test_assert( rv == 0 ); + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = chmod( "testfile1.tst", fstat.st_mode ); + rtems_test_assert( rv == 0 ); + + /* Test without times argument */ + clock_gettime( CLOCK_REALTIME, _time ); + + rv = utime( "testfile1.tst", NULL ); + rtems_test_assert( rv == 0 ); + + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + rtems_test_assert( current_time.tv_sec <= fstat.st_atim.tv_sec ); + rtems_test_assert( current_time.tv_sec <= fstat.st_mtim.tv_sec ); + + /* Pass invalid values */ + time.actime = -1; + time.modtime = 54321; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + + time.actime = 12345; + time.modtime = -1; + + rv = utime( "testfile1.tst", ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EINVAL ); + /* Now, the success test. */ time.actime = 12345; time.modtime = 54321; @@ -280,24 +330,22 @@ static void UTimeTest( void ) rv = utime( "testfile1.tst", ); rtems_test_assert( rv == 0 ); - /* But, did it set the time? */ + /* Check that it actually changed the time */ rv = stat( "testfile1.tst", ); rtems_test_assert( rv == 0 ); rtems_test_assert( fstat.st_atime == 12345 ); rtems_test_assert( fstat.st_mtime == 54321 ); - rv = utime( "testfile1.tst", NULL ); - rtems_test_assert( rv == 0 ); } /** - * @brief Exercises utimes(). Does NOT test the functionality of the - *underlying utime entry in the IMFS op table. + * @brief Exercises utimes(). */ static void UTimesTest( void ) { int rv; struct timeval time[2]; + struct timespec current_time; struct stat fstat; /* First, an invalid filename. */ @@ -305,14 +353,422 @@ static void UTimesTest( void ) rtems_test_assert( rv == -1 ); rtems_test_assert( errno == ENOENT ); + rv = stat( "testfile1.tst", ); + rtems_test_assert( rv == 0 ); + + /* Change the owner of the file temporarily */ + rv = chown( "testfile1.tst", 123, fstat.st_gid ); + rtems_test_assert( rv == 0 ); + + rv = utimes( "testfile1.tst", time ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = chown( "testfile1.tst", fstat.st_uid, fstat.st_gid ); + rtems_test_assert( rv == 0 ); + + /* Change file to be read-only */ + rv = chmod( "testfile1.tst", 06444 ); + rtems_test_assert( rv == 0 ); + + rv = utimes( "testfile1.tst", time ); + rtems_test_assert( rv == -1 ); + rtems_test_assert( errno == EACCES ); + + rv = chmod( "testfile1.tst", fstat.st_mode ); + rtems_test_assert( rv == 0 ); + + /* Test without times argument */ + clock_gettime( CLOCK_REALTIME, _time ); + + rv = utimes(
[PATCH v1 3/5] libcsupport: Implement utimes() in terms of utimensat()
utimes() now calls utimensat() to update file access and modification timestamps. Closes #4398 --- cpukit/libcsupport/src/utimes.c | 54 ++--- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/cpukit/libcsupport/src/utimes.c b/cpukit/libcsupport/src/utimes.c index 3dc47c0..568871c 100644 --- a/cpukit/libcsupport/src/utimes.c +++ b/cpukit/libcsupport/src/utimes.c @@ -1,38 +1,64 @@ /** * @file * - * @brief Change File Last Access and Modification Times * @ingroup libcsupport + * + * @brief Set file access and modification times in milliseconds. */ /* - * Written by: Vinu Rajashekhar + * COPYRIGHT (c) 1989-2009, 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 #include "config.h" #endif -#include -#include #include +#include + +/** + * https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/futimens.html + * + * Set file access and modification times + */ int utimes( const char *path, const struct timeval times[2] -) +) { - struct utimbuf timeinsecs; + struct timespec timeinsecs[2]; - if ( times == NULL ) -return utime( path, NULL ); + if( times == NULL ) +return utimensat( AT_FDCWD, path, NULL , 0 ); - timeinsecs.actime = times[0].tv_sec; - timeinsecs.modtime = times[1].tv_sec; + timeinsecs[0].tv_sec = times[0].tv_sec; + timeinsecs[0].tv_nsec = times[0].tv_usec * 1000; + timeinsecs[1].tv_sec = times[1].tv_sec; + timeinsecs[1].tv_nsec = times[1].tv_usec * 1000; - return utime( path, ); + return utimensat( AT_FDCWD, path, timeinsecs, 0 ); } -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 5/5] Change filesystem utime_h handler to utimens_h
Closes #4400 --- bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 4 +-- cpukit/include/rtems/confdefs/libio.h | 4 +-- cpukit/include/rtems/imfs.h | 7 +++-- cpukit/include/rtems/libio.h| 21 +++ cpukit/libcsupport/src/__usrenv.c | 9 +++ cpukit/libfs/src/defaults/default_ops.c | 2 +- cpukit/libfs/src/defaults/default_utime.c | 32 -- cpukit/libfs/src/defaults/default_utimens.c | 33 +++ cpukit/libfs/src/dosfs/msdos_init.c | 11 cpukit/libfs/src/ftpfs/ftpfs.c | 2 +- cpukit/libfs/src/ftpfs/tftpDriver.c | 2 +- cpukit/libfs/src/imfs/imfs_init.c | 4 +-- cpukit/libfs/src/imfs/imfs_utime.c | 41 cpukit/libfs/src/imfs/imfs_utimens.c| 42 + cpukit/libfs/src/jffs2/src/fs-rtems.c | 11 cpukit/libfs/src/rfs/rtems-rfs-rtems.c | 16 +-- spec/build/cpukit/librtemscpu.yml | 4 +-- 18 files changed, 120 insertions(+), 127 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 diff --git a/bsps/arm/csb337/umon/tfsDriver.c b/bsps/arm/csb337/umon/tfsDriver.c index 0195346..caf3a4b 100644 --- a/bsps/arm/csb337/umon/tfsDriver.c +++ b/bsps/arm/csb337/umon/tfsDriver.c @@ -657,7 +657,7 @@ static const rtems_filesystem_operations_table rtems_tfs_ops = { .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/Makefile.am b/cpukit/Makefile.am index 29b4207..c144773 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -377,7 +377,7 @@ librtemscpu_a_SOURCES += libfs/src/defaults/default_rmnod.c librtemscpu_a_SOURCES += libfs/src/defaults/default_statvfs.c librtemscpu_a_SOURCES += libfs/src/defaults/default_symlink.c librtemscpu_a_SOURCES += libfs/src/defaults/default_unmount.c -librtemscpu_a_SOURCES += libfs/src/defaults/default_utime.c +librtemscpu_a_SOURCES += libfs/src/defaults/default_utimens.c librtemscpu_a_SOURCES += libfs/src/defaults/default_write.c librtemscpu_a_SOURCES += libfs/src/defaults/default_writev.c librtemscpu_a_SOURCES += libfs/src/dosfs/fat.c @@ -434,7 +434,7 @@ librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_stat_file.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_symlink.c librtemscpu_a_SOURCES += libfs/src/imfs/imfs_unmount.c -librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utime.c +librtemscpu_a_SOURCES += libfs/src/imfs/imfs_utimens.c librtemscpu_a_SOURCES += libfs/src/imfs/ioman.c librtemscpu_a_SOURCES += libfs/src/pipe/fifo.c librtemscpu_a_SOURCES += libfs/src/pipe/pipe.c diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h index 16a4fb69..1b84f8c 100644 --- a/cpukit/include/rtems/confdefs/libio.h +++ b/cpukit/include/rtems/confdefs/libio.h @@ -231,9 +231,9 @@ static const rtems_filesystem_operations_table IMFS_root_ops = { #endif rtems_filesystem_default_fsunmount, #ifdef CONFIGURE_IMFS_DISABLE_UTIME -rtems_filesystem_default_utime, +rtems_filesystem_default_utimens, #else -IMFS_utime, +IMFS_utimens, #endif #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK rtems_filesystem_default_symlink, diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index b2a9868..6e0d5d5 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -5,7 +5,7 @@ */ /* - * COPYRIGHT (c) 1989-2011. + * COPYRIGHT (c) 1989-2011, 2021. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -954,10 +954,9 @@ extern int device_ftruncate( * This routine is the implementation of the utime() system * call for the IMFS. */ -extern int IMFS_utime( +extern int IMFS_utimens( const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime + struct timespec times[2] ); /** diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h index 519e797..99543ba 100644 --- a/cpukit/include/rtems/libio.h +++ b/cpukit/include/rtems/libio.h @@ -11,7 +11,7 @@ */ /* - * COPYRIGHT (c) 1989-2008. + * COPYRIGHT (c) 1989-2008, 2021. * On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are @@ -375,18 +375,16 @@ typedef int
[PATCH v1 0/5] Add nanosecond support patch
Hi, For this series of patches, I - Created the futimens() and utimensat() functions - Reimplemented utime() and utimes() using utimensat() - Added onto the test cases for utime() and utimes() - Made tests for utimensat() and futimens() - Changed the utime_h handler to utimens_h() I still have to change the handler itself. The main change that was made in that patch was changing the arguments from an access and modifcation time to a timespec array. The names of the functions were changed, and a couple of files were renamed as well. Thanks, Ryan Ryan Long (5): libcsupport: Added futimens() and utimensat() libcsupport: Implement utime() in terms of utimensat() libcsupport: Implement utimes() in terms of utimensat() psx13: Added tests for utimensat() and futimens() Change filesystem utime_h handler to utimens_h bsps/arm/csb337/umon/tfsDriver.c| 2 +- cpukit/Makefile.am | 6 +- cpukit/include/rtems/confdefs/libio.h | 4 +- cpukit/include/rtems/imfs.h | 7 +- cpukit/include/rtems/libio.h| 21 +- cpukit/include/rtems/libio_.h | 61 +++- cpukit/libcsupport/src/__usrenv.c | 9 +- cpukit/libcsupport/src/futimens.c | 91 ++ cpukit/libcsupport/src/utime.c | 74 +++-- cpukit/libcsupport/src/utimensat.c | 229 + cpukit/libcsupport/src/utimes.c | 54 +++- cpukit/libfs/src/defaults/default_ops.c | 2 +- cpukit/libfs/src/defaults/default_utime.c | 32 -- cpukit/libfs/src/defaults/default_utimens.c | 33 ++ cpukit/libfs/src/dosfs/msdos_init.c | 11 +- cpukit/libfs/src/ftpfs/ftpfs.c | 2 +- cpukit/libfs/src/ftpfs/tftpDriver.c | 2 +- cpukit/libfs/src/imfs/imfs_init.c | 4 +- cpukit/libfs/src/imfs/imfs_utime.c | 41 --- cpukit/libfs/src/imfs/imfs_utimens.c| 42 +++ cpukit/libfs/src/jffs2/src/fs-rtems.c | 11 +- cpukit/libfs/src/rfs/rtems-rfs-rtems.c | 16 +- spec/build/cpukit/librtemscpu.yml | 6 +- testsuites/psxtests/psx13/main.c| 2 - testsuites/psxtests/psx13/test.c| 484 +++- 25 files changed, 1056 insertions(+), 190 deletions(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c 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 -- 1.8.3.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v1 1/5] libcsupport: Added futimens() and utimensat()
Created futimens.c and utimensat.c to add support for the POSIX methods futimens() and utimensat(). utime() and utimes() are considered obsolote by POSIX, but RTEMS will continue to support them. Closes #4396 --- cpukit/Makefile.am | 2 + cpukit/include/rtems/libio_.h | 61 +- cpukit/libcsupport/src/futimens.c | 91 +++ cpukit/libcsupport/src/utimensat.c | 229 + spec/build/cpukit/librtemscpu.yml | 2 + 5 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 cpukit/libcsupport/src/futimens.c create mode 100644 cpukit/libcsupport/src/utimensat.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index b0df610..29b4207 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -262,6 +262,8 @@ librtemscpu_a_SOURCES += libcsupport/src/unmount.c librtemscpu_a_SOURCES += libcsupport/src/__usrenv.c librtemscpu_a_SOURCES += libcsupport/src/utime.c librtemscpu_a_SOURCES += libcsupport/src/utimes.c +librtemscpu_a_SOURCES += libcsupport/src/futimens.c +librtemscpu_a_SOURCES += libcsupport/src/utimensat.c librtemscpu_a_SOURCES += libcsupport/src/utsname.c librtemscpu_a_SOURCES += libcsupport/src/vprintk.c librtemscpu_a_SOURCES += libcsupport/src/write.c diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h index e9eb462..fc7a1e4 100644 --- a/cpukit/include/rtems/libio_.h +++ b/cpukit/include/rtems/libio_.h @@ -7,7 +7,7 @@ */ /* - * COPYRIGHT (c) 1989-2011. + * COPYRIGHT (c) 1989-2011, 2021. * On-Line Applications Research Corporation (OAR). * * Modifications to support reference counting in the file system are @@ -357,6 +357,65 @@ static inline void rtems_filesystem_instance_unlock( (*mt_entry->ops->unlock_h)( mt_entry ); } +/* Prototypes for functions used between utimensat() and futimens() */ + +/** + * @brief Checks the tv_sec member of a timespec struct + * + * @param[in] time The timespec struct to be validated + * + * Ensures that the value in the tv_sec member is non-negative. + * + * @retval true If the tv_sec member is a valid value + * @retval false If the tv_sec member is not a valid value + */ +bool rtems_filesystem_utime_tv_sec_valid( struct timespec time ); + +/** + * @brief Checks the tv_nsec member of a timespec struct + * + * Ensures that the value in the tv_nsec member is equal to either + * UTIME_NOW, UTIME_OMIT, or a value greater-than or equal to zero + * and less than a billion. + * + * @param[in] time The timespec struct to be validated + * + * @retval true If the tv_nsec member is a valid value + * @retval false If the tv_nsec member is not a valid value + */ +bool rtems_filesystem_utime_tv_nsec_valid( struct timespec time ); + +/** + * @brief Determines if the process has write permissions to a file + * + * Checks that the process has the same userID as the file and whether the + * file has write permissions. + * + * @param[in] currentloc The current location to a file + * @param[in] fstat_h The file handler of @currentloc + * + * @retval 0 If the process has write permissions + * @retval -1 If the process does not have write permissions + */ +int rtems_filesystem_utime_check_permissions( + const rtems_filesystem_location_info_t *currentloc, + rtems_filesystem_fstat_t fstat_h +); + +/** + * @brief Checks @times and updates @new_times + * + * @param[in] times The timespec struct to be checked + * @param[in,out] new_times The timespec struct to contain the updated time + * + * @retval 0 If the time was able to be updated + * @retval -1 If the time was not able to be updated + */ +int rtems_filesystem_utime_check_times( + const struct timespec times[2], + struct timespec new_times[2] +); + /* * File Descriptor Routine Prototypes */ diff --git a/cpukit/libcsupport/src/futimens.c b/cpukit/libcsupport/src/futimens.c new file mode 100644 index 000..33ae469 --- /dev/null +++ b/cpukit/libcsupport/src/futimens.c @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup libcsupport + * + * @brief Set file access and modification times based on file descriptor in + * nanoseconds. + */ + +/* + * COPYRIGHT (c) 1989-2009, 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
[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( , path, eval_flags ); - struct utimbuf now_times; - - if ( times == NULL ) { -time_t now = time( NULL ); - -now_times.actime = now; -now_times.modtime = now; - -times = _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( ); + 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