Components/IFS/src/include/IFS/Gdb/FileSystem.h
Go to the documentation of this file.
1 /****
2  * FileSystem.h
3  * IFS wrapper for GDB syscall file access
4  *
5  * Created on: 1 December 2020
6  *
7  * Copyright 2019 mikee47 <mike@sillyhouse.net>
8  *
9  * This file is part of the IFS Library
10  *
11  * This library is free software: you can redistribute it and/or modify it under the terms of the
12  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with this library.
19  * If not, see <https://www.gnu.org/licenses/>.
20  *
21  ****/
22 
23 #pragma once
24 
25 #include "../IFileSystem.h"
26 
27 namespace IFS
28 {
29 namespace Gdb
30 {
34 class FileSystem : public IFileSystem
35 {
36 public:
38  {
39  }
40 
41  ~FileSystem() override
42  {
43  }
44 
45  int mount() override
46  {
47  return FS_OK;
48  }
49 
50  // IFileSystem methods
51  int getinfo(Info& info) override;
52  String getErrorString(int err) override;
53  int opendir(const char* path, DirHandle& dir) override
54  {
55  return Error::NotSupported;
56  }
57  int rewinddir(DirHandle dir) override
58  {
59  return Error::NotSupported;
60  }
61  int readdir(DirHandle dir, Stat& stat) override
62  {
63  return Error::NotSupported;
64  }
65  int closedir(DirHandle dir) override
66  {
67  return Error::NotSupported;
68  }
69  int mkdir(const char* path) override
70  {
71  return Error::NotSupported;
72  }
73  int stat(const char* path, Stat* stat) override;
74  int fstat(FileHandle file, Stat* stat) override;
75  int fsetxattr(FileHandle file, AttributeTag tag, const void* data, size_t size) override
76  {
77  return Error::NotSupported;
78  }
79  int fgetxattr(FileHandle file, AttributeTag tag, void* buffer, size_t size) override
80  {
81  return Error::NotSupported;
82  }
83  int fenumxattr(FileHandle file, AttributeEnumCallback callback, void* buffer, size_t bufsize) override
84  {
85  return Error::NotSupported;
86  }
87  int setxattr(const char* path, AttributeTag tag, const void* data, size_t size) override
88  {
89  return Error::NotSupported;
90  }
91  int getxattr(const char* path, AttributeTag tag, void* buffer, size_t size) override
92  {
93  return Error::NotSupported;
94  }
95  FileHandle open(const char* path, OpenFlags flags) override;
96  int close(FileHandle file) override;
97  int read(FileHandle file, void* data, size_t size) override;
98  int write(FileHandle file, const void* data, size_t size) override;
99  file_offset_t lseek(FileHandle file, file_offset_t offset, SeekOrigin origin) override;
100  int eof(FileHandle file) override;
101  file_offset_t tell(FileHandle file) override;
102  int ftruncate(FileHandle file, file_size_t new_size) override
103  {
104  return Error::NotSupported;
105  }
106  int flush(FileHandle file) override
107  {
108  return Error::NotSupported;
109  }
110  int rename(const char* oldpath, const char* newpath) override;
111  int remove(const char* path) override;
112  int fremove(FileHandle file) override
113  {
114  return Error::NotImplemented;
115  }
116  int format() override
117  {
118  return Error::NotSupported;
119  }
120  int check() override
121  {
122  return FS_OK;
123  }
124 };
125 
126 } // namespace Gdb
127 } // namespace IFS
int32_t file_offset_t
Definition: Components/IFS/src/include/IFS/Types.h:51
uint32_t file_size_t
Definition: Components/IFS/src/include/IFS/Types.h:50
SeekOrigin
Stream/file seek origins.
Definition: SeekOrigin.h:18
Manage a set of bit values using enumeration.
Definition: BitSet.h:45
Definition: Delegate.h:20
IFS implementation of Host filing system.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:35
int rewinddir(DirHandle dir) override
Reset directory read position to start.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:57
int getinfo(Info &info) override
get filing system information
int stat(const char *path, Stat *stat) override
get file information
int fstat(FileHandle file, Stat *stat) override
get file information
FileHandle open(const char *path, OpenFlags flags) override
open a file (or directory) by path
String getErrorString(int err) override
get the text for a returned error code
int setxattr(const char *path, AttributeTag tag, const void *data, size_t size) override
Set an extended attribute for a file given its path.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:87
int format() override
format the filing system
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:116
int check() override
Perform a file system consistency check.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:120
int getxattr(const char *path, AttributeTag tag, void *buffer, size_t size) override
Get an attribute from a file given its path.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:91
int readdir(DirHandle dir, Stat &stat) override
read a directory entry
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:61
int fremove(FileHandle file) override
remove (delete) a file by handle
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:112
int closedir(DirHandle dir) override
close a directory object
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:65
int fenumxattr(FileHandle file, AttributeEnumCallback callback, void *buffer, size_t bufsize) override
Enumerate attributes.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:83
FileSystem()
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:37
int write(FileHandle file, const void *data, size_t size) override
write content to a file at current position and advance cursor
int flush(FileHandle file) override
flush any buffered data to physical media
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:106
int ftruncate(FileHandle file, file_size_t new_size) override
Truncate (reduce) the size of an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:102
int close(FileHandle file) override
close an open file
int opendir(const char *path, DirHandle &dir) override
open a directory for reading
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:53
int read(FileHandle file, void *data, size_t size) override
read content from a file and advance cursor
~FileSystem() override
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:41
int fgetxattr(FileHandle file, AttributeTag tag, void *buffer, size_t size) override
Get an extended attribute from an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:79
int remove(const char *path) override
remove (delete) a file by path
file_offset_t lseek(FileHandle file, file_offset_t offset, SeekOrigin origin) override
change file read/write position
int rename(const char *oldpath, const char *newpath) override
rename a file
int fsetxattr(FileHandle file, AttributeTag tag, const void *data, size_t size) override
Set an extended attribute on an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:75
int eof(FileHandle file) override
determine if current file position is at end of file
int mount() override
Mount file system, performing any required initialisation.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:45
int mkdir(const char *path) override
Create a directory.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:69
file_offset_t tell(FileHandle file) override
get current file position
Installable File System base class.
Definition: IFileSystem.h:100
The String class.
Definition: WString.h:137
constexpr ErrorCode FS_OK
Definition: Components/IFS/src/include/IFS/Error.h:130
Definition: DirectoryTemplate.h:37
struct ImplFileDir * DirHandle
Definition: IFileSystem.h:72
AttributeTag
Identifies a specific attribute.
Definition: Attribute.h:45
int16_t FileHandle
File handle.
Definition: Stat.h:40
Basic information about filing system.
Definition: IFileSystem.h:122
File Status structure.
Definition: Stat.h:52