summaryrefslogtreecommitdiffstats
path: root/filesystem/in-memory.rst
blob: 59da32bdf61452ab360b242abc299ee453117701 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
In-Memory Filesystem
####################

This chapter describes the In-Memory FileSystem (IMFS).  The IMFS is a
full featured POSIX filesystem that keeps all information in memory.

IMFS Per Node Data Structure
============================

Each regular file, device, hard link, and directory is represented by a data
structure called a ``jnode``. The ``jnode`` is formally represented by the
structure:
.. code:: c

    struct IMFS_jnode_tt {
    Chain_Node          Node;             /* for chaining them together \*/
    IMFS_jnode_t       \*Parent;           /* Parent node \*/
    char                name[NAME_MAX+1]; /* "basename" \*/
    mode_t              st_mode;          /* File mode \*/
    nlink_t             st_nlink;         /* Link count \*/
    ino_t               st_ino;           /* inode \*/
    uid_t               st_uid;           /* User ID of owner \*/
    gid_t               st_gid;           /* Group ID of owner \*/
    time_t              st_atime;         /* Time of last access \*/
    time_t              st_mtime;         /* Time of last modification \*/
    time_t              st_ctime;         /* Time of last status change \*/
    IMFS_jnode_types_t  type;             /* Type of this entry \*/
    IMFS_typs_union     info;
    };

The key elements of this structure are listed below together with a brief
explanation of their role in the filesystem.

*Node*
    exists to allow the entire ``jnode`` structure to be included in a chain.

*Parent*
    is a pointer to another ``jnode`` structure that is the logical parent of the
    node in which it appears.  This field may be NULL if the file associated with
    this node is deleted but there are open file descriptors on this file or
    there are still hard links to this node.

*name*
    is the name of this node within the filesystem hierarchical tree. Example:  If
    the fully qualified pathname to the ``jnode`` was ``/a/b/c``, the``jnode`` name field would contain the null terminated string ``"c"``.

*st_mode*
    is the standard Unix access permissions for the file or directory.

*st_nlink*
    is the number of hard links to this file. When a ``jnode`` is first created
    its link count is set to 1. A ``jnode`` and its associated resources
    cannot be deleted unless its link count is less than 1.

*st_ino*
    is a unique node identification number

*st_uid*
    is the user ID of the file's owner

*st_gid*
    is the group ID of the file's owner

*st_atime*
    is the time of the last access to this file

*st_mtime*
    is the time of the last modification of this file

*st_ctime*
    is the time of the last status change to the file

*type*
    is the indication of node type must be one of the following states:
    - IMFS_DIRECTORY
    - IMFS_MEMORY_FILE
    - IMFS_HARD_LINK
    - IMFS_SYM_LINK
    - IMFS_DEVICE

*info*
    is this contains a structure that is unique to file type (See IMFS_typs_union
    in imfs.h).

    - IMFS_DIRECTORY

      An IMFS directory contains a dynamic chain structure that
      records all files and directories that are subordinate to the directory node.

    - IMFS_MEMORY_FILE

      Under the in memory filesystem regular files hold data. Data is dynamically
      allocated to the file in 128 byte chunks of memory.  The individual chunks of
      memory are tracked by arrays of pointers that record the address of the
      allocated chunk of memory. Single, double, and triple indirection pointers
      are used to record the locations of all segments of the file.  The
      memory organization of an IMFS file are discussed elsewhere in this manual.

    - IMFS_HARD_LINK

      The IMFS filesystem supports the concept of hard links to other nodes in the
      IMFS filesystem.  These hard links are actual pointers to other nodes in the
      same filesystem. This type of link cannot cross-filesystem boundaries.

    - IMFS_SYM_LINK

      The IMFS filesystem supports the concept of symbolic links to other nodes in
      any filesystem. A symbolic link consists of a pointer to a character string
      that represents the pathname to the target node. This type of link can
      cross-filesystem boundaries.  Just as with most versions of UNIX supporting
      symbolic links, a symbolic link can point to a non-existent file.

    - IMFS_DEVICE

      All RTEMS devices now appear as files under the in memory filesystem. On
      system initialization, all devices are registered as nodes under the file
      system.

Miscellaneous IMFS Information
==============================

