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

4.11
Last change on this file since a9df916 was a9df916, checked in by Sebastian Huber <sebastian.huber@…>, on Feb 8, 2015 at 6:43:09 PM

IMFS: Add fine grained configuration

Remove miniIMFS. Statically initialize the root IMFS.

Add configuration options to disable individual
features of the root IMFS, e.g.

o CONFIGURE_IMFS_DISABLE_CHOWN,
o CONFIGURE_IMFS_DISABLE_FCHMOD,
o CONFIGURE_IMFS_DISABLE_LINK,
o CONFIGURE_IMFS_DISABLE_MKNOD,
o CONFIGURE_IMFS_DISABLE_MOUNT,
o CONFIGURE_IMFS_DISABLE_READLINK,
o CONFIGURE_IMFS_DISABLE_RENAME,
o CONFIGURE_IMFS_DISABLE_RMNOD,
o CONFIGURE_IMFS_DISABLE_SYMLINK,
o CONFIGURE_IMFS_DISABLE_UNMOUNT, and
o CONFIGURE_IMFS_DISABLE_UTIME.

  • Property mode set to 100644
File size: 2.9 KB
Line 
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>
22#include <errno.h>
23#include <stdio.h>
24#include <unistd.h>
25#include <utime.h>
26
27#include <rtems/imfs.h>
28#include <rtems/libio.h>
29
30const char rtems_test_name[] = "FSIMFSCONFIG 1";
31
32static const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER(
33  &rtems_filesystem_handlers_default,
34  IMFS_node_initialize_generic,
35  IMFS_node_destroy_default
36);
37
38static void Init(rtems_task_argument arg)
39{
40  struct utimbuf times;
41  const char *generic = "generic";
42  const char *mnt = "mnt";
43  int rv;
44
45  TEST_BEGIN();
46
47  rv = IMFS_make_generic_node(
48    generic,
49    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
50    &node_control,
51    NULL
52  );
53  rtems_test_assert(rv == 0);
54
55  errno = 0;
56  rv = chown(generic, 0, 0);
57  rtems_test_assert(rv == -1);
58  rtems_test_assert(errno == ENOTSUP);
59
60  errno = 0;
61  rv = chmod(generic, 0);
62  rtems_test_assert(rv == -1);
63  rtems_test_assert(errno == ENOTSUP);
64
65  errno = 0;
66  rv = link(generic, "link");
67  rtems_test_assert(rv == -1);
68  rtems_test_assert(errno == ENOTSUP);
69
70  rv = mkdir(mnt, S_IRWXU);
71  rtems_test_assert(rv == 0);
72
73  errno = 0;
74  rv = mount(
75    "",
76    mnt,
77    RTEMS_FILESYSTEM_TYPE_IMFS,
78    RTEMS_FILESYSTEM_READ_ONLY,
79    NULL
80  );
81  rtems_test_assert(rv == -1);
82  rtems_test_assert(errno == ENOTSUP);
83
84  errno = 0;
85  rv = rename(generic, "new");
86  rtems_test_assert(rv == -1);
87  rtems_test_assert(errno == ENOTSUP);
88
89  errno = 0;
90  rv = unlink(generic);
91  rtems_test_assert(rv == -1);
92  rtems_test_assert(errno == ENOTSUP);
93
94  errno = 0;
95  rv = symlink(generic, "link");
96  rtems_test_assert(rv == -1);
97  rtems_test_assert(errno == ENOTSUP);
98
99  errno = 0;
100  rv = utime(generic, &times);
101  rtems_test_assert(rv == -1);
102  rtems_test_assert(errno == ENOTSUP);
103
104  TEST_END();
105  rtems_test_exit(0);
106}
107
108#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
109#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
110
111#define CONFIGURE_FILESYSTEM_IMFS
112
113#define CONFIGURE_IMFS_DISABLE_CHOWN
114#define CONFIGURE_IMFS_DISABLE_FCHMOD
115#define CONFIGURE_IMFS_DISABLE_LINK
116
117#if 0
118/*
119 * This would lead to a fatal error since rtems_filesystem_initialize() creates
120 * a "/dev" directory.
121 */
122#define CONFIGURE_IMFS_DISABLE_MKNOD
123#endif
124
125#define CONFIGURE_IMFS_DISABLE_MOUNT
126#define CONFIGURE_IMFS_DISABLE_RENAME
127#define CONFIGURE_IMFS_DISABLE_RMNOD
128#define CONFIGURE_IMFS_DISABLE_SYMLINK
129#define CONFIGURE_IMFS_DISABLE_UTIME
130
131#define CONFIGURE_MAXIMUM_TASKS 1
132
133#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
134
135#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
136
137#define CONFIGURE_INIT
138
139#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.