char *err = NULL;
char uuidstr[37];
uuid_t uu;
+ struct lafs_ino *ifile, *imfile, *rootdir;
+ int create_atime = 1;
+
if (st->lafs->blocksize) {
- printf("newfs: Filesytem already has state - consider using \"reset\"\n");
+ printf("newfs: Filesytem already has state"
+ " - consider using \"reset\"\n");
return;
}
if (args[4])
memcpy(st->lafs->uuid, uu, 16);
+ ifile = lafs_get_itable(st->lafs);
+ imfile = lafs_add_inode(ifile, 1, TypeInodeMap);
+ rootdir = lafs_add_inode(ifile, 2, TypeDir);
+ if (create_atime)
+ lafs_add_inode(ifile, 3, TypeAccessTime);
+ rootdir->md.file.linkcount = 2;
+ rootdir->md.file.mode = 0755;
+ rootdir->md.file.parent = 2;
+ lafs_dirty_inode(rootdir);
+ lafs_add_inode(ifile, 8, TypeOrphanList);
+
+ lafs_imap_set(imfile, 1);
+ lafs_imap_set(imfile, 2);
+ lafs_imap_set(imfile, 8);
+
+ lafs_cluster_init(st->lafs, 0, 0, 0, 1);
+
if (st->verbose) {
uuid_unparse(st->lafs->uuid, uuidstr);
printf("Filesystem has been initilised: block size %d, "
char *devname = args[1];
int fd;
struct lafs_device *dev;
+ struct lafs_ino *ifile, *imfile, *segmap;
if (!devname) {
printf("add_device: No device or file name given to add\n");
return;
}
- if (st->lafs->blocksize == 0) {
+ block_bytes = st->lafs->blocksize;
+ if (block_bytes == 0) {
printf("add_device: filesystem is not ready for devices"
" - consider \"newfs\".\n");
return;
}
- block_bytes = st->lafs->blocksize;
+
+ ifile = st->lafs->ss.root;
+ if (!ifile) {
+ printf("add_device: filesystem has no root inode - strange"
+ " - consider \"newfs\" again.\n");
+ return;
+ }
+
+ imfile = lafs_get_inode(ifile, 1);
+ if (!imfile) {
+ printf("add_device: Cannot find inode-map\n");
+ return;
+ }
+
if (args[3]) {
device_bytes = parse_size_print(args[3], &err, "add_device",
stride_bytes / block_bytes,
width,
usage_inum);
+
+ segmap = lafs_add_inode(ifile, usage_inum, TypeSegmentMap);
+ if (segmap == NULL) {
+ printf("ERROR: could not allocate segusage file.\n");
+ st->lafs->flags |= LAFS_NEED_CHECK;
+ return;
+ }
+ dev->segsum = segmap;
+ segmap->md.segmentusage.table_size = dev->tablesize * usage_inum;
+ dev->tablesize = segmap->md.segmentusage.table_size;
+ lafs_dirty_inode(segmap);
+ lafs_imap_set(imfile, usage_inum);
+
printf("Added device %s at %llu with %llu segments of %llu %dk blocks\n",
devname, (unsigned long long)dev->start,
(unsigned long long)dev->segment_count,