loff_t oldaddr, loff_t newaddr,
int is_index);
void lafs_segment_count(struct lafs *fs, loff_t addr, int diff);
+void lafs_segment_apply_delayed(struct lafs *fs);
void lafs_print_device(struct lafs_device *dev);
void lafs_print_devblock(struct lafs_dev *dev);
void lafs_print_inode(struct lafs_ino *ino);
void lafs_print_cluster(struct cluster_head *head, int blocksize,
int groups, int verbose);
+void lafs_print_segusage(char *buf, int blocksize, int start, int max);
u32 lafs_find_next(struct lafs_ino *ino, u32 bnum);
int lafs_hash_name(u32 seed, int len, const char *name);
void lafs_dir_init_block(char *block, int psz, const char *name, int len,
char *bstr = args[2];
if (!bstr) {
- printf("show dirblock: now block number given\n");
+ printf("show dirblock: no block number given\n");
return;
}
if (get_int(bstr, &bnum) < 0) {
free(buf);
}
+/****** SHOW SEGUSAGE ******/
+static char help_show_segusage[] = "Show counts in segusage block";
+static struct args args_show_segusage[] = {
+ { "BLOCK", opaque, -1, {NULL}, "Block number in file or LaFS"},
+ TERMINAL_ARG
+};
+static void c_show_segusage(struct state *st, void **args)
+{
+ int bnum;
+ char *buf;
+ char *bstr = args[2];
+
+ if (!bstr) {
+ printf("show segusage: no block number given\n");
+ return;
+ }
+ if (get_int(bstr, &bnum) < 0) {
+ printf("show segusage: %s is not a valid address\n", bstr);
+ return;
+ }
+ if (!st->lafs->blocksize) {
+ printf("show segusage: LaFS not ready to show blocks\n");
+ return;
+ }
+
+ buf = malloc(st->lafs->blocksize);
+ if (lafs_read_virtual(st->lafs, buf, bnum)) {
+ printf("show segusage: cannot read block at %d\n", bnum);
+ free(buf);
+ return;
+ }
+
+ lafs_print_segusage(buf, st->lafs->blocksize, 0, st->lafs->blocksize);
+ if (!args[3])
+ free(buf);
+}
#define SCMD(x) {#x, c_show_##x, args_show_##x, help_show_##x}
static struct cmd show_cmds[] = {
SCMD(device),
SCMD(dirblock),
SCMD(inode),
+ SCMD(segusage),
SCMD(state),
{ NULL, NULL, NULL, NULL}
};
inum = lafs_imap_alloc(imfile);
inode = lafs_add_inode(fs, inum, TypeFile);
lafs_dir_add(dir, tail, inum, lafs_dt_type(inode));
+ inode->md.file.linkcount = 1;
+ lafs_dirty_inode(inode);
bnum = 0;
while(1) {