Memory associated with the IMFS
===============================

A memory based filesystem draws its resources for files and directories
from the memory resources of the system. When it is time to un-mount the
filesystem, the memory resources that supported filesystem are set free.
In order to free these resources, a recursive walk of the filesystems
tree structure will be performed. As the leaf nodes under the filesystem
are encountered their resources are freed. When directories are made empty
by this process, their resources are freed.

Node removal constraints for the IMFS
-------------------------------------

The IMFS conforms to the general filesystem requirements for node
removal.  See `File and Directory Removal Constraints`_.

IMFS General Housekeeping Notes
-------------------------------

The following is a list of odd housekeeping notes for the IMFS.

- If the global variable rtems_filesystem_current refers to the node that
  we are trying to remove, the node_access element of this structure must be
  set to NULL to invalidate it.

- If the node was of IMFS_MEMORY_FILE type, free the memory associated
  with the memory file before freeing the node. Use the IMFS_memfile_remove()
  function.

IMFS Operation Tables
=====================

IMFS Filesystem Handler Table Functions
---------------------------------------

OPS table functions are defined in a rtems_filesystem_operations_table
structure.  It defines functions that are specific to a given filesystem.
One table exists for each filesystem that is supported in the RTEMS
configuration. The structure definition appears below and is followed by
general developmental information on each of the functions contained in this
function management structure.
.. code:: c

    rtems_filesystem_operations_table  IMFS_ops = {
    IMFS_eval_path,
    IMFS_evaluate_for_make,
    IMFS_link,
    IMFS_unlink,
    IMFS_node_type,
    IMFS_mknod,
    IMFS_rmnod,
    IMFS_chown,
    IMFS_freenodinfo,
    IMFS_mount,
    IMFS_initialize,
    IMFS_unmount,
    IMFS_fsunmount,
    IMFS_utime,
    IMFS_evaluate_link,
    IMFS_symlink,
    IMFS_readlink
    };

.. COMMENT: @page

IMFS_evalpath()
~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

IMFS_evalformake()
~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

IMFS_link()
~~~~~~~~~~~

**Corresponding Structure Element:**

link

**Arguments:**

.. code:: c

    rtems_filesystem_location_info_t    \*to_loc,      /* IN \*/
    rtems_filesystem_location_info_t    \*parent_loc,  /* IN \*/
    const char                          \*token        /* IN \*/

**File:**

imfs_link.c

**Description:**

This routine is used in the IMFS filesystem to create a hard-link.

It will first examine the st_nlink count of the node that we are trying to.
If the link count exceeds LINK_MAX an error will be returned.

The name of the link will be normalized to remove extraneous separators from
the end of the name.

IMFS_create_node will be used to create a filesystem node that will have the
following characteristics:

- parent that was determined in the link() function in file link.c

- Type will be set to IMFS_HARD_LINK

- name will be set to the normalized name

- mode of the hard-link will be set to the mode of the target node

If there was trouble allocating memory for the new node an error will be
returned.

The st_nlink count of the target node will be incremented to reflect the new
link.

The time fields of the link will be set to reflect the creation time of the
hard-link.

.. COMMENT: @page

IMFS_unlink()
~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

IMFS_node_type()
~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_node_type()

**Arguments:**

.. code:: c

    rtems_filesystem_location_info_t    \*pathloc        /* IN \*/

**File:**

imfs_ntype.c

**Description:**

This routine will locate the IMFS_jnode_t structure that holds ownership
information for the selected node in the filesystem.

This structure is pointed to by pathloc->node_access.

The IMFS_jnode_t type element indicates one of the node types listed below:

- RTEMS_FILESYSTEM_DIRECTORY

- RTEMS_FILESYSTEM_DEVICE

- RTEMS_FILESYSTEM_HARD_LINK

- RTEMS_FILESYSTEM_MEMORY_FILE

.. COMMENT: @page

IMFS_mknod()
~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_mknod()

**Arguments:**

.. code:: c

    const char                          \*token,        /* IN \*/
    mode_t                               mode,         /* IN \*/
    dev_t                                dev,          /* IN \*/
    rtems_filesystem_location_info_t    \*pathloc       /* IN/OUT \*/

**File:**

imfs_mknod.c

**Description:**

