18#define ROUND_UP(_a, _b) (((_a) + (_b) - 1)/(_b))
20#define MAXBLOCKSIZE (64*1024*1024)
46 int fd = open(manifest, O_RDONLY);
47 struct stat manifeststat;
50 perror(
"Cannot open manifest");
54 fstat(fd, &manifeststat);
71 for (i = 0; i < 512; i++)
132 memset(
id, 0,
sizeof(*
id));
133 memset(&node, 0,
sizeof(node));
139 fd = open(file, O_RDONLY);
141 perror(
"Cannot open file");
147 perror(
"File read error");
190 memcpy(&entries[entry].objId, fobj,
sizeof(
ObjID));
197 memcpy(&entries[entry].objId, dobj,
sizeof(
ObjID));
203 printf(
"Unexpected end of file\n");
212 entries[entry].
flags = 0;
230 memset(&node, 0,
sizeof(node));
239 memset(
id, 0,
sizeof(*
id));
241 id->offset = nodeoff;
257 for (
off_t i = 0; i < (off / 8); i++) {
260 for (
off_t i = 0; i < (off % 8); i++) {
272 memset(&sb, 0,
sizeof(sb));
289 printf(
"Usage: newfs_o2fs [OPTIONS] special-device\n");
291 printf(
" -m, --manifest Manifest of files to copy to file system\n");
292 printf(
" -s, --size Size in megabytes of device or disk image\n");
293 printf(
" -v, --verbose Verbose logging\n");
294 printf(
" -h, --help Print help message\n");
297int main(
int argc,
char *
const *argv)
305 struct option longopts[] = {
306 {
"manifest", required_argument,
NULL,
'm' },
307 {
"size", required_argument,
NULL,
's' },
308 {
"verbose", no_argument,
NULL,
'v' },
309 {
"help", no_argument,
NULL,
'h' },
313 while ((ch = getopt_long(argc, argv,
"m:s:vh", longopts,
NULL)) != -1)
321 diskSize = atol(optarg) * 1024 * 1024;
343 diskfd = open(argv[0], O_RDWR | O_CREAT, 0660);
345 perror(
"Cannot open special device or disk image");
351 perror(
"Cannot fstat special device or disk image");
356 printf(
"Error: Must specify size for disk images\n");
385 printf(
"Expected '/' token\n");
void Superblock(ObjID *objid)
ObjID * AddFile(const char *file)
void LoadManifest(const char *manifest)
uint64_t AppendEmpty(void)
uint64_t AppendBlock(const void *buf, size_t len)
int main(int argc, char *const *argv)
void FlushBlock(uint64_t offset, const void *buf, size_t len)
char tempbuf[MAXBLOCKSIZE]
char zerobuf[MAXBLOCKSIZE]
#define O2FS_VERSION_MINOR
BPtr direct[O2FS_DIRECT_PTR]
#define O2FS_VERSION_MAJOR
int printf(const char *fmt,...)
int strcmp(const char *s1, const char *s2)
char * strncpy(char *to, const char *from, size_t len)
void * memset(void *dst, int c, size_t len)
void * memcpy(void *dst, const void *src, size_t len)