vfs: check userland buffers before reading them.
[haiku.git] / src / system / kernel / device_manager / FileDevice.h
blobabc0d440bc01134c67be3ed4c9ccf80170de023d
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef FILE_DEVICE_H
6 #define FILE_DEVICE_H
9 #include "BaseDevice.h"
12 namespace BPrivate {
15 class FileDevice : public BaseDevice {
16 public:
17 FileDevice();
18 virtual ~FileDevice();
20 status_t Init(const char* path);
22 virtual status_t InitDevice();
23 virtual void UninitDevice();
25 virtual void Removed();
27 virtual bool HasSelect() const;
28 virtual bool HasDeselect() const;
29 virtual bool HasRead() const;
30 virtual bool HasWrite() const;
31 virtual bool HasIO() const;
33 virtual status_t Open(const char* path, int openMode,
34 void** _cookie);
35 virtual status_t Read(void* cookie, off_t pos, void* buffer,
36 size_t* _length);
37 virtual status_t Write(void* cookie, off_t pos, const void* buffer,
38 size_t* _length);
39 virtual status_t IO(void* cookie, io_request* request);
40 virtual status_t Control(void* cookie, int32 op, void* buffer,
41 size_t length);
42 virtual status_t Select(void* cookie, uint8 event, selectsync* sync);
43 virtual status_t Deselect(void* cookie, uint8 event,
44 selectsync* sync);
46 virtual status_t Close(void* cookie);
47 virtual status_t Free(void* cookie);
49 private:
50 struct Cookie;
52 private:
53 int fFD;
54 off_t fFileSize;
58 } // namespace BPrivate
61 using BPrivate::FileDevice;
64 #endif // FILE_DEVICE_H