µ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++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2015-2025 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can
9 * be obtained from https://opensource.org/licenses/mit.
10 */
11
12#ifndef CMSIS_PLUS_POSIX_IO_FILE_SYSTEM_H_
13#define CMSIS_PLUS_POSIX_IO_FILE_SYSTEM_H_
14
15// ----------------------------------------------------------------------------
16
17#if defined(__cplusplus)
18
19// ----------------------------------------------------------------------------
20
21#if defined(OS_USE_OS_APP_CONFIG_H)
22#include <cmsis-plus/os-app-config.h>
23#endif
24
27
29
31
32#include <mutex>
33#include <cstdarg>
34#include <sys/stat.h>
35#include <utime.h>
36
37// ----------------------------------------------------------------------------
38
39#define FF_MOUNT_FLAGS_HAS_VOLUME (1)
40
41// ----------------------------------------------------------------------------
42
43#pragma GCC diagnostic push
44#if defined(__clang__)
45#pragma clang diagnostic ignored "-Wc++98-compat"
46#endif
47
48// ----------------------------------------------------------------------------
49
50namespace os
51{
52 namespace posix
53 {
54 // ------------------------------------------------------------------------
55
56 class io;
57 class file;
58 class directory;
59 class block_device;
60
61 class file_system_impl;
62
68 // ------------------------------------------------------------------------
69 // ----- Non-io, global file system functions -----
70 int
71 mkdir (const char* path, mode_t mode);
72
73 int
74 rmdir (const char* path);
75
76 void
77 sync (void);
78
79 // ------------------------------------------------------------------------
80 // ----- Non-io, file functions -----
81
82 int
83 chmod (const char* path, mode_t mode);
84
85 int
86 stat (const char* path, struct stat* buf);
87
88 int
89 truncate (const char* path, off_t length);
90
91 int
92 rename (const char* existing, const char* _new);
93
94 int
95 unlink (const char* path);
96
97 int
98 utime (const char* path, const /* struct */ utimbuf* times);
99
100 int
101 statvfs (const char* path, struct statvfs* buf);
102
108 directory*
109 opendir (const char* dirname);
110
115 // ========================================================================
121#pragma GCC diagnostic push
122#if defined(__clang__)
123#elif defined(__GNUC__)
124#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
125#pragma GCC diagnostic ignored "-Wsuggest-final-types"
126#endif
128 {
129 // ----------------------------------------------------------------------
130
135 friend int
136 mkdir (const char* path, mode_t mode);
137
138 friend int
139 rmdir (const char* path);
140
141 friend void
142 sync (void);
143
144 friend int
145 chmod (const char* path, mode_t mode);
146
147 friend int
148 stat (const char* path, struct stat* buf);
149
150 friend int
151 truncate (const char* path, off_t length);
152
153 friend int
154 rename (const char* existing, const char* _new);
155
156 friend int
157 unlink (const char* path);
158
159 friend int
160 utime (const char* path, const /* struct */ utimbuf* times);
161
162 friend int
163 statvfs (const char* path, struct statvfs* buf);
164
169 // ----------------------------------------------------------------------
175 public:
176 file_system (file_system_impl& impl, const char* name);
177
182 // The rule of five.
183 file_system (const file_system&) = delete;
184 file_system (file_system&&) = delete;
186 operator= (const file_system&)
187 = delete;
189 operator= (file_system&&)
190 = delete;
191
196 virtual ~file_system ();
197
202 // ----------------------------------------------------------------------
208 public:
209 int
210 mkfs (int options, ...);
211
212 virtual int
213 vmkfs (int options, std::va_list args);
214
215 int
216 mount (const char* path = nullptr, unsigned int flags = 0, ...);
217
230 virtual int
231 vmount (const char* path, unsigned int flags, std::va_list args);
232
241 virtual int
242 umount (int unsigned flags = 0);
243
244 static file_system*
245 identify_mounted (const char** path1, const char** path2 = nullptr);
246
247 // ----------------------------------------------------------------------
248
249 file*
250 open (const char* path = nullptr, int oflag = 0, ...);
251
252 virtual file*
253 vopen (const char* path, int oflag, std::va_list args);
254
255 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/opendir.html
256 virtual directory*
257 opendir (const char* dirpath);
258
259 // ----------------------------------------------------------------------
260 // Also called from namespace friend functions.
261
262 virtual int
263 mkdir (const char* path, mode_t mode);
264
265 virtual int
266 rmdir (const char* path);
267
268 virtual void
269 sync (void);
270
271 virtual int
272 chmod (const char* path, mode_t mode);
273
274 virtual int
275 stat (const char* path, struct stat* buf);
276
277 virtual int
278 truncate (const char* path, off_t length);
279
280 virtual int
281 rename (const char* existing, const char* _new);
282
283 virtual int
284 unlink (const char* path);
285
286 virtual int
287 utime (const char* path, const /* struct */ utimbuf* times);
288
289 virtual int
290 statvfs (struct statvfs* buf);
291
292 public:
293 // ----------------------------------------------------------------------
294 // Support functions.
295
296 const char*
298
299 const char*
300 name (void) const;
301
302 void
303 add_deferred_file (file* fil);
304
305 void
307
310 &file::deferred_links_>;
311
314 &directory::deferred_links_>;
315
317 deferred_files_list (void);
318
321
322 // ----------------------------------------------------------------------
323
324 template <typename T>
325 T*
326 allocate_file (void);
327
328 template <typename T>
329 T*
330 allocate_directory (void);
331
332 template <typename T, typename L>
333 T*
334 allocate_file (L& locker);
335
336 template <typename T, typename L>
337 T*
338 allocate_directory (L& locker);
339
340 template <typename T>
341 void
342 deallocate_files (void);
343
344 template <typename T>
345 void
347
348 // ----------------------------------------------------------------------
349 // Support functions.
350
352 device (void) const;
353
355 impl (void) const;
356
361 // ----------------------------------------------------------------------
362 protected:
367 const char* name_ = nullptr;
368
369 file_system_impl& impl_;
370
371 deferred_files_list_t deferred_files_list_;
372
373 deferred_directories_list_t deferred_directories_list_;
374
375 const char* mounted_path_ = nullptr;
376
381 // ----------------------------------------------------------------------
382 public:
387 // Intrusive node used to link this file system to the
388 // mount manager list.
389 // Must be public. The constructor clears the pointers.
390 utils::double_list_links mount_manager_links_;
391
396 // ----------------------------------------------------------------------
397 protected:
402 // Statics.
403 using mounted_list
405 &file_system::mount_manager_links_>;
406 static mounted_list mounted_list__;
407
408 static file_system* mounted_root__;
409
413 };
414#pragma GCC diagnostic pop
415
416 // ========================================================================
417
419 {
420 // ----------------------------------------------------------------------
421
422 friend class file_system;
423
429 public:
431
436 // The rule of five.
437 file_system_impl (const file_system_impl&) = delete;
440 operator= (const file_system_impl&)
441 = delete;
443 operator= (file_system_impl&&)
444 = delete;
445
450 virtual ~file_system_impl ();
451
456 // ----------------------------------------------------------------------
462 public:
463 virtual int
464 do_vmkfs (int options, std::va_list args)
465 = 0;
466
467 virtual int
468 do_vmount (unsigned int flags, std::va_list args)
469 = 0;
470
471 virtual int
472 do_umount (unsigned int flags)
473 = 0;
474
475 virtual file*
476 do_vopen (/* class */ file_system& fs, const char* path, int oflag,
477 std::va_list args)
478 = 0;
479
480 virtual directory*
481 do_opendir (/* class */ file_system& fs, const char* dirname)
482 = 0;
483
484 virtual int
485 do_mkdir (const char* path, mode_t mode)
486 = 0;
487
488 virtual int
489 do_rmdir (const char* path)
490 = 0;
491
492 virtual void
493 do_sync (void)
494 = 0;
495
496 virtual int
497 do_chmod (const char* path, mode_t mode)
498 = 0;
499
500 virtual int
501 do_stat (const char* path, struct stat* buf)
502 = 0;
503
504 virtual int
505 do_truncate (const char* path, off_t length)
506 = 0;
507
508 virtual int
509 do_rename (const char* existing, const char* _new)
510 = 0;
511
512 virtual int
513 do_unlink (const char* path)
514 = 0;
515
516 virtual int
517 do_utime (const char* path, const /* struct */ utimbuf* times)
518 = 0;
519
520 virtual int
521 do_statvfs (struct statvfs* buf)
522 = 0;
523
524 // ----------------------------------------------------------------------
525 // Support functions.
526
528 device (void) const;
529
534 // ----------------------------------------------------------------------
535 protected:
540 block_device& device_;
541
542 file_system* fs_ = nullptr;
543
547 };
548
549 // ========================================================================
550
551#pragma GCC diagnostic push
552#if defined(__clang__)
553#elif defined(__GNUC__)
554#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
555#pragma GCC diagnostic ignored "-Wsuggest-final-types"
556#endif
557 template <typename T>
559 {
560 // ----------------------------------------------------------------------
561
562 public:
563 using value_type = T;
564
565 // ----------------------------------------------------------------------
566
572 public:
573 template <typename... Args>
575 Args&&... args);
576
581 // The rule of five.
585 operator= (const file_system_implementable&)
586 = delete;
588 operator= (file_system_implementable&&)
589 = delete;
590
595 virtual ~file_system_implementable () override;
596
601 // ----------------------------------------------------------------------
607 public:
608 // Support functions.
609
611 impl (void) const;
612
617 // ----------------------------------------------------------------------
618 protected:
623 value_type impl_instance_;
624
628 };
629#pragma GCC diagnostic pop
630
631 // ========================================================================
632
633#pragma GCC diagnostic push
634#if defined(__clang__)
635#elif defined(__GNUC__)
636#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
637#pragma GCC diagnostic ignored "-Wsuggest-final-types"
638#endif
639 template <typename T, typename L>
641 {
642 // ----------------------------------------------------------------------
643
644 public:
645 using value_type = T;
646 using lockable_type = L;
647
648 // ----------------------------------------------------------------------
649
655 public:
656 template <typename... Args>
658 lockable_type& locker, Args&&... args);
659
664 // The rule of five.
668 operator= (const file_system_lockable&)
669 = delete;
671 operator= (file_system_lockable&&)
672 = delete;
673
678 virtual ~file_system_lockable () override;
679
684 // ----------------------------------------------------------------------
690 public:
703 virtual int
704 vmount (const char* path, unsigned int flags,
705 std::va_list args) override;
706
715 virtual int
716 umount (int unsigned flags = 0) override;
717
718 // ----------------------------------------------------------------------
719
720 virtual file*
721 vopen (const char* path, int oflag, std::va_list args) override;
722
723 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/opendir.html
724 virtual directory*
725 opendir (const char* dirpath) override;
726
727 // ----------------------------------------------------------------------
728
729 virtual int
730 mkdir (const char* path, mode_t mode) override;
731
732 virtual int
733 rmdir (const char* path) override;
734
735 virtual void
736 sync (void) override;
737
738 virtual int
739 chmod (const char* path, mode_t mode) override;
740
741 virtual int
742 stat (const char* path, struct stat* buf) override;
743
744 virtual int
745 truncate (const char* path, off_t length) override;
746
747 virtual int
748 rename (const char* existing, const char* _new) override;
749
750 virtual int
751 unlink (const char* path) override;
752
753 virtual int
754 utime (const char* path, const /* struct */ utimbuf* times) override;
755
756 virtual int
757 statvfs (struct statvfs* buf) override;
758
759 // ----------------------------------------------------------------------
760 // Support functions.
761
763 impl (void) const;
764
769 // ----------------------------------------------------------------------
770 protected:
775 value_type impl_instance_;
776
780 };
781#pragma GCC diagnostic pop
782
783 // ========================================================================
784 } /* namespace posix */
785} /* namespace os */
786
787// ===== Inline & template implementations ====================================
788
789namespace os
790{
791 namespace posix
792 {
793 // ========================================================================
794
795 inline const char*
796 file_system::name (void) const
797 {
798 return name_;
799 }
800
801#pragma GCC diagnostic push
802#if defined(__clang__)
803#elif defined(__GNUC__)
804#pragma GCC diagnostic ignored "-Wuseless-cast"
805#endif
806
807 inline file_system_impl&
808 file_system::impl (void) const
809 {
810 return static_cast<file_system_impl&> (impl_);
811 }
812
813#pragma GCC diagnostic pop
814
815 inline block_device&
817 {
818 return impl ().device ();
819 }
820
821 inline void
823 {
824 deferred_files_list_.link (*fil);
825 }
826
827 inline void
829 {
830 deferred_directories_list_.link (*dir);
831 }
832
835 {
836 return deferred_files_list_;
837 }
838
841 {
842 return deferred_directories_list_;
843 }
844
845 template <typename T>
846 T*
848 {
849 using file_type = T;
850
851 file_type* fil;
852
853 if (deferred_files_list_.empty ())
854 {
855 fil = new file_type (*this);
856 }
857 else
858 {
859 fil = static_cast<file_type*> (deferred_files_list_.unlink_head ());
860
861 // Call the constructor before reusing the object,
862 fil->~file_type ();
863
864 // Placement new, run only the constructor.
865 new (fil) file_type (*this);
866
867 deallocate_files<file_type> ();
868 }
869 return fil;
870 }
871
872 template <typename T, typename L>
873 T*
875 {
876 using file_type = T;
877
878 file_type* fil;
879
880 if (deferred_files_list_.empty ())
881 {
882 fil = new file_type (*this, locker);
883 }
884 else
885 {
886 fil = static_cast<file_type*> (deferred_files_list_.unlink_head ());
887
888 // Call the constructor before reusing the object,
889 fil->~file_type ();
890
891 // Placement new, run only the constructor.
892 new (fil) file_type (*this, locker);
893
894 deallocate_files<file_type> ();
895 }
896 return fil;
897 }
898
899 template <typename T>
900 void
902 {
903 using file_type = T;
904
905 // Deallocate all remaining elements in the list.
906 while (!deferred_files_list_.empty ())
907 {
908 file_type* f
909 = static_cast<file_type*> (deferred_files_list_.unlink_head ());
910
911 // Call the destructor and the deallocator.
912 delete f;
913 }
914 }
915
916 template <typename T>
917 T*
919 {
920 using directory_type = T;
921
922 directory_type* dir;
923
924 if (deferred_directories_list_.empty ())
925 {
926 dir = new directory_type (*this);
927 }
928 else
929 {
930 dir = static_cast<directory_type*> (
931 deferred_directories_list_.unlink_head ());
932
933 // Call the constructor before reusing the object,
934 dir->~directory_type ();
935
936 // Placement new, run only the constructor.
937 new (dir) directory_type (*this);
938
939 deallocate_directories<directory_type> ();
940 }
941 return dir;
942 }
943
944 template <typename T, typename L>
945 T*
947 {
948 using directory_type = T;
949
950 directory_type* dir;
951
952 if (deferred_directories_list_.empty ())
953 {
954 dir = new directory_type (*this, locker);
955 }
956 else
957 {
958 dir = static_cast<directory_type*> (
959 deferred_directories_list_.unlink_head ());
960
961 // Call the constructor before reusing the object,
962 dir->~directory_type ();
963
964 // Placement new, run only the constructor.
965 new (dir) directory_type (*this, locker);
966
967 deallocate_directories<directory_type> ();
968 }
969 return dir;
970 }
971
972 template <typename T>
973 void
975 {
976 using directory_type = T;
977
978 // Deallocate all remaining elements in the list.
979 while (!deferred_directories_list_.empty ())
980 {
981 directory_type* d = static_cast<directory_type*> (
982 deferred_directories_list_.unlink_head ());
983
984 // Call the destructor and the deallocator.
985 delete d;
986 }
987 }
988
989 // ========================================================================
990
991 inline block_device&
993 {
994 return device_;
995 }
996
997 // ========================================================================
998
999 template <typename T>
1000 template <typename... Args>
1002 const char* name, block_device& device, Args&&... args)
1003 : file_system{ impl_instance_, name }, //
1004 impl_instance_{ device, std::forward<Args> (args)... }
1005 {
1006#if defined(OS_TRACE_POSIX_IO_FILE_SYSTEM)
1007 trace::printf ("file_system_implementable::%s(\"%s\")=@%p\n", __func__,
1008 name_, this);
1009#endif
1010 }
1011
1012#pragma GCC diagnostic push
1013#if defined(__clang__)
1014#elif defined(__GNUC__)
1015#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
1016#endif
1017 template <typename T>
1019 {
1020#if defined(OS_TRACE_POSIX_IO_FILE_SYSTEM)
1021 trace::printf ("file_system_implementable::%s() @%p %s\n", __func__,
1022 this, name_);
1023#endif
1024 }
1025#pragma GCC diagnostic pop
1026
1027 template <typename T>
1030 {
1031 return static_cast<value_type&> (impl_);
1032 }
1033
1034 // ========================================================================
1035
1036 template <typename T, typename L>
1037 template <typename... Args>
1040 lockable_type& locker,
1041 Args&&... args)
1042 : file_system{ impl_instance_, name }, //
1043 impl_instance_{ 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{ impl_instance_.locker () };
1072
1073 return file_system::vmount (path, flags, args);
1074 }
1075
1081 template <typename T, typename L>
1082 int
1084 {
1085 std::lock_guard<L> lock{ impl_instance_.locker () };
1086
1087 return file_system::umount (flags);
1088 }
1089
1090 // ------------------------------------------------------------------------
1091
1092 template <typename T, typename L>
1093 file*
1094 file_system_lockable<T, L>::vopen (const char* path, int oflag,
1095 std::va_list args)
1096 {
1097 std::lock_guard<L> lock{ impl_instance_.locker () };
1098
1099 return file_system::vopen (path, oflag, args);
1100 }
1101
1102 template <typename T, typename L>
1103 directory*
1105 {
1106 std::lock_guard<L> lock{ impl_instance_.locker () };
1107
1108 return file_system::opendir (dirpath);
1109 }
1110
1111 // ------------------------------------------------------------------------
1112
1113 template <typename T, typename L>
1114 int
1115 file_system_lockable<T, L>::mkdir (const char* path, mode_t mode)
1116 {
1117 std::lock_guard<L> lock{ impl_instance_.locker () };
1118
1119 return file_system::mkdir (path, mode);
1120 }
1121
1122 template <typename T, typename L>
1123 int
1125 {
1126 std::lock_guard<L> lock{ impl_instance_.locker () };
1127
1128 return file_system::rmdir (path);
1129 }
1130
1131 template <typename T, typename L>
1132 void
1134 {
1135 std::lock_guard<L> lock{ impl_instance_.locker () };
1136
1137 return file_system::sync ();
1138 }
1139
1140 // ------------------------------------------------------------------------
1141
1142 template <typename T, typename L>
1143 int
1144 file_system_lockable<T, L>::chmod (const char* path, mode_t mode)
1145 {
1146 std::lock_guard<L> lock{ impl_instance_.locker () };
1147
1148 return file_system::chmod (path, mode);
1149 }
1150
1151 template <typename T, typename L>
1152 int
1153 file_system_lockable<T, L>::stat (const char* path, struct stat* buf)
1154 {
1155 std::lock_guard<L> lock{ impl_instance_.locker () };
1156
1157 return file_system::stat (path, buf);
1158 }
1159
1160 template <typename T, typename L>
1161 int
1162 file_system_lockable<T, L>::truncate (const char* path, off_t length)
1163 {
1164 std::lock_guard<L> lock{ impl_instance_.locker () };
1165
1166 return file_system::truncate (path, length);
1167 }
1168
1169 template <typename T, typename L>
1170 int
1171 file_system_lockable<T, L>::rename (const char* existing, const char* _new)
1172 {
1173 std::lock_guard<L> lock{ impl_instance_.locker () };
1174
1175 return file_system::rename (existing, _new);
1176 }
1177
1178 template <typename T, typename L>
1179 int
1181 {
1182 std::lock_guard<L> lock{ impl_instance_.locker () };
1183
1184 return file_system::unlink (path);
1185 }
1186
1187 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html
1188 template <typename T, typename L>
1189 int
1191 const /* struct */ utimbuf* times)
1192 {
1193 std::lock_guard<L> lock{ impl_instance_.locker () };
1194
1195 return file_system::utime (path, times);
1196 }
1197
1198 template <typename T, typename L>
1199 int
1201 {
1202 std::lock_guard<L> lock{ impl_instance_.locker () };
1203
1204 return file_system::statvfs (buf);
1205 }
1206
1207 template <typename T, typename L>
1210 {
1211 return static_cast<value_type&> (impl_);
1212 }
1213
1214 // ========================================================================
1215 } /* namespace posix */
1216} /* namespace os */
1217
1218#pragma GCC diagnostic pop
1219
1220// ----------------------------------------------------------------------------
1221
1222#endif /* __cplusplus */
1223
1224// ----------------------------------------------------------------------------
1225
1226#endif /* CMSIS_PLUS_POSIX_IO_FILE_SYSTEM_H_ */
Block device class.
Base device class.
Definition device.h:67
Directory class.
Definition directory.h:75
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:64
List of intrusive nodes.
Definition lists.h:690
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59
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.
Standard std namespace.