Changeset 5e7b3c65 in rtems


Ignore:
Timestamp:
Oct 7, 2019, 3:48:23 PM (6 months ago)
Author:
Joel Sherrill <joel@…>
Branches:
master
Children:
ebf0f8f
Parents:
362cf319
git-author:
Joel Sherrill <joel@…> (10/07/19 15:48:23)
git-committer:
Joel Sherrill <joel@…> (01/17/20 22:13:35)
Message:

posix_devctl - Add support for SOCKCLOSE

The FACE Technical Standard, Edition 3.0 and later require the definition
of the subcommand SOCKCLOSE in <devctl.h>.

Reference: ​https://www.opengroup.org/face

closes #3856.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/posix_devctl.c

    r362cf319 r5e7b3c65  
    11/*
    2  * Copyright (c) 2016 Joel Sherrill <joel@rtems.org>.  All rights reserved.
     2 * Copyright (c) 2016, 2020 Joel Sherrill <joel@rtems.org>.
     3 * All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3334#include <sys/ioctl.h>
    3435#include <rtems/seterr.h>
     36
     37#include  <unistd.h>
    3538
    3639int posix_devctl(
     
    6972  }
    7073
     74  /*
     75   * The FACE Technical Standard Edition 3.0 and newer requires the SOCKCLOSE
     76   * ioctl command. This is because the Security Profile does not include
     77   * close() and applications need a way to close sockets. Closing sockets is
     78   * a minimum requirement so using close() in the implementation meets that
     79   * requirement but also lets the application close other file types.
     80   */
     81  if (dcmd == SOCKCLOSE ) {
     82    return close(fd);
     83  }
     84
    7185  return ioctl(fd, dcmd, dev_data_ptr);
    7286}
  • testsuites/psxtests/psxdevctl01/main.c

    r362cf319 r5e7b3c65  
    4040#define CONFIGURE_MAXIMUM_TASKS 1
    4141
     42#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 4
     43
    4244#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
    4345
  • testsuites/psxtests/psxdevctl01/psxdevctl01.scn

    r362cf319 r5e7b3c65  
    11*** BEGIN OF TEST PSXDEVCTL 1 ***
    22posix_devctl() FIONBIO on stdin return dev_info -- EBADF
    3 posix_devctl() FIONBIO on stdin return dev_info -- EBADF
     3posix_devctl() FIONBIO on stdin NULL dev_info -- EBADF
     4posix_devctl() SOCKCLOSE on invalid file descriptor -- EBADF
     5posix_devctl() SOCKCLOSE on valid file descriptor -- OK
    46*** END OF TEST PSXDEVCTL 1 ***
  • testsuites/psxtests/psxdevctl01/test.c

    r362cf319 r5e7b3c65  
    7777  rtems_test_assert( errno == EBADF );
    7878
     79  puts( "posix_devctl() SOCKCLOSE on invalid file descriptor -- EBADF" );
     80  fd = 21;
     81  dcmd = SOCKCLOSE;
     82  dev_data_ptr = NULL;
     83  nbyte = 0;
     84  status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL );
     85  rtems_test_assert( status == -1 );
     86  rtems_test_assert( errno == EBADF );
     87
     88  /*
     89   * Create a file, open it, and close it via posix_devctl().
     90   * Then verify it is really closed.
     91   */
     92  puts( "posix_devctl() SOCKCLOSE on valid file descriptor -- OK" );
     93  fd = open("tmp_for_close", O_CREAT | O_RDWR, S_IRWXU );
     94  rtems_test_assert( fd != -1 );
     95
     96  dcmd = SOCKCLOSE;
     97  dev_data_ptr = NULL;
     98  nbyte = 0;
     99  status = posix_devctl( fd, dcmd, dev_data_ptr, nbyte, NULL );
     100  rtems_test_assert( status == 0 );
     101
     102  status = close( fd );
     103  rtems_test_assert( status == -1 );
     104  rtems_test_assert( errno == EBADF );
    79105  TEST_END();
    80106  exit(0);
Note: See TracChangeset for help on using the changeset viewer.