Redo makefiles.
[pintos-anon] / src / filesys / filehdr.h
1 #ifndef HEADER_FILEHDR_H
2 #define HEADER_FILEHDR_H 1
3
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include "off_t.h"
7 #include "devices/disk.h"
8
9 /* Number of direct sector pointers in a file header. */
10 #define DIRECT_CNT ((DISK_SECTOR_SIZE - sizeof (off_t) * 2)     \
11                     / sizeof (disk_sector_t))
12
13 /* File header.
14    This is both an in-memory and on-disk structure. */
15 struct filehdr 
16   {
17     off_t length;                       /* File size in bytes. */
18     size_t sector_cnt;                  /* File size in sectors. */
19     disk_sector_t sectors[DIRECT_CNT];  /* Sectors allocated for file. */
20   };
21
22 struct bitmap;
23 struct filehdr *filehdr_allocate (struct bitmap *, off_t length);
24 void filehdr_deallocate (struct filehdr *, struct bitmap *);
25 struct filehdr *filehdr_read (disk_sector_t);
26 void filehdr_write (const struct filehdr *, disk_sector_t);
27 void filehdr_destroy (struct filehdr *);
28 disk_sector_t filehdr_byte_to_sector (const struct filehdr *, off_t);
29 off_t filehdr_length (const struct filehdr *);
30 void filehdr_print (const struct filehdr *);
31
32 #endif /* filehdr.h */