xref: /haiku/headers/private/kernel/boot/FileMapDisk.h (revision 04ec719a7040836b0860309cdf002a2cd156f913)
1 /*
2  * Copyright 2008, François Revol <revol@free.fr>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef _BOOT_FILE_MAP_DISK_H
7 #define _BOOT_FILE_MAP_DISK_H
8 
9 #include <boot/vfs.h>
10 #include <boot/partitions.h>
11 
12 #define FMAP_FOLDER_NAME "BEOS"
13 #define FMAP_IMAGE_NAME "IMAGE.BE"
14 //#define FMAP_FOLDER_NAME "HAIKU"
15 //#define FMAP_IMAGE_NAME "IMAGE.BFS"
16 
17 #define FMAP_MAX_RUNS 128
18 
19 struct file_map_run {
20 	off_t offset;
21 	off_t block;
22 	off_t len;
23 };
24 
25 struct file_map_boot_item {
26 	int32 block_size;
27 	int32 num_runs;
28 	struct file_map_run runs[FMAP_MAX_RUNS];
29 };
30 
31 #ifdef _BOOT_MODE
32 
33 class FileMap {
34 public:
35 	FileMap();
36 	~FileMap();
37 	void AddRun(off_t offset, off_t block, off_t len);
38 
39 private:
40 	struct file_map_run fRuns[FMAP_MAX_RUNS];
41 };
42 
43 class FileMapDisk : public Node {
44 	public:
45 		FileMapDisk();
46 		virtual ~FileMapDisk();
47 
48 		status_t Init(Node *node/*Partition *partition, FileMap *map, off_t imageSize*/);
49 
50 		virtual status_t Open(void **_cookie, int mode);
51 		virtual status_t Close(void *cookie);
52 
53 
54 		virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer,
55 			size_t bufferSize);
56 		virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer,
57 			size_t bufferSize);
58 
59 		virtual status_t GetName(char *nameBuffer, size_t bufferSize) const;
60 		virtual status_t GetFileMap(struct file_map_run *runs, int32 *count);
61 		virtual off_t Size() const;
62 
63 		static FileMapDisk *FindAnyFileMapDisk(Directory *volume);
64 
65 		status_t RegisterFileMapBootItem();
66 
67 	private:
68 		Node		*fNode;
69 		/*
70 		Partition	*fPartition;
71 		FileMap		*fMap;
72 		off_t		fImageSize;
73 		*/
74 
75 };
76 
77 #endif // _BOOT_MODE
78 
79 #endif	// _BOOT_FILE_MAP_DISK_H
80