xref: /haiku/src/system/kernel/disk_device_manager/UserDataWriter.h (revision 2d690920ac4d0cd27eb3c118fb2b0862615869e0)
1 // KDiskDeviceUserDataWriter.h
2 
3 #ifndef _K_DISK_DEVICE_USER_DATA_WRITER_H
4 #define _K_DISK_DEVICE_USER_DATA_WRITER_H
5 
6 #include <SupportDefs.h>
7 
8 struct user_disk_device_data;
9 struct user_partition_data;
10 
11 namespace BPrivate {
12 namespace DiskDevice {
13 
14 class UserDataWriter {
15 public:
16 	UserDataWriter();
17 	UserDataWriter(user_disk_device_data *buffer, size_t bufferSize);
18 	~UserDataWriter();
19 
20 	status_t SetTo(user_disk_device_data *buffer, size_t bufferSize);
21 	void Unset();
22 
23 	void *AllocateData(size_t size, size_t align = 1);
24 	user_partition_data *AllocatePartitionData(size_t childCount);
25 	user_disk_device_data *AllocateDeviceData(size_t childCount);
26 
27 	char *PlaceString(const char *str);
28 
29 	size_t AllocatedSize() const;
30 
31 	status_t AddRelocationEntry(void *address);
32 	status_t Relocate(void *address);
33 
34 private:
35 	struct RelocationEntryList;
36 
37 	user_disk_device_data	*fBuffer;
38 	size_t					fBufferSize;
39 	size_t					fAllocatedSize;
40 	RelocationEntryList		*fRelocationEntries;
41 };
42 
43 } // namespace DiskDevice
44 } // namespace BPrivate
45 
46 using BPrivate::DiskDevice::UserDataWriter;
47 
48 #endif	// _K_DISK_DEVICE_USER_DATA_WRITER_H
49