vfs: check userland buffers before reading them.
[haiku.git] / headers / private / storage / DiskDevice.h
blob90994462a51ac537dd9dfdd3cf5948511c0016dc
1 /*
2 * Copyright 2003-2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2003, Tyler Akidau, haiku@akidau.net.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef _DISK_DEVICE_H
7 #define _DISK_DEVICE_H
9 #include <Partition.h>
12 struct user_disk_device_data;
14 class BDiskDevice : public BPartition {
15 public:
16 BDiskDevice();
17 virtual ~BDiskDevice();
19 bool HasMedia() const;
20 bool IsRemovableMedia() const;
21 bool IsReadOnlyMedia() const;
22 bool IsWriteOnceMedia() const;
24 status_t Eject(bool update = false);
26 status_t SetTo(partition_id id);
27 status_t Update(bool* updated = NULL);
28 void Unset();
29 status_t InitCheck() const;
31 virtual status_t GetPath(BPath* path) const;
33 bool IsModified() const;
34 status_t PrepareModifications();
35 status_t CommitModifications(bool synchronously = true,
36 BMessenger progressMessenger = BMessenger(),
37 bool receiveCompleteProgressUpdates = true);
38 status_t CancelModifications();
40 bool IsFile() const;
41 status_t GetFilePath(BPath* path) const;
43 private:
44 friend class BDiskDeviceList;
45 friend class BDiskDeviceRoster;
47 BDiskDevice(const BDiskDevice&);
48 BDiskDevice& operator=(const BDiskDevice&);
50 static status_t _GetData(partition_id id, bool deviceOnly,
51 size_t neededSize,
52 user_disk_device_data** data);
54 status_t _SetTo(partition_id id, bool deviceOnly,
55 size_t neededSize);
56 status_t _SetTo(user_disk_device_data* data);
57 status_t _Update(bool* updated);
58 status_t _Update(user_disk_device_data* data,
59 bool* updated);
61 static void _ClearUserData(user_partition_data* data);
63 virtual bool _AcceptVisitor(BDiskDeviceVisitor* visitor,
64 int32 level);
66 user_disk_device_data* fDeviceData;
69 #endif // _DISK_DEVICE_H