File indexing completed on 2025-05-11 08:24:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032
0033 #include <sys/stat.h>
0034 #include <stdio.h>
0035 #include <string.h>
0036 #include <unistd.h>
0037 #include <stdlib.h>
0038 #include <errno.h>
0039 #include <rtems.h>
0040 #include <fcntl.h>
0041 #include <inttypes.h>
0042 #include <rtems/error.h>
0043 #include <ctype.h>
0044 #include <rtems/libcsupport.h>
0045
0046 #include "fstest.h"
0047 #include "fs_config.h"
0048 #include "tmacros.h"
0049
0050 const char rtems_test_name[] = "FSFPATHCONF " FILESYSTEM;
0051 const RTEMS_TEST_STATE rtems_test_state = TEST_STATE;
0052
0053 static void fpathconf_test(void){
0054
0055 int rv = 0;
0056 const char *fname = "testfile.km";
0057 int fd = -1;
0058
0059
0060 rv = fpathconf(fd, _PC_LINK_MAX);
0061 printf("\nfpathconf of non-existing file give %d , expected -1",rv);
0062
0063 if (rv == -1) {
0064 printf("\n... creating file \"%s\"\n",fname);
0065 fd = open(fname,O_WRONLY | O_CREAT | O_TRUNC,S_IREAD|S_IWRITE);
0066
0067 if (fd < 0) {
0068 printf("*** file create failed, errno = %d(%s)\n",errno,strerror(errno));
0069 }else
0070 printf("*** file created succesfully\n");
0071
0072
0073 rv = fpathconf(fd, _PC_LINK_MAX);
0074 printf("\nrequest with _PC_LINK_MAX return : %d",rv);
0075 rv = fpathconf(fd, _PC_MAX_CANON);
0076 printf("\nrequest with _PC_MAX_CANON return : %d",rv);
0077 rv = fpathconf(fd, _PC_MAX_INPUT);
0078 printf("\nrequest with _PC_MAX_INPUT return : %d",rv);
0079 rv = fpathconf(fd, _PC_NAME_MAX);
0080 printf("\nrequest with _PC_NAME_MAX return : %d",rv);
0081 rv = fpathconf(fd, _PC_PATH_MAX);
0082 printf("\nrequest with _PC_PATH_MAX return : %d",rv);
0083 rv = fpathconf(fd, _PC_PIPE_BUF);
0084 printf("\nrequest with _PC_PIPE_BUF return : %d",rv);
0085 rv = fpathconf(fd, _PC_CHOWN_RESTRICTED);
0086 printf("\nrequest with _PC_CHOWN_RESTRICTED return : %d",rv);
0087 rv = fpathconf(fd, _PC_NO_TRUNC);
0088 printf("\nrequest with _PC_NO_TRUNC return : %d",rv);
0089 rv = fpathconf(fd, _PC_VDISABLE);
0090 printf("\nrequest with _PC_VDISABLE return : %d",rv);
0091 rv = fpathconf(fd, _PC_ASYNC_IO);
0092 printf("\nrequest with _PC_ASYNC_IO return : %d",rv);
0093 rv = fpathconf(fd, _PC_PRIO_IO);
0094 printf("\nrequest with _PC_PRIO_IO return : %d",rv);
0095 rv = fpathconf(fd, _PC_SYNC_IO);
0096 printf("\nrequest with _PC_SYNC_IO return : %d",rv);
0097
0098 rv = fpathconf(fd, 255);
0099 printf("\nrequest with bad argument return : %d",rv);
0100
0101 close(fd);
0102 fd = open("testfile.test", O_WRONLY);
0103
0104 rv = fpathconf(fd, _PC_LINK_MAX);
0105 }
0106 }
0107
0108 void test(void){
0109 fpathconf_test();
0110 }
0111
0112