µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
file-system.h
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ distribution.
3 * (https://github.com/micro-os-plus)
4 * Copyright (c) 2015-2023 Liviu Ionescu. All rights reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software
7 * for any purpose is hereby granted, under the terms of the MIT license.
8 *
9 * If a copy of the license was not distributed with this file, it can
10 * be obtained from https://opensource.org/licenses/mit/.
11 */
12
13#ifndef CMSIS_PLUS_POSIX_IO_FILE_SYSTEM_H_
14#define CMSIS_PLUS_POSIX_IO_FILE_SYSTEM_H_
15
16// ----------------------------------------------------------------------------
17
18#if defined(__cplusplus)
19
20// ----------------------------------------------------------------------------
21
22#if defined(OS_USE_OS_APP_CONFIG_H)
23#include <cmsis-plus/os-app-config.h>
24#endif
25
28
30
32
33#include <mutex>
34#include <cstdarg>
35#include <sys/stat.h>
36#include <utime.h>
37
38// ----------------------------------------------------------------------------
39
40#define FF_MOUNT_FLAGS_HAS_VOLUME (1)
41
42// ----------------------------------------------------------------------------
43
44#pragma GCC diagnostic push
45#if defined(__clang__)
46#pragma clang diagnostic ignored "-Wc++98-compat"
47#endif
48
49// ----------------------------------------------------------------------------
50
51namespace os
52{
53 namespace posix
54 {
55 // ------------------------------------------------------------------------
56
57 class io;
58 class file;
59 class directory;
60 class block_device;
61
62 class file_system_impl;
63
69 // ------------------------------------------------------------------------
70 // ----- Non-io, global file system functions -----
71 int
72 mkdir (const char* path, mode_t mode);
73
74 int
75 rmdir (const char* path);
76
77 void
78 sync (void);
79
80 // ------------------------------------------------------------------------
81 // ----- Non-io, file functions -----
82
83 int
84 chmod (const char* path, mode_t mode);
85
86 int
87 stat (const char* path, struct stat* buf);
88
89 int
90 truncate (const char* path, off_t length);
91
92 int
93 rename (const char* existing, const char* _new);
94
95 int
96 unlink (const char* path);
97
98 int
99 utime (const char* path, const /* struct */ utimbuf* times);
100
101 int
102 statvfs (const char* path, struct statvfs* buf);
103
109 directory*
110 opendir (const char* dirname);
111
116 // ========================================================================
122#pragma GCC diagnostic push
123#if defined(__clang__)
124#elif defined(__GNUC__)
125#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
126#pragma GCC diagnostic ignored "-Wsuggest-final-types"
127#endif
129 {
130 // ----------------------------------------------------------------------
131
136 friend int
137 mkdir (const char* path, mode_t mode);
138
139 friend int
140 rmdir (const char* path);
141
142 friend void
143 sync (void);
144
145 friend int
146 chmod (const char* path, mode_t mode);
147
148 friend int
149 stat (const char* path, struct stat* buf);
150
151 friend int
152 truncate (const char* path, off_t length);
153
154 friend int
155 rename (const char* existing, const char* _new);
156
157 friend int
158 unlink (const char* path);
159
160 friend int
161 utime (const char* path, const /* struct */ utimbuf* times);
162
163 friend int
164 statvfs (const char* path, struct statvfs* buf);
165
170 // ----------------------------------------------------------------------
176 public:
177
178 file_system (file_system_impl& impl, const char* name);
179
184 // The rule of five.
185 file_system (const file_system&) = delete;
186 file_system (file_system&&) = delete;
188 operator= (const file_system&) = delete;
190 operator= (file_system&&) = delete;
191
196 virtual
197 ~file_system ();
198
203 // ----------------------------------------------------------------------
209 public:
210
211 int
212 mkfs (int options, ...);
213
214 virtual int
215 vmkfs (int options, std::va_list args);
216
217 int
218 mount (const char* path = nullptr, unsigned int flags = 0, ...);
219
232 virtual int
233 vmount (const char* path, unsigned int flags, std::va_list args);
234
243 virtual int
244 umount (int unsigned flags = 0);
245
246 static file_system*
247 identify_mounted (const char** path1, const char** path2 = nullptr);
248
249 // ----------------------------------------------------------------------
250
251 file*
252 open (const char* path = nullptr, int oflag = 0, ...);
253
254 virtual file*
255 vopen (const char* path, int oflag, std::va_list args);
256
257 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/opendir.html
258 virtual directory*
259 opendir (const char* dirpath);
260
261 // ----------------------------------------------------------------------
262 // Also called from namespace friend functions.
263
264 virtual int
265 mkdir (const char* path, mode_t mode);
266
267 virtual int
268 rmdir (const char* path);
269
270 virtual void
271 sync (void);
272
273 virtual int
274 chmod (const char* path, mode_t mode);
275
276 virtual int
277 stat (const char* path, struct stat* buf);
278
279 virtual int
280 truncate (const char* path, off_t length);
281
282 virtual int
283 rename (const char* existing, const char* _new);
284
285 virtual int
286 unlink (const char* path);
287
288 virtual int
289 utime (const char* path, const /* struct */ utimbuf* times);
290
291 virtual int
292 statvfs (struct statvfs* buf);
293
294 public:
295
296 // ----------------------------------------------------------------------
297 // Support functions.
298
299 const char*
301
302 const char*
303 name (void) const;
304
305 void
306 add_deferred_file (file* fil);
307
308 void
310
312 utils::double_list_links, &file::deferred_links_>;
313
315 utils::double_list_links, &directory::deferred_links_>;
316
318 deferred_files_list (void);
319
322
323 // ----------------------------------------------------------------------
324
325 template<typename T>
326 T*
327 allocate_file (void);
328
329 template<typename T>
330 T*
331 allocate_directory (void);
332
333 template<typename T, typename L>
334 T*
335 allocate_file (L& locker);
336
337 template<typename T, typename L>
338 T*
339 allocate_directory (L& locker);
340
341 template<typename T>
342 void
343 deallocate_files (void);
344
345 template<typename T>
346 void
348
349 // ----------------------------------------------------------------------
350 // Support functions.
351
353 device (void) const;
354
356 impl (void) const;
357
362 // ----------------------------------------------------------------------
363 protected:
364
369 const char* name_ = nullptr;
370
371 file_system_impl& impl_;
372
373 deferred_files_list_t deferred_files_list_;
374
375 deferred_directories_list_t deferred_directories_list_;
376
377 const char* mounted_path_ = nullptr;
378
383 // ----------------------------------------------------------------------
384 public:
385
390 // Intrusive node used to link this file system to the
391 // mount manager list.
392 // Must be public. The constructor clears the pointers.
393 utils::double_list_links mount_manager_links_;
394
399 // ----------------------------------------------------------------------
400 protected:
401
406 // Statics.
407 using mounted_list = utils::intrusive_list<file_system,
408 utils::double_list_links, &file_system::mount_manager_links_>;
409 static mounted_list mounted_list__;
410
411 static file_system* mounted_root__;
412
416 };
417#pragma GCC diagnostic pop
418
419 // ========================================================================
420
422 {
423 // ----------------------------------------------------------------------
424
425 friend class file_system;
426
432 public:
433
435
440 // The rule of five.
441 file_system_impl (const file_system_impl&) = delete;
444 operator= (const file_system_impl&) = delete;
446 operator= (file_system_impl&&) = delete;
447
452 virtual
454
459 // ----------------------------------------------------------------------
465 public:
466
467 virtual int
468 do_vmkfs (int options, std::va_list args) = 0;
469
470 virtual int
471 do_vmount (unsigned int flags, std::va_list args) = 0;
472
473 virtual int
474 do_umount (unsigned int flags) = 0;
475
476 virtual file*
477 do_vopen (/* class */ file_system& fs, const char* path, int oflag,
478 std::va_list args) = 0;
479
480 virtual directory*
481 do_opendir (/* class */ file_system& fs, const char* dirname) = 0;
482
483 virtual int
484 do_mkdir (const char* path, mode_t mode) = 0;
485
486 virtual int
487 do_rmdir (const char* path) = 0;
488
489 virtual void
490 do_sync (void) = 0;
491
492 virtual int
493 do_chmod (const char* path, mode_t mode) = 0;
494
495 virtual int
496 do_stat (const char* path, struct stat* buf) = 0;
497
498 virtual int
499 do_truncate (const char* path, off_t length) = 0;
500
501 virtual int
502 do_rename (const char* existing, const char* _new) = 0;
503
504 virtual int
505 do_unlink (const char* path) = 0;
506
507 virtual int
508 do_utime (const char* path, const /* struct */ utimbuf* times) = 0;
509
510 virtual int
511 do_statvfs (struct statvfs* buf) = 0;
512
513 // ----------------------------------------------------------------------
514 // Support functions.
515
517 device (void) const;
518
523 // ----------------------------------------------------------------------
524 protected:
525
530 block_device& device_;
531
532 file_system* fs_ = nullptr;
533
537 };
538
539 // ========================================================================
540
541#pragma GCC diagnostic push
542#if defined(__clang__)
543#elif defined(__GNUC__)
544#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
545#pragma GCC diagnostic ignored "-Wsuggest-final-types"
546#endif
547 template<typename T>
549 {
550 // --------------------------------------------------------------------
551
552 public:
553
554 using value_type = T;
555
556 // --------------------------------------------------------------------
557
563 public:
564
565 template<typename ... Args>
567 Args&&... args);
568
573 // The rule of five.
577 operator= (const file_system_implementable&) = delete;
579 operator= (file_system_implementable&&) = delete;
580
585 virtual
586 ~file_system_implementable () override;
587
592 // --------------------------------------------------------------------
598 public:
599
600 // Support functions.
601
603 impl (void) const;
604
609 // --------------------------------------------------------------------
610 protected:
611
616 value_type impl_instance_;
617
621 };
622#pragma GCC diagnostic pop
623
624 // ========================================================================
625
626#pragma GCC diagnostic push
627#if defined(__clang__)
628#elif defined(__GNUC__)
629#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
630#pragma GCC diagnostic ignored "-Wsuggest-final-types"
631#endif
632 template<typename T, typename L>
634 {
635 // --------------------------------------------------------------------
636
637 public:
638
639 using value_type = T;
640 using lockable_type = L;
641
642 // --------------------------------------------------------------------
643
649 public:
650
651 template<typename ... Args>
653 lockable_type& locker, Args&&... args);
654
659 // The rule of five.
663 operator= (const file_system_lockable&) = delete;
665 operator= (file_system_lockable&&) = delete;
666
671 virtual
672 ~file_system_lockable () override;
673
678 // --------------------------------------------------------------------
684 public:
685
698 virtual int
699 vmount (const char* path, unsigned int flags, std::va_list args)
700 override;
701
710 virtual int
711 umount (int unsigned flags = 0) override;
712
713 // --------------------------------------------------------------------
714
715 virtual file*
716 vopen (const char* path, int oflag, std::va_list args) override;
717
718 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/opendir.html
719 virtual directory*
720 opendir (const char* dirpath) override;
721
722 // --------------------------------------------------------------------
723
724 virtual int
725 mkdir (const char* path, mode_t mode) override;
726
727 virtual int
728 rmdir (const char* path) override;
729
730 virtual void
731 sync (void) override;
732
733 virtual int
734 chmod (const char* path, mode_t mode) override;
735
736 virtual int
737 stat (const char* path, struct stat* buf) override;
738
739 virtual int
740 truncate (const char* path, off_t length) override;
741
742 virtual int
743 rename (const char* existing, const char* _new) override;
744
745 virtual int
746 unlink (const char* path) override;
747
748 virtual int
749 utime (const char* path, const /* struct */ utimbuf* times) override;
750
751 virtual int
752 statvfs (struct statvfs* buf) override;
753
754 // --------------------------------------------------------------------
755 // Support functions.
756
758 impl (void) const;
759
764 // --------------------------------------------------------------------
765 protected:
766
771 value_type impl_instance_;
772
776 };
777#pragma GCC diagnostic pop
778
779 // ==========================================================================
780 } /* namespace posix */
781} /* namespace os */
782
783// ===== Inline & template implementations ====================================
784
785namespace os
786{
787 namespace posix
788 {
789 // ========================================================================
790
791 inline const char*
792 file_system::name (void) const
793 {
794 return name_;
795 }
796
797#pragma GCC diagnostic push
798#if defined(__clang__)
799#elif defined(__GNUC__)
800#pragma GCC diagnostic ignored "-Wuseless-cast"
801#endif
802
803 inline file_system_impl&
804 file_system::impl (void) const
805 {
806 return static_cast<file_system_impl&> (impl_);
807 }
808
809#pragma GCC diagnostic pop
810
811 inline block_device&
813 {
814 return impl ().device ();
815 }
816
817 inline void
819 {
820 deferred_files_list_.link (*fil);
821 }
822
823 inline void
825 {
826 deferred_directories_list_.link (*dir);
827 }
828
831 {
832 return deferred_files_list_;
833 }
834
837 {
838 return deferred_directories_list_;
839 }
840
841 template<typename T>
842 T*
844 {
845 using file_type = T;
846
847 file_type* fil;
848
849 if (deferred_files_list_.empty ())
850 {
851 fil = new file_type (*this);
852 }
853 else
854 {
855 fil = static_cast<file_type*> (deferred_files_list_.unlink_head ());
856
857 // Call the constructor before reusing the object,
858 fil->~file_type ();
859
860 // Placement new, run only the constructor.
861 new (fil) file_type (*this);
862
863 deallocate_files<file_type> ();
864 }
865 return fil;
866 }
867
868 template<typename T, typename L>
869 T*
871 {
872 using file_type = T;
873
874 file_type* fil;
875
876 if (deferred_files_list_.empty ())
877 {
878 fil = new file_type (*this, locker);
879 }
880 else
881 {
882 fil = static_cast<file_type*> (deferred_files_list_.unlink_head ());
883
884 // Call the constructor before reusing the object,
885 fil->~file_type ();
886
887 // Placement new, run only the constructor.
888 new (fil) file_type (*this, locker);
889
890 deallocate_files<file_type> ();
891 }
892 return fil;
893 }
894
895 template<typename T>
896 void
898 {
899 using file_type = T;
900
901 // Deallocate all remaining elements in the list.
902 while (!deferred_files_list_.empty ())
903 {
904 file_type* f =
905 static_cast<file_type*> (deferred_files_list_.unlink_head ());
906
907 // Call the destructor and the deallocator.
908 delete f;
909 }
910 }
911
912 template<typename T>
913 T*
915 {
916 using directory_type = T;
917
918 directory_type* dir;
919
920 if (deferred_directories_list_.empty ())
921 {
922 dir = new directory_type (*this);
923 }
924 else
925 {
926 dir =
927 static_cast<directory_type*> (deferred_directories_list_.unlink_head ());
928
929 // Call the constructor before reusing the object,
930 dir->~directory_type ();
931
932 // Placement new, run only the constructor.
933 new (dir) directory_type (*this);
934
935 deallocate_directories<directory_type> ();
936 }
937 return dir;
938 }
939
940 template<typename T, typename L>
941 T*
943 {
944 using directory_type = T;
945
946 directory_type* dir;
947
948 if (deferred_directories_list_.empty ())
949 {
950 dir = new directory_type (*this, locker);
951 }
952 else
953 {
954 dir =
955 static_cast<directory_type*> (deferred_directories_list_.unlink_head ());
956
957 // Call the constructor before reusing the object,
958 dir->~directory_type ();
959
960 // Placement new, run only the constructor.
961 new (dir) directory_type (*this, locker);
962
963 deallocate_directories<directory_type> ();
964 }
965 return dir;
966 }
967
968 template<typename T>
969 void
971 {
972 using directory_type = T;
973
974 // Deallocate all remaining elements in the list.
975 while (!deferred_directories_list_.empty ())
976 {
977 directory_type* d =
978 static_cast<directory_type*> (deferred_directories_list_.unlink_head ());
979
980 // Call the destructor and the deallocator.
981 delete d;
982 }
983 }
984
985 // ========================================================================
986
987 inline block_device&
989 {
990 return device_;
991 }
992
993 // ========================================================================
994
995 template<typename T>
996 template<typename ... Args>
998 const char* name, block_device& device, Args&&... args) :
1000 { impl_instance_, name }, //
1001 impl_instance_
1002 { device, std::forward<Args>(args)... }
1003 {
1004#if defined(OS_TRACE_POSIX_IO_FILE_SYSTEM)
1005 trace::printf ("file_system_implementable::%s(\"%s\")=@%p\n",
1006 __func__, name_, this);
1007#endif
1008 }
1009
1010#pragma GCC diagnostic push
1011#if defined(__clang__)
1012#elif defined(__GNUC__)
1013#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
1014#endif
1015 template<typename T>
1017 {
1018#if defined(OS_TRACE_POSIX_IO_FILE_SYSTEM)
1019 trace::printf ("file_system_implementable::%s() @%p %s\n", __func__,
1020 this, name_);
1021#endif
1022 }
1023#pragma GCC diagnostic pop
1024
1025 template<typename T>
1028 {
1029 return static_cast<value_type&> (impl_);
1030 }
1031
1032 // ========================================================================
1033
1034 template<typename T, typename L>
1035 template<typename ... Args>
1038 lockable_type& locker,
1039 Args&&... args) :
1041 { impl_instance_, name }, //
1042 impl_instance_
1043 { device, locker, std::forward<Args>(args)... }
1044 {
1045#if defined(OS_TRACE_POSIX_IO_FILE_SYSTEM)
1046 trace::printf ("file_system_lockable::%s()=%p\n", __func__, this);
1047#endif
1048 }
1049
1050#pragma GCC diagnostic push
1051#if defined(__clang__)
1052#elif defined(__GNUC__)
1053#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
1054#endif
1055 template<typename T, typename L>
1057 {
1058#if defined(OS_TRACE_POSIX_IO_FILE_SYSTEM)
1059 trace::printf ("file_system_lockable::%s() @%p\n", __func__, this);
1060#endif
1061 }
1062#pragma GCC diagnostic pop
1063
1064 // ------------------------------------------------------------------------
1065
1066 template<typename T, typename L>
1067 int
1068 file_system_lockable<T, L>::vmount (const char* path, unsigned int flags,
1069 std::va_list args)
1070 {
1071 std::lock_guard<L> lock
1072 { impl_instance_.locker () };
1073
1074 return file_system::vmount (path, flags, args);
1075 }
1076
1082 template<typename T, typename L>
1083 int
1085 {
1086 std::lock_guard<L> lock
1087 { impl_instance_.locker () };
1088
1089 return file_system::umount (flags);
1090 }
1091
1092 // ------------------------------------------------------------------------
1093
1094 template<typename T, typename L>
1095 file*
1096 file_system_lockable<T, L>::vopen (const char* path, int oflag,
1097 std::va_list args)
1098 {
1099 std::lock_guard<L> lock
1100 { impl_instance_.locker () };
1101
1102 return file_system::vopen (path, oflag, args);
1103 }
1104
1105 template<typename T, typename L>
1106 directory*
1108 {
1109 std::lock_guard<L> lock
1110 { impl_instance_.locker () };
1111
1112 return file_system::opendir (dirpath);
1113 }
1114
1115 // ------------------------------------------------------------------------
1116
1117 template<typename T, typename L>
1118 int
1119 file_system_lockable<T, L>::mkdir (const char* path, mode_t mode)
1120 {
1121 std::lock_guard<L> lock
1122 { impl_instance_.locker () };
1123
1124 return file_system::mkdir (path, mode);
1125 }
1126
1127 template<typename T, typename L>
1128 int
1130 {
1131 std::lock_guard<L> lock
1132 { impl_instance_.locker () };
1133
1134 return file_system::rmdir (path);
1135 }
1136
1137 template<typename T, typename L>
1138 void
1140 {
1141 std::lock_guard<L> lock
1142 { impl_instance_.locker () };
1143
1144 return file_system::sync ();
1145 }
1146
1147 // ------------------------------------------------------------------------
1148
1149 template<typename T, typename L>
1150 int
1151 file_system_lockable<T, L>::chmod (const char* path, mode_t mode)
1152 {
1153 std::lock_guard<L> lock
1154 { impl_instance_.locker () };
1155
1156 return file_system::chmod (path, mode);
1157 }
1158
1159 template<typename T, typename L>
1160 int
1161 file_system_lockable<T, L>::stat (const char* path, struct stat* buf)
1162 {
1163 std::lock_guard<L> lock
1164 { impl_instance_.locker () };
1165
1166 return file_system::stat (path, buf);
1167 }
1168
1169 template<typename T, typename L>
1170 int
1171 file_system_lockable<T, L>::truncate (const char* path, off_t length)
1172 {
1173 std::lock_guard<L> lock
1174 { impl_instance_.locker () };
1175
1176 return file_system::truncate (path, length);
1177 }
1178
1179 template<typename T, typename L>
1180 int
1182 const char* _new)
1183 {
1184 std::lock_guard<L> lock
1185 { impl_instance_.locker () };
1186
1187 return file_system::rename (existing, _new);
1188 }
1189
1190 template<typename T, typename L>
1191 int
1193 {
1194 std::lock_guard<L> lock
1195 { impl_instance_.locker () };
1196
1197 return file_system::unlink (path);
1198 }
1199
1200 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html
1201 template<typename T, typename L>
1202 int
1204 const /* struct */ utimbuf* times)
1205 {
1206 std::lock_guard<L> lock
1207 { impl_instance_.locker () };
1208
1209 return file_system::utime (path, times);
1210 }
1211
1212 template<typename T, typename L>
1213 int
1215 {
1216 std::lock_guard<L> lock
1217 { impl_instance_.locker () };
1218
1219 return file_system::statvfs (buf);
1220 }
1221
1222 template<typename T, typename L>
1225 {
1226 return static_cast<value_type&> (impl_);
1227 }
1228
1229// ==========================================================================
1230 } /* namespace posix */
1231} /* namespace os */
1232
1233#pragma GCC diagnostic pop
1234
1235// ----------------------------------------------------------------------------
1236
1237#endif /* __cplusplus */
1238
1239// ----------------------------------------------------------------------------
1240
1241#endif /* CMSIS_PLUS_POSIX_IO_FILE_SYSTEM_H_ */
Block device class.
Base device class.
Definition device.h:68
Directory class.
Definition directory.h:76
virtual int do_rename(const char *existing, const char *_new)=0
virtual int do_mkdir(const char *path, mode_t mode)=0
virtual directory * do_opendir(file_system &fs, const char *dirname)=0
virtual int do_unlink(const char *path)=0
virtual int do_umount(unsigned int flags)=0
virtual void do_sync(void)=0
virtual int do_truncate(const char *path, off_t length)=0
virtual int do_vmkfs(int options, std::va_list args)=0
virtual int do_chmod(const char *path, mode_t mode)=0
block_device & device(void) const
virtual int do_vmount(unsigned int flags, std::va_list args)=0
virtual int do_utime(const char *path, const utimbuf *times)=0
virtual file * do_vopen(file_system &fs, const char *path, int oflag, std::va_list args)=0
virtual int do_stat(const char *path, struct stat *buf)=0
virtual int do_statvfs(struct statvfs *buf)=0
virtual int do_rmdir(const char *path)=0
value_type & impl(void) const
virtual ~file_system_implementable() override
file_system_implementable(const char *name, block_device &device, Args &&... args)
virtual file * vopen(const char *path, int oflag, std::va_list args) override
virtual directory * opendir(const char *dirpath) override
virtual int utime(const char *path, const utimbuf *times) override
virtual int vmount(const char *path, unsigned int flags, std::va_list args) override
Mount file system.
virtual void sync(void) override
value_type & impl(void) const
file_system_lockable(const char *name, block_device &device, lockable_type &locker, Args &&... args)
virtual int stat(const char *path, struct stat *buf) override
virtual int mkdir(const char *path, mode_t mode) override
virtual int unlink(const char *path) override
virtual int chmod(const char *path, mode_t mode) override
virtual ~file_system_lockable() override
virtual int umount(int unsigned flags=0) override
Unmount file system.
virtual int truncate(const char *path, off_t length) override
virtual int rename(const char *existing, const char *_new) override
virtual int statvfs(struct statvfs *buf) override
virtual int rmdir(const char *path) override
File system class.
int mount(const char *path=nullptr, unsigned int flags=0,...)
deferred_directories_list_t & deferred_directories_list(void)
virtual int truncate(const char *path, off_t length)
file * open(const char *path=nullptr, int oflag=0,...)
virtual int mkdir(const char *path, mode_t mode)
virtual int rename(const char *existing, const char *_new)
void add_deferred_directory(directory *dir)
virtual void sync(void)
block_device & device(void) const
virtual int unlink(const char *path)
virtual int statvfs(struct statvfs *buf)
virtual int utime(const char *path, const utimbuf *times)
virtual int stat(const char *path, struct stat *buf)
static file_system * identify_mounted(const char **path1, const char **path2=nullptr)
int mkfs(int options,...)
virtual int chmod(const char *path, mode_t mode)
virtual int vmount(const char *path, unsigned int flags, std::va_list args)
Mount file system.
virtual file * vopen(const char *path, int oflag, std::va_list args)
virtual int umount(int unsigned flags=0)
Unmount file system.
virtual int rmdir(const char *path)
deferred_files_list_t & deferred_files_list(void)
void add_deferred_file(file *fil)
const char * name(void) const
void deallocate_files(void)
file_system_impl & impl(void) const
const char * mounted_path(void)
virtual int vmkfs(int options, std::va_list args)
void deallocate_directories(void)
virtual directory * opendir(const char *dirpath)
File class.
Definition file.h:65
List of intrusive nodes.
Definition lists.h:705
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:60
clock_t times(struct tms *buf)
int utime(const char *path, const utimbuf *times)
int unlink(const char *path)
int rmdir(const char *path)
int rename(const char *existing, const char *_new)
int stat(const char *path, struct stat *buf)
int chmod(const char *path, mode_t mode)
int truncate(const char *path, off_t length)
void sync(void)
directory * opendir(const char *dirname)
Open directory.
int mkdir(const char *path, mode_t mode)
System namespace.