vfs: check userland buffers before reading them.
[haiku.git] / src / system / kernel / device_manager / AbstractModuleDevice.h
blob3e6a833a5384ce14ab60225466e795023fe8c8e9
1 /*
2 * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2008-2009, Axel Dörfler, axeld@pinc-software.de.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef ABSTRACT_MODULE_DEVICE_H
7 #define ABSTRACT_MODULE_DEVICE_H
10 #include "BaseDevice.h"
13 namespace BPrivate {
16 class AbstractModuleDevice : public BaseDevice {
17 public:
18 AbstractModuleDevice();
19 virtual ~AbstractModuleDevice();
21 device_module_info* Module() const { return fDeviceModule; }
23 void* Data() const { return fDeviceData; }
24 device_node* Node() const { return fNode; }
26 virtual bool HasSelect() const;
27 virtual bool HasDeselect() const;
28 virtual bool HasRead() const;
29 virtual bool HasWrite() const;
30 virtual bool HasIO() const;
32 virtual status_t Open(const char* path, int openMode,
33 void** _cookie);
34 virtual status_t Read(void* cookie, off_t pos, void* buffer,
35 size_t* _length);
36 virtual status_t Write(void* cookie, off_t pos, const void* buffer,
37 size_t* _length);
38 virtual status_t IO(void* cookie, io_request* request);
39 virtual status_t Control(void* cookie, int32 op, void* buffer,
40 size_t length);
41 virtual status_t Select(void* cookie, uint8 event, selectsync* sync);
42 virtual status_t Deselect(void* cookie, uint8 event,
43 selectsync* sync);
45 virtual status_t Close(void* cookie);
46 virtual status_t Free(void* cookie);
48 protected:
49 device_node* fNode;
50 int32 fInitialized;
51 device_module_info* fDeviceModule;
52 void* fDeviceData;
56 } // namespace BPrivate
59 using BPrivate::AbstractModuleDevice;
62 #endif // ABSTRACT_MODULE_DEVICE_H