This routine will examine the mode argument to determine is we are trying to
create a directory, regular file and a device node. The creation of other
node types is not permitted and will cause an assert.

Memory space will be allocated for a ``jnode`` and the node will be set up
according to the nodal type that was specified. The IMFS_create_node()
function performs the allocation and setup of the node.

The only problem that is currently reported is the lack of memory when we
attempt to allocate space for the ``jnode`` (ENOMEN).

.. COMMENT: @page

IMFS_rmnod()
~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

IMFS_chown()
~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_chown()

**Arguments:**

.. code:: c

    rtems_filesystem_location_info_t    \*pathloc        /* IN \*/
    uid_t                                owner          /* IN \*/
    gid_t                                group          /* IN \*/

**File:**

imfs_chown.c

**Description:**

This routine will locate the IMFS_jnode_t structure that holds ownership
information for the selected node in the filesystem.

This structure is pointed to by pathloc->node_access.

The st_uid and st_gid fields of the node are then modified. Since this is a
memory based filesystem, no further action is required to alter the
ownership of the IMFS_jnode_t structure.

.. COMMENT: @page

IMFS_freenod()
~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_freenod()

**Arguments:**

.. code:: c

    rtems_filesystem_location_info_t      \*pathloc       /* IN \*/

**File:**

imfs_free.c

**Description:**

This method is a private function to the IMFS.  It is called by IMFS routines
to free nodes that have been allocated.  Examples of where this routine
may be called from are unlink and rmnod.

Note:  This routine should not be confused with the filesystem callback
freenod.  The IMFS allocates memory until the node no longer exists.

.. COMMENT: @page

IMFS_freenodinfo()
~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_freenodinfo()

**Arguments:**

.. code:: c

    rtems_filesystem_location_info_t      \*pathloc       /* IN \*/

**File:**

imfs_free.c

**Description:**

The In-Memory File System does not need to allocate memory during the
evaluate routines. Therefore, this routine simply routines PASS.

.. COMMENT: @page

IMFS_mount()
~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_mount()

**Arguments:**

.. code:: c

    rtems_filesystem_mount_table_entry_t   \*mt_entry

**File:**

imfs_mount.c

**Description:**

This routine provides the filesystem specific processing required to mount a
filesystem for the system that contains the mount point. It will determine
if the point that we are trying to mount onto is a node of IMFS_DIRECTORY
type.

If it is the node's info element is altered so that the info.directory.mt_fs
element points to the mount table chain entry that is associated with the
mounted filesystem at this point. The info.directory.mt_fs element can be
examined to determine if a filesystem is mounted at a directory. If it is
NULL, the directory does not serve as a mount point. A non-NULL entry
indicates that the directory does serve as a mount point and the value of
info.directory.mt_fs can be used to locate the mount table chain entry that
describes the filesystem mounted at this point.

.. COMMENT: @page

IMFS_fsmount_me()
~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_initialize()

**Arguments:**

.. code:: c

    rtems_filesystem_mount_table_entry_t   \*mt_entry

**File:**

imfs_init.c

**Description:**

This function is provided with a filesystem to take care of the internal
filesystem management details associated with mounting that filesystem
under the RTEMS environment.

It is not responsible for the mounting details associated the filesystem
containing the mount point.

The rtems_filesystem_mount_table_entry_t structure contains the key elements
below:

rtems_filesystem_location_info_t         \*mt_point_node,

This structure contains information about the mount point. This
allows us to find the ops-table and the handling functions
associated with the filesystem containing the mount point.

rtems_filesystem_location_info_t         \*fs_root_node,

This structure contains information about the root node in the file
system to be mounted. It allows us to find the ops-table and the
handling functions associated with the filesystem to be mounted.

rtems_filesystem_options_t                 options,

Read only or read/write access

void                                         \*fs_info,

This points to an allocated block of memory the will be used to
hold any filesystem specific information of a global nature. This
allocated region if important because it allows us to mount the
same filesystem type more than once under the RTEMS system.
Each instance of the mounted filesystem has its own set of global
management information that is separate from the global
management information associated with the other instances of the
mounted filesystem type.

rtems_filesystem_limits_and_options_t    pathconf_info,

The table contains the following set of values associated with the
mounted filesystem:

