source: rtems/testsuites/fstests/fsimfsconfig01/init.c @ f785492

4.115
Last change on this file since f785492 was f785492, checked in by Sebastian Huber <sebastian.huber@…>, on 02/14/15 at 19:07:19

IMFS: Add CONFIGURE_IMFS_DISABLE_READDIR

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[a9df916]1/*
2 * Copyright (c) 2015 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include "tmacros.h"
20
21#include <sys/stat.h>
[f785492]22#include <dirent.h>
[a9df916]23#include <errno.h>
[12eee4fd]24#include <fcntl.h>
[a9df916]25#include <stdio.h>
26#include <unistd.h>
27#include <utime.h>
28
29#include <rtems/imfs.h>
30#include <rtems/libio.h>
31
32const char rtems_test_name[] = "FSIMFSCONFIG 1";
33
34static const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER(
35  &rtems_filesystem_handlers_default,
36  IMFS_node_initialize_generic,
37  IMFS_node_destroy_default
38);
39
40static void Init(rtems_task_argument arg)
41{
42  struct utimbuf times;
43  const char *generic = "generic";
44  const char *mnt = "mnt";
[12eee4fd]45  const char *dev = "device";
46  const char *file = "file";
47  const char *fifo = "fifo";
[a9df916]48  int rv;
[12eee4fd]49  int fd;
[f785492]50  DIR *dirp;
51  struct dirent *dire;
52  struct stat st;
[a9df916]53
54  TEST_BEGIN();
55
56  rv = IMFS_make_generic_node(
57    generic,
58    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
59    &node_control,
60    NULL
61  );
62  rtems_test_assert(rv == 0);
63
64  errno = 0;
65  rv = chown(generic, 0, 0);
66  rtems_test_assert(rv == -1);
67  rtems_test_assert(errno == ENOTSUP);
68
69  errno = 0;
70  rv = chmod(generic, 0);
71  rtems_test_assert(rv == -1);
72  rtems_test_assert(errno == ENOTSUP);
73
74  errno = 0;
75  rv = link(generic, "link");
76  rtems_test_assert(rv == -1);
77  rtems_test_assert(errno == ENOTSUP);
78
79  rv = mkdir(mnt, S_IRWXU);
80  rtems_test_assert(rv == 0);
81
[12eee4fd]82  rv = mknod(dev, S_IFCHR | S_IRWXU, 0);
83  rtems_test_assert(rv == 0);
84
[40a18d7f]85  errno = 0;
[12eee4fd]86  fd = creat(file, S_IRWXU);
[40a18d7f]87  rtems_test_assert(fd == -1);
88  rtems_test_assert(errno == ENOSYS);
[12eee4fd]89
90  errno = 0;
91  rv = mkfifo(fifo, S_IRWXU);
92  rtems_test_assert(rv == -1);
93  rtems_test_assert(errno == ENOSYS);
94
[f785492]95  dirp = opendir(mnt);
96  rtems_test_assert(dirp != NULL);
97
98  errno = 0;
99  dire = readdir(dirp);
100  rtems_test_assert(dire == NULL);
101  rtems_test_assert(errno == ENOTSUP);
102
103  rv = closedir(dirp);
104  rtems_test_assert(rv == 0);
105
106  rv = stat(mnt, &st);
107  rtems_test_assert(rv == 0);
108  rtems_test_assert(st.st_size == 0);
109
[a9df916]110  errno = 0;
111  rv = mount(
112    "",
113    mnt,
114    RTEMS_FILESYSTEM_TYPE_IMFS,
115    RTEMS_FILESYSTEM_READ_ONLY,
116    NULL
117  );
118  rtems_test_assert(rv == -1);
119  rtems_test_assert(errno == ENOTSUP);
120
121  errno = 0;
122  rv = rename(generic, "new");
123  rtems_test_assert(rv == -1);
124  rtems_test_assert(errno == ENOTSUP);
125
126  errno = 0;
[12eee4fd]127  rv = symlink(generic, "link");
[a9df916]128  rtems_test_assert(rv == -1);
129  rtems_test_assert(errno == ENOTSUP);
130
131  errno = 0;
[12eee4fd]132  rv = utime(generic, &times);
[a9df916]133  rtems_test_assert(rv == -1);
134  rtems_test_assert(errno == ENOTSUP);
135
136  errno = 0;
[12eee4fd]137  rv = unlink(generic);
[a9df916]138  rtems_test_assert(rv == -1);
139  rtems_test_assert(errno == ENOTSUP);
140
141  TEST_END();
142  rtems_test_exit(0);
143}
144
145#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
146#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
147
[12eee4fd]148#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
149
[a9df916]150#define CONFIGURE_FILESYSTEM_IMFS
151
152#define CONFIGURE_IMFS_DISABLE_CHOWN
[249766c5]153#define CONFIGURE_IMFS_DISABLE_CHMOD
[a9df916]154#define CONFIGURE_IMFS_DISABLE_LINK
155
156#if 0
157/*
158 * This would lead to a fatal error since rtems_filesystem_initialize() creates
159 * a "/dev" directory.
160 */
161#define CONFIGURE_IMFS_DISABLE_MKNOD
162#endif
163
[40a18d7f]164#define CONFIGURE_IMFS_DISABLE_MKNOD_FILE
[a9df916]165#define CONFIGURE_IMFS_DISABLE_MOUNT
166#define CONFIGURE_IMFS_DISABLE_RENAME
[f785492]167#define CONFIGURE_IMFS_DISABLE_READDIR
[a9df916]168#define CONFIGURE_IMFS_DISABLE_RMNOD
169#define CONFIGURE_IMFS_DISABLE_SYMLINK
170#define CONFIGURE_IMFS_DISABLE_UTIME
171
172#define CONFIGURE_MAXIMUM_TASKS 1
173
174#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
175
176#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
177
178#define CONFIGURE_INIT
179
180#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.