vfs: check userland buffers before reading them.
[haiku.git] / src / system / boot / loader / file_systems / fat / Directory.h
blob9292a70bf7f43eca423ab262d5d07858deecfbcf
1 /*
2 ** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the MIT License.
4 */
5 #ifndef DIRECTORY_H
6 #define DIRECTORY_H
9 #include "fatfs.h"
10 #include "Stream.h"
12 #include <boot/vfs.h>
15 namespace FATFS {
17 struct dir_entry;
18 class Volume;
20 class Directory : public ::Directory {
21 public:
22 Directory();
23 Directory(Volume &volume, off_t dirEntryOffset, uint32 cluster,
24 const char *name);
25 virtual ~Directory();
27 status_t InitCheck();
29 off_t DirEntryOffset() const { return fDirEntryOffset; }
31 virtual status_t Open(void **_cookie, int mode);
32 virtual status_t Close(void *cookie);
34 virtual Node* LookupDontTraverse(const char* name);
36 virtual status_t GetNextEntry(void *cookie, char *nameBuffer, size_t bufferSize);
37 virtual status_t GetNextNode(void *cookie, Node **_node);
38 virtual status_t Rewind(void *cookie);
39 virtual bool IsEmpty();
41 virtual status_t GetName(char *name, size_t size) const;
42 virtual ino_t Inode() const;
44 virtual status_t CreateFile(const char *name, mode_t permissions,
45 Node **_node);
47 static status_t UpdateDirEntry(Volume& volume, off_t dirEntryOffset,
48 uint32 firstCluster, uint32 size);
50 private:
51 status_t GetNextEntry(void *cookie,
52 uint8 mask = FAT_VOLUME, uint8 match = 0);
53 status_t _AddEntry(dir_entry& entry, off_t& _entryOffset);
54 off_t _GetStreamSize();
56 Volume &fVolume;
57 Stream fStream;
58 off_t fDirEntryOffset;
60 typedef ::Directory _inherited;
63 } // namespace FATFS
65 #endif /* DIRECTORY_H */