- link_max

- max_canon

- max_input

- name_max

- path_max

- pipe_buf

- posix_async_io

- posix_chown_restrictions

- posix_no_trunc

- posix_prio_io

- posix_sync_io

- posix_vdisable

These values are accessed with the pathconf() and the fpathconf ()
functions.

const char                                   \*dev

The is intended to contain a string that identifies the device that contains
the filesystem information. The filesystems that are currently implemented
are memory based and don't require a device specification.

If the mt_point_node.node_access is NULL then we are mounting the base file
system.

The routine will create a directory node for the root of the IMFS file
system.

The node will have read, write and execute permissions for owner, group and
others.

The node's name will be a null string.

A filesystem information structure(fs_info) will be allocated and
initialized for the IMFS filesystem. The fs_info pointer in the mount table
entry will be set to point the filesystem information structure.

The pathconf_info element of the mount table will be set to the appropriate
table of path configuration constants ( IMFS_LIMITS_AND_OPTIONS ).

The fs_root_node structure will be filled in with the following:

- pointer to the allocated root node of the filesystem

- directory handlers for a directory node under the IMFS filesystem

- OPS table functions for the IMFS

A 0 will be returned to the calling routine if the process succeeded,
otherwise a 1 will be returned.

.. COMMENT: @page

IMFS_unmount()
~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_unmount()

**Arguments:**

.. code:: c

    rtems_filesystem_mount_table_entry_t   \*mt_entry

**File:**

imfs_unmount.c

**Description:**

This routine allows the IMFS to unmount a filesystem that has been
mounted onto a IMFS directory.

The mount entry mount point node access is verified to be a mounted
directory.  It's mt_fs is set to NULL.  This identifies to future
calles into the IMFS that this directory node is no longer a mount
point.  Additionally, it will allow any directories that were hidden
by the mounted system to again become visible.

.. COMMENT: @page

IMFS_fsunmount()
~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

imfs_fsunmount()

**Arguments:**

.. code:: c

    rtems_filesystem_mount_table_entry_t   \*mt_entry

**File:**

imfs_init.c

**Description:**

This method unmounts this instance of the IMFS file system.  It is the
counterpart to the IMFS_initialize routine.  It is called by the generic
code under the fsunmount_me callback.

All method loops finding the first encountered node with no children and
removing the node from the tree, thus returning allocated resources.  This
is done until all allocated nodes are returned.

.. COMMENT: @page

IMFS_utime()
~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

IMFS_eval_link()
~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

Regular File Handler Table Functions
------------------------------------

Handler table functions are defined in a rtems_filesystem_file_handlers_r
structure. It defines functions that are specific to a node type in a given
filesystem. One table exists for each of the filesystem's node types. The
structure definition appears below. It is followed by general developmental
information on each of the functions associated with regular files contained
in this function management structure.
.. code:: c

    rtems_filesystem_file_handlers_r IMFS_memfile_handlers = {
    memfile_open,
    memfile_close,
    memfile_read,
    memfile_write,
    memfile_ioctl,
    memfile_lseek,
    IMFS_stat,
    IMFS_fchmod,
    memfile_ftruncate,
    NULL,                /* fpathconf \*/
    NULL,                /* fsync \*/
    IMFS_fdatasync,
    IMFS_fcntl
    };

.. COMMENT: @page

memfile_open() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

memfile_open()

**Arguments:**

.. code:: c

    rtems_libio_t   \*iop,
    const char      \*pathname,
    unsigned32       flag,
    unsigned32       mode

**File:**

memfile.c

**Description:**

Currently this function is a shell. No meaningful processing is performed and
a success code is always returned.

.. COMMENT: @page

memfile_close() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

memfile_close()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop

**File:**

memfile.c

**Description:**

This routine is a dummy for regular files under the base filesystem. It
performs a capture of the IMFS_jnode_t pointer from the file control block
and then immediately returns a success status.

.. COMMENT: @page

memfile_read() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

memfile_read()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop,
    void              \*buffer,
    unsigned32         count

**File:**

memfile.c

**Description:**

This routine will determine the ``jnode`` that is associated with this file.

It will then call IMFS_memfile_read() with the ``jnode``, file position index,
buffer and transfer count as arguments.

