xref: /haiku/headers/private/kernel/boot/FileMapDisk.h (revision bc3955fea5b07e2e94a27fc05e4bb58fe6f0319b)
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 class FileMap {
26 public:
27 	FileMap();
28 	~FileMap();
29 	void AddRun(off_t offset, off_t block, off_t len);
30 
31 private:
32 	struct file_map_run fRuns[FMAP_MAX_RUNS];
33 };
34 
35 class FileMapDisk : public Node {
36 	public:
37 		FileMapDisk();
38 		virtual ~FileMapDisk();
39 
40 		status_t Init(Node *node/*Partition *partition, FileMap *map, off_t imageSize*/);
41 
42 		virtual status_t Open(void **_cookie, int mode);
43 		virtual status_t Close(void *cookie);
44 
45 
46 		virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer,
47 			size_t bufferSize);
48 		virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer,
49 			size_t bufferSize);
50 
51 		virtual status_t GetName(char *nameBuffer, size_t bufferSize) const;
52 		virtual off_t Size() const;
53 
54 		status_t GetFileMap(FileMap **map);
55 
56 		static FileMapDisk *FindAnyFileMapDisk(Directory *volume);
57 
58 	private:
59 		Node		*fNode;
60 		/*
61 		Partition	*fPartition;
62 		FileMap		*fMap;
63 		off_t		fImageSize;
64 		*/
65 
66 };
67 
68 #endif	// _BOOT_FILE_MAP_DISK_H
69