vfs: check userland buffers before reading them.
[haiku.git] / src / system / kernel / device_manager / BaseDevice.h
blobbd353513002029b4e14fd16f60bff6a425608a55
1 /*
2 * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef BASE_DEVICE_H
6 #define BASE_DEVICE_H
9 #include <device_manager.h>
12 namespace BPrivate {
15 class BaseDevice {
16 public:
17 BaseDevice();
18 virtual ~BaseDevice();
20 void SetID(ino_t id) { fID = id; }
21 ino_t ID() const { return fID; }
23 virtual status_t InitDevice();
24 virtual void UninitDevice();
26 virtual void Removed();
28 virtual bool HasSelect() const;
29 virtual bool HasDeselect() const;
30 virtual bool HasRead() const;
31 virtual bool HasWrite() const;
32 virtual bool HasIO() const;
34 virtual status_t Open(const char* path, int openMode,
35 void** _cookie) = 0;
36 virtual status_t Read(void* cookie, off_t pos, void* buffer,
37 size_t* _length);
38 virtual status_t Write(void* cookie, off_t pos, const void* buffer,
39 size_t* _length);
40 virtual status_t IO(void* cookie, io_request* request);
41 virtual status_t Control(void* cookie, int32 op, void* buffer,
42 size_t length);
43 virtual status_t Select(void* cookie, uint8 event, selectsync* sync);
44 virtual status_t Deselect(void* cookie, uint8 event,
45 selectsync* sync);
47 virtual status_t Close(void* cookie) = 0;
48 virtual status_t Free(void* cookie) = 0;
50 protected:
51 ino_t fID;
55 } // namespace BPrivate
58 using BPrivate::BaseDevice;
61 #endif // BASE_DEVICE_H