IMFS_memfile_read() will do the following:

- Verify that the ``jnode`` is associated with a memory file

- Verify that the destination of the read is valid

- Adjust the length of the read if it is too long

- Acquire data from the memory blocks associated with the file

- Update the access time for the data in the file

.. COMMENT: @page

memfile_write() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

memfile_ioctl() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop,
    unsigned32       command,
    void              \*buffer

**File:**

memfile.c

**Description:**

The current code is a placeholder for future development. The routine returns
a successful completion status.

.. COMMENT: @page

memfile_lseek() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

Memfile_lseek()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop,
    off_t              offset,
    int                whence

**File:**

memfile.c

**Description:**

This routine make sure that the memory based file is sufficiently large to
allow for the new file position index.

The IMFS_memfile_extend() function is used to evaluate the current size of
the memory file and allocate additional memory blocks if required by the new
file position index. A success code is always returned from this routine.

.. COMMENT: @page

IMFS_stat() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_stat()

**Arguments:**

.. code:: c

    rtems_filesystem_location_info_t   \*loc,
    struct stat                        \*buf

**File:**

imfs_stat.c

**Description:**

This routine actually performs status processing for both devices and regular
files.

The IMFS_jnode_t structure is referenced to determine the type of node under
the filesystem.

If the node is associated with a device, node information is extracted and
transformed to set the st_dev element of the stat structure.

If the node is a regular file, the size of the regular file is extracted from
the node.

This routine rejects other node types.

The following information is extracted from the node and placed in the stat
structure:

- st_mode

- st_nlink

- st_ino

- st_uid

- st_gid

- st_atime

- st_mtime

- st_ctime

.. COMMENT: @page

IMFS_fchmod() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_fchmod()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop
    mode_t              mode

**File:**

imfs_fchmod.c

**Description:**

This routine will obtain the pointer to the IMFS_jnode_t structure from the
information currently in the file control block.

Based on configuration the routine will acquire the user ID from a call to
getuid()  or from the IMFS_jnode_t structure.

It then checks to see if we have the ownership rights to alter the mode of
the file.  If the caller does not, an error code is returned.

An additional test is performed to verify that the caller is not trying to
alter the nature of the node. If the caller is attempting to alter more than
the permissions associated with user group and other, an error is returned.

If all the preconditions are met, the user, group and other fields are set
based on the mode calling parameter.

.. COMMENT: @page

memfile_ftruncate() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

No pathconf() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

NULL

**Arguments:**

Not Implemented

**File:**

Not Implemented

**Description:**

Not Implemented

.. COMMENT: @page

No fsync() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

IMFS_fdatasync() for Regular Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

Directory Handler Table Functions
---------------------------------

Handler table functions are defined in a rtems_filesystem_file_handlers_r
structure. It defines functions that are specific to a node type in a given
filesystem. One table exists for each of the filesystem's node types. The
structure definition appears below. It is followed by general developmental
information on each of the functions associated with directories contained in
this function management structure.
.. code:: c

    rtems_filesystem_file_handlers_r IMFS_directory_handlers = {
    IMFS_dir_open,
    IMFS_dir_close,
    IMFS_dir_read,
    NULL,             /* write \*/
    NULL,             /* ioctl \*/
    IMFS_dir_lseek,
    IMFS_dir_fstat,
    IMFS_fchmod,
    NULL,             /* ftruncate \*/
    NULL,             /* fpathconf \*/
    NULL,             /* fsync \*/
    IMFS_fdatasync,
    IMFS_fcntl
    };

.. COMMENT: @page

IMFS_dir_open() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

imfs_dir_open()

**Arguments:**

.. code:: c

    rtems_libio_t  \*iop,
    const char     \*pathname,
    unsigned32      flag,
    unsigned32      mode

**File:**

imfs_directory.c

**Description:**

This routine will look into the file control block to find the ``jnode`` that
is associated with the directory.

The routine will verify that the node is a directory. If its not a directory
an error code will be returned.

If it is a directory, the offset in the file control block will be set to 0.
This allows us to start reading at the beginning of the directory.

.. COMMENT: @page

IMFS_dir_close() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

imfs_dir_close()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop

**File:**

imfs_directory.c

**Description:**

This routine is a dummy for directories under the base filesystem. It
immediately returns a success status.

