vfs: check userland buffers before reading them.
[haiku.git] / src / system / boot / loader / file_systems / bfs / Stream.h
blob8377a0b7df109cc1c90f4c8afeb1b9855bb24fbc
1 /* Stream - inode stream access functions
2 **
3 ** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
4 ** Distributed under the terms of the MIT License.
5 */
6 #ifndef STREAM_H
7 #define STREAM_H
10 #include "Volume.h"
12 #include <sys/stat.h>
14 class Node;
17 namespace BFS {
19 class Stream : public bfs_inode {
20 public:
21 Stream(Volume &volume, block_run run);
22 Stream(Volume &volume, off_t id);
23 ~Stream();
25 status_t InitCheck();
26 Volume &GetVolume() const { return fVolume; }
28 status_t FindBlockRun(off_t pos, block_run &run, off_t &offset);
29 status_t ReadAt(off_t pos, uint8 *buffer, size_t *length);
31 status_t GetName(char *name, size_t size) const;
32 off_t Size() const { return data.Size(); }
33 off_t ID() const { return fVolume.ToVnode(inode_num); }
34 status_t ReadLink(char *buffer, size_t bufferSize);
36 bool IsContainer() const { return Mode() & (S_IFDIR | S_INDEX_DIR | S_ATTR_DIR); }
37 bool IsSymlink() const { return S_ISLNK(Mode()); }
38 bool IsIndex() const { return false; }
40 static Node *NodeFactory(Volume &volume, off_t id);
42 private:
43 status_t GetNextSmallData(const small_data **_smallData) const;
45 Volume &fVolume;
48 } // namespace BFS
50 #endif /* STREAM_H */