vfs: check userland buffers before reading them.
[haiku.git] / headers / private / storage / FileDescriptorIO.h
bloba7f702cbd396f1d5dee016394aee62c72e5aee94
1 /*
2 * Copyright 2009-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _FILE_DESCRIPTOR_IO_H
6 #define _FILE_DESCRIPTOR_IO_H
9 #include <DataIO.h>
12 class BFileDescriptorIO : public BPositionIO {
13 public:
14 BFileDescriptorIO(int fd,
15 bool takeOverOwnership = false);
16 virtual ~BFileDescriptorIO();
18 virtual ssize_t Read(void *buffer, size_t size);
19 virtual ssize_t Write(const void *buffer, size_t size);
21 virtual ssize_t ReadAt(off_t position, void *buffer,
22 size_t size);
23 virtual ssize_t WriteAt(off_t position, const void *buffer,
24 size_t size);
26 virtual off_t Seek(off_t position, uint32 seekMode);
27 virtual off_t Position() const;
29 virtual status_t SetSize(off_t size);
30 virtual status_t GetSize(off_t* size) const;
32 private:
33 BFileDescriptorIO(
34 const BFileDescriptorIO& other);
35 BFileDescriptorIO& operator=(const BFileDescriptorIO& other);
37 private:
38 int fFD;
39 bool fOwnsFD;
43 #endif // _FILE_DESCRIPTOR_IO_H