.. COMMENT: @page

IMFS_dir_read() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

imfs_dir_read

**Arguments:**

.. code:: c

    rtems_libio_t  \*iop,
    void           \*buffer,
    unsigned32      count

**File:**

imfs_directory.c

**Description:**

This routine will read a fixed number of directory entries from the current
directory offset. The number of directory bytes read will be returned from
this routine.

.. COMMENT: @page

No write() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

No ioctl() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

ioctl

**Arguments:**

**File:**

Not supported

**Description:**

XXX

.. COMMENT: @page

IMFS_dir_lseek() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

imfs_dir_lseek()

**Arguments:**

.. code:: c

    rtems_libio_t      \*iop,
    off_t               offset,
    int                 whence

**File:**

imfs_directory.c

**Description:**

This routine alters the offset in the file control block.

No test is performed on the number of children under the current open
directory.  The imfs_dir_read() function protects against reads beyond the
current size to the directory by returning a 0 bytes transfered to the
calling programs whenever the file position index exceeds the last entry in
the open directory.

.. COMMENT: @page

IMFS_dir_fstat() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

imfs_dir_fstat()

**Arguments:**

.. code:: c

    rtems_filesystem_location_info_t   \*loc,
    struct stat                        \*buf

**File:**

imfs_directory.c

**Description:**

The node access information in the rtems_filesystem_location_info_t structure
is used to locate the appropriate IMFS_jnode_t structure. The following
information is taken from the IMFS_jnode_t structure and placed in the stat
structure:

- st_ino

- st_mode

- st_nlink

- st_uid

- st_gid

- st_atime

- st_mtime

- st_ctime

The st_size field is obtained by running through the chain of directory
entries and summing the sizes of the dirent structures associated with each
of the children of the directory.

.. COMMENT: @page

IMFS_fchmod() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_fchmod()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop
    mode_t             mode

**File:**

imfs_fchmod.c

**Description:**

This routine will obtain the pointer to the IMFS_jnode_t structure from the
information currently in the file control block.

Based on configuration the routine will acquire the user ID from a call to
getuid()  or from the IMFS_jnode_t structure.

It then checks to see if we have the ownership rights to alter the mode of
the file.  If the caller does not, an error code is returned.

An additional test is performed to verify that the caller is not trying to
alter the nature of the node. If the caller is attempting to alter more than
the permissions associated with user group and other, an error is returned.

If all the preconditions are met, the user, group and other fields are set
based on the mode calling parameter.

.. COMMENT: @page

No ftruncate() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

No fpathconf() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

fpathconf

**Arguments:**

Not Implemented

**File:**

Not Implemented

**Description:**

Not Implemented

.. COMMENT: @page

No fsync() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

IMFS_fdatasync() for Directories
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

Device Handler Table Functions
------------------------------

Handler table functions are defined in a rtems_filesystem_file_handlers_r
structure. It defines functions that are specific to a node type in a given
filesystem. One table exists for each of the filesystem's node types. The
structure definition appears below. It is followed by general developmental
information on each of the functions associated with devices contained in
this function management structure.
.. code:: c

    typedef struct {
    rtems_filesystem_open_t           open;
    rtems_filesystem_close_t          close;
    rtems_filesystem_read_t           read;
    rtems_filesystem_write_t          write;
    rtems_filesystem_ioctl_t          ioctl;
    rtems_filesystem_lseek_t          lseek;
    rtems_filesystem_fstat_t          fstat;
    rtems_filesystem_fchmod_t         fchmod;
    rtems_filesystem_ftruncate_t      ftruncate;
    rtems_filesystem_fpathconf_t      fpathconf;
    rtems_filesystem_fsync_t          fsync;
    rtems_filesystem_fdatasync_t      fdatasync;
    } rtems_filesystem_file_handlers_r;

.. COMMENT: @page

device_open() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

device_open()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop,
    const char        \*pathname,
    unsigned32         flag,
    unsigned32         mode

**File:**

deviceio.c

**Description:**

This routine will use the file control block to locate the node structure for
the device.

It will extract the major and minor device numbers from the ``jnode``.

The major and minor device numbers will be used to make a rtems_io_open()
function call to open the device driver. An argument list is sent to the
driver that contains the file control block, flags and mode information.

.. COMMENT: @page

device_close() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

device_close()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop

**File:**

deviceio.c

**Description:**

This routine extracts the major and minor device driver numbers from the
IMFS_jnode_t that is referenced in the file control block.

It also forms an argument list that contains the file control block.

A rtems_io_close() function call is made to close the device specified by the
major and minor device numbers.

.. COMMENT: @page

device_read() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

device_read()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop,
    void              \*buffer,
    unsigned32         count

**File:**

deviceio.c

**Description:**

This routine will extract the major and minor numbers for the device from the -
jnode- associated with the file descriptor.

A rtems_io_read() call will be made to the device driver associated with the file
descriptor. The major and minor device number will be sent as arguments as well
as an argument list consisting of:

- file control block

- file position index

- buffer pointer where the data read is to be placed

- count indicating the number of bytes that the program wishes to read
  from the device

- flags from the file control block

On return from the rtems_io_read() the number of bytes that were actually
read will be returned to the calling program.

.. COMMENT: @page

device_write() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

device_ioctl() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

ioctl

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop,
    unsigned32         command,
    void              \*buffer

**File:**

deviceio.c

**Description:**

This handler will obtain status information about a device.

The form of status is device dependent.

The rtems_io_control() function uses the major and minor number of the device
to obtain the status information.

rtems_io_control() requires an rtems_libio_ioctl_args_t argument list which
contains the file control block, device specific command and a buffer pointer
to return the device status information.

The device specific command should indicate the nature of the information
that is desired from the device.

After the rtems_io_control() is processed, the buffer should contain the
requested device information.

If the device information is not obtained properly a -1 will be returned to
the calling program, otherwise the ioctl_return value is returned.

.. COMMENT: @page

device_lseek() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

device_lseek()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop,
    off_t              offset,
    int                whence

**File:**

deviceio.c

**Description:**

At the present time this is a placeholder function. It always returns a
successful status.

.. COMMENT: @page

IMFS_stat() for Devices
~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_stat()

**Arguments:**

.. code:: c

    rtems_filesystem_location_info_t   \*loc,
    struct stat                        \*buf

**File:**

imfs_stat.c

**Description:**

This routine actually performs status processing for both devices and regular files.

The IMFS_jnode_t structure is referenced to determine the type of node under the
filesystem.

If the node is associated with a device, node information is extracted and
transformed to set the st_dev element of the stat structure.

If the node is a regular file, the size of the regular file is extracted from the node.

This routine rejects other node types.

The following information is extracted from the node and placed in the stat
structure:

- st_mode

- st_nlink

- st_ino

- st_uid

- st_gid

- st_atime

- st_mtime

- st_ctime

.. COMMENT: @page

IMFS_fchmod() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

IMFS_fchmod()

**Arguments:**

.. code:: c

    rtems_libio_t     \*iop
    mode_t             mode

**File:**

imfs_fchmod.c

**Description:**

This routine will obtain the pointer to the IMFS_jnode_t structure from the
information currently in the file control block.

Based on configuration the routine will acquire the user ID from a call to
getuid()  or from the IMFS_jnode_t structure.

It then checks to see if we have the ownership rights to alter the mode of
the file.  If the caller does not, an error code is returned.

An additional test is performed to verify that the caller is not trying to
alter the nature of the node. If the caller is attempting to alter more than
the permissions associated with user group and other, an error is returned.

If all the preconditions are met, the user, group and other fields are set
based on the mode calling parameter.

.. COMMENT: @page

No ftruncate() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

No fpathconf() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

fpathconf

**Arguments:**

Not Implemented

**File:**

Not Implemented

**Description:**

Not Implemented

.. COMMENT: @page

No fsync() for Devices
~~~~~~~~~~~~~~~~~~~~~~

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: @page

No fdatasync() for Devices
~~~~~~~~~~~~~~~~~~~~~~~~~~

Not Implemented

**Corresponding Structure Element:**

XXX

**Arguments:**

XXX

**File:**

XXX

**Description:**

XXX

.. COMMENT: COPYRIGHT (c) 1988-2002.

.. COMMENT: On-Line Applications Research Corporation (OAR).

.. COMMENT: All rights reserved.