1 #ifndef FILESYS_FILEHDR_H
2 #define FILESYS_FILEHDR_H
6 #include "filesys/off_t.h"
7 #include "devices/disk.h"
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))
14 This is both an in-memory and on-disk structure. */
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. */
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 *);
32 #endif /* filesys/filehdr.h */