diff options
author | Jaegeuk Kim <jaegeuk@google.com> | 2023-02-14 00:50:11 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-02-14 00:50:11 +0000 |
commit | 30f1c36236593d3956c77e25b07dc21136449cd6 (patch) | |
tree | e698e4c68a9324d1714f56035300e76164389375 | |
parent | af5ee250bd3624ac27326a538a20ad9965f2b08e (diff) | |
parent | fc7d13c739270a5bf524416be9c814631810a28d (diff) | |
download | f2fs-tools-30f1c36236593d3956c77e25b07dc21136449cd6.tar.gz |
Upgrade f2fs-tools to 3835fef5963a7396f89275fe3582f42da2854f92 am: 76adf1cf90 am: fc7d13c739
Original change: https://android-review.googlesource.com/c/platform/external/f2fs-tools/+/2433794
Change-Id: I3d66e9547c3c19b943765971c07a90e2460589e8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Android.bp | 10 | ||||
-rw-r--r-- | METADATA | 13 | ||||
-rw-r--r-- | fsck/f2fs.h | 2 | ||||
-rw-r--r-- | fsck/fsck.c | 4 | ||||
-rw-r--r-- | fsck/mount.c | 34 | ||||
-rw-r--r-- | fsck/resize.c | 8 | ||||
-rw-r--r-- | tools/Makefile.am | 3 | ||||
-rw-r--r-- | tools/f2fs_io/Makefile.am | 2 | ||||
-rw-r--r-- | tools/f2fs_io/f2fs_io.c | 21 | ||||
-rw-r--r-- | tools/f2fstat.c | 311 |
11 files changed, 45 insertions, 364 deletions
@@ -46,7 +46,6 @@ stamp-h1 /mkfs/mkfs.f2fs /fsck/fsck.f2fs -/tools/f2fstat /tools/fibmap.f2fs /tools/parse.f2fs /tools/f2fscrypt @@ -319,16 +319,6 @@ cc_binary { } cc_binary { - name: "f2fsstat", - defaults: [ - "tools-defaults", - ], - srcs: [ - "tools/f2fstat.c", - ], -} - -cc_binary { name: "f2fs.fibmap", defaults: [ "tools-defaults", @@ -1,6 +1,9 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update f2fs-tools +# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md + name: "f2fs-tools" description: "F2FS filesystem tools" - third_party { url { type: HOMEPAGE @@ -10,11 +13,11 @@ third_party { type: GIT value: "https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git" } - version: "021ead4a89414e8bc95ed6402630a08cf3443f83" + version: "3835fef5963a7396f89275fe3582f42da2854f92" license_type: RESTRICTED last_upgrade_date { - year: 2022 - month: 12 - day: 14 + year: 2023 + month: 2 + day: 13 } } diff --git a/fsck/f2fs.h b/fsck/f2fs.h index 703f340..e65644e 100644 --- a/fsck/f2fs.h +++ b/fsck/f2fs.h @@ -463,6 +463,7 @@ static inline block_t __end_block_addr(struct f2fs_sb_info *sbi) #define GET_R2L_SEGNO(sbi, segno) (segno + FREE_I_START_SEGNO(sbi)) #define MAIN_SEGS(sbi) (SM_I(sbi)->main_segments) +#define TOTAL_SEGS(sbi) (SM_I(sbi)->segment_count) #define TOTAL_BLKS(sbi) (TOTAL_SEGS(sbi) << (sbi)->log_blocks_per_seg) #define MAX_BLKADDR(sbi) (SEG0_BLKADDR(sbi) + TOTAL_BLKS(sbi)) @@ -511,7 +512,6 @@ struct fsync_inode_entry { ((segno) % sit_i->sents_per_block) #define SIT_BLOCK_OFFSET(sit_i, segno) \ ((segno) / SIT_ENTRY_PER_BLOCK) -#define TOTAL_SEGS(sbi) (SM_I(sbi)->main_segments) static inline bool IS_VALID_NID(struct f2fs_sb_info *sbi, u32 nid) { diff --git a/fsck/fsck.c b/fsck/fsck.c index df91c82..1b6f2c2 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -2064,7 +2064,7 @@ int fsck_chk_meta(struct f2fs_sb_info *sbi) unsigned int i; /* 1. check sit usage with CP: curseg is lost? */ - for (i = 0; i < TOTAL_SEGS(sbi); i++) { + for (i = 0; i < MAIN_SEGS(sbi); i++) { se = get_seg_entry(sbi, i); if (se->valid_blocks != 0) sit_valid_segs++; @@ -2607,7 +2607,7 @@ int check_sit_types(struct f2fs_sb_info *sbi) unsigned int i; int err = 0; - for (i = 0; i < TOTAL_SEGS(sbi); i++) { + for (i = 0; i < MAIN_SEGS(sbi); i++) { struct seg_entry *se; se = get_seg_entry(sbi, i); diff --git a/fsck/mount.c b/fsck/mount.c index 25b7f3b..2b26701 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -80,7 +80,7 @@ unsigned int get_usable_seg_count(struct f2fs_sb_info *sbi) { unsigned int i, usable_seg_count = 0; - for (i = 0; i < TOTAL_SEGS(sbi); i++) + for (i = 0; i < MAIN_SEGS(sbi); i++) if (is_usable_seg(sbi, i)) usable_seg_count++; @@ -96,7 +96,7 @@ bool is_usable_seg(struct f2fs_sb_info *UNUSED(sbi), unsigned int UNUSED(segno)) unsigned int get_usable_seg_count(struct f2fs_sb_info *sbi) { - return TOTAL_SEGS(sbi); + return MAIN_SEGS(sbi); } #endif @@ -105,7 +105,7 @@ u32 get_free_segments(struct f2fs_sb_info *sbi) { u32 i, free_segs = 0; - for (i = 0; i < TOTAL_SEGS(sbi); i++) { + for (i = 0; i < MAIN_SEGS(sbi); i++) { struct seg_entry *se = get_seg_entry(sbi, i); if (se->valid_blocks == 0x0 && !IS_CUR_SEGNO(sbi, i) && @@ -866,16 +866,16 @@ int sanity_check_raw_super(struct f2fs_super_block *sb, enum SB_ADDR sb_addr) unsigned int segment_count, segs_per_sec, secs_per_zone, segs_per_zone; unsigned int total_sections, blocks_per_seg; - if ((get_sb(feature) & F2FS_FEATURE_SB_CHKSUM) && - verify_sb_chksum(sb)) - return -1; - if (F2FS_SUPER_MAGIC != get_sb(magic)) { MSG(0, "Magic Mismatch, valid(0x%x) - read(0x%x)\n", F2FS_SUPER_MAGIC, get_sb(magic)); return -1; } + if ((get_sb(feature) & F2FS_FEATURE_SB_CHKSUM) && + verify_sb_chksum(sb)) + return -1; + blocksize = 1 << get_sb(log_blocksize); if (F2FS_BLKSIZE != blocksize) { MSG(0, "Invalid blocksize (%u), supports only 4KB\n", @@ -1789,13 +1789,13 @@ int build_sit_info(struct f2fs_sb_info *sbi) SM_I(sbi)->sit_info = sit_i; - sit_i->sentries = calloc(TOTAL_SEGS(sbi) * sizeof(struct seg_entry), 1); + sit_i->sentries = calloc(MAIN_SEGS(sbi) * sizeof(struct seg_entry), 1); if (!sit_i->sentries) { MSG(1, "\tError: Calloc failed for build_sit_info!\n"); goto free_sit_info; } - bitmap_size = TOTAL_SEGS(sbi) * SIT_VBLOCK_MAP_SIZE; + bitmap_size = MAIN_SEGS(sbi) * SIT_VBLOCK_MAP_SIZE; if (need_fsync_data_record(sbi)) bitmap_size += bitmap_size; @@ -1808,7 +1808,7 @@ int build_sit_info(struct f2fs_sb_info *sbi) bitmap = sit_i->bitmap; - for (start = 0; start < TOTAL_SEGS(sbi); start++) { + for (start = 0; start < MAIN_SEGS(sbi); start++) { sit_i->sentries[start].cur_valid_map = bitmap; bitmap += SIT_VBLOCK_MAP_SIZE; @@ -2060,7 +2060,7 @@ static int build_curseg(struct f2fs_sb_info *sbi) blk_off = get_cp(cur_node_blkoff[i - CURSEG_HOT_NODE]); segno = get_cp(cur_node_segno[i - CURSEG_HOT_NODE]); } - ASSERT(segno < TOTAL_SEGS(sbi)); + ASSERT(segno < MAIN_SEGS(sbi)); ASSERT(blk_off < DEFAULT_BLOCKS_PER_SEGMENT); array[i].segno = segno; @@ -2422,7 +2422,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi) segno = start_blk * sit_i->sents_per_block; end = (start_blk + readed) * sit_i->sents_per_block; - for (; segno < end && segno < TOTAL_SEGS(sbi); segno++) { + for (; segno < end && segno < MAIN_SEGS(sbi); segno++) { se = &sit_i->sentries[segno]; get_current_sit_page(sbi, segno, sit_blk); @@ -2448,7 +2448,7 @@ static int build_sit_entries(struct f2fs_sb_info *sbi) for (i = 0; i < sits_in_cursum(journal); i++) { segno = le32_to_cpu(segno_in_journal(journal, i)); - if (segno >= TOTAL_SEGS(sbi)) { + if (segno >= MAIN_SEGS(sbi)) { MSG(0, "\tError: build_sit_entries: segno(%u) is invalid!!!\n", segno); journal->n_sits = cpu_to_le16(i); c.fix_on = 1; @@ -2525,7 +2525,7 @@ void build_sit_area_bitmap(struct f2fs_sb_info *sbi) ASSERT(fsck->sit_area_bitmap_sz == fsck->main_area_bitmap_sz); - for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { + for (segno = 0; segno < MAIN_SEGS(sbi); segno++) { se = get_seg_entry(sbi, segno); memcpy(ptr, se->cur_valid_map, SIT_VBLOCK_MAP_SIZE); @@ -2571,7 +2571,7 @@ void rewrite_sit_area_bitmap(struct f2fs_sb_info *sbi) ptr = fsck->main_area_bitmap; - for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { + for (segno = 0; segno < MAIN_SEGS(sbi); segno++) { struct f2fs_sit_entry *sit; struct seg_entry *se; u16 valid_blocks = 0; @@ -2694,7 +2694,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi) sit_blk = calloc(BLOCK_SZ, 1); ASSERT(sit_blk); /* update free segments */ - for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { + for (segno = 0; segno < MAIN_SEGS(sbi); segno++) { struct f2fs_sit_entry *sit; struct seg_entry *se; @@ -3400,7 +3400,7 @@ static int find_fsync_inode(struct f2fs_sb_info *sbi, struct list_head *head) struct f2fs_node *node_blk; block_t blkaddr; unsigned int loop_cnt = 0; - unsigned int free_blocks = TOTAL_SEGS(sbi) * sbi->blocks_per_seg - + unsigned int free_blocks = MAIN_SEGS(sbi) * sbi->blocks_per_seg - sbi->total_valid_block_count; int err = 0; diff --git a/fsck/resize.c b/fsck/resize.c index c545dd9..2fd3941 100644 --- a/fsck/resize.c +++ b/fsck/resize.c @@ -175,7 +175,7 @@ static void migrate_main(struct f2fs_sb_info *sbi, unsigned int offset) ASSERT(raw != NULL); - for (i = TOTAL_SEGS(sbi) - 1; i >= 0; i--) { + for (i = MAIN_SEGS(sbi) - 1; i >= 0; i--) { se = get_seg_entry(sbi, i); if (!se->valid_blocks) continue; @@ -240,7 +240,7 @@ static void migrate_ssa(struct f2fs_sb_info *sbi, block_t new_sum_blkaddr = get_newsb(ssa_blkaddr); block_t end_sum_blkaddr = get_newsb(main_blkaddr); block_t expand_sum_blkaddr = new_sum_blkaddr + - TOTAL_SEGS(sbi) - offset; + MAIN_SEGS(sbi) - offset; block_t blkaddr; int ret; void *zero_block = calloc(BLOCK_SZ, 1); @@ -258,7 +258,7 @@ static void migrate_ssa(struct f2fs_sb_info *sbi, } } else { blkaddr = end_sum_blkaddr - 1; - offset = TOTAL_SEGS(sbi) - 1; + offset = MAIN_SEGS(sbi) - 1; while (blkaddr >= new_sum_blkaddr) { if (blkaddr >= expand_sum_blkaddr) { ret = dev_write_block(zero_block, blkaddr--); @@ -412,7 +412,7 @@ static void migrate_sit(struct f2fs_sb_info *sbi, DBG(3, "Write zero sit: %x\n", get_newsb(sit_blkaddr) + index); } - for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { + for (segno = 0; segno < MAIN_SEGS(sbi); segno++) { struct f2fs_sit_entry *sit; se = get_seg_entry(sbi, segno); diff --git a/tools/Makefile.am b/tools/Makefile.am index 8dd963a..6b03814 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,11 +2,10 @@ AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include AM_CFLAGS = -Wall -sbin_PROGRAMS = f2fstat +sbin_PROGRAMS = if !WINDOWS sbin_PROGRAMS += fibmap.f2fs parse.f2fs endif -f2fstat_SOURCES = f2fstat.c fibmap_f2fs_SOURCES = fibmap.c parse_f2fs_SOURCES = f2fs_io_parse.c diff --git a/tools/f2fs_io/Makefile.am b/tools/f2fs_io/Makefile.am index 6c17db1..bc4f9d0 100644 --- a/tools/f2fs_io/Makefile.am +++ b/tools/f2fs_io/Makefile.am @@ -1,7 +1,7 @@ ## Makefile.am if LINUX -AM_CPPFLAGS = -I../../include +AM_CPPFLAGS = -I$(top_srcdir)/include AM_CFLAGS = -Wall sbin_PROGRAMS = f2fs_io f2fs_io_SOURCES = f2fs_io.c diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c index 6dcd840..5bc0baf 100644 --- a/tools/f2fs_io/f2fs_io.c +++ b/tools/f2fs_io/f2fs_io.c @@ -1195,16 +1195,17 @@ static void do_get_filename_encrypt_mode (int argc, char **argv, const struct cmd_desc *cmd) { static const char *enc_name[] = { - "invalid", /* FS_ENCRYPTION_MODE_INVALID (0) */ - "aes-256-xts", /* FS_ENCRYPTION_MODE_AES_256_XTS (1) */ - "aes-256-gcm", /* FS_ENCRYPTION_MODE_AES_256_GCM (2) */ - "aes-256-cbc", /* FS_ENCRYPTION_MODE_AES_256_CBC (3) */ - "aes-256-cts", /* FS_ENCRYPTION_MODE_AES_256_CTS (4) */ - "aes-128-cbc", /* FS_ENCRYPTION_MODE_AES_128_CBC (5) */ - "aes-128-cts", /* FS_ENCRYPTION_MODE_AES_128_CTS (6) */ - "speck128-256-xts", /* FS_ENCRYPTION_MODE_SPECK128_256_XTS (7) */ - "speck128-256-cts", /* FS_ENCRYPTION_MODE_SPECK128_256_CTS (8) */ - "adiantum", /* FS_ENCRYPTION_MODE_ADIANTUM (9) */ + "invalid", /* FSCRYPT_MODE_INVALID (0) */ + "aes-256-xts", /* FSCRYPT_MODE_AES_256_XTS (1) */ + "aes-256-gcm", /* FSCRYPT_MODE_AES_256_GCM (2) */ + "aes-256-cbc", /* FSCRYPT_MODE_AES_256_CBC (3) */ + "aes-256-cts", /* FSCRYPT_MODE_AES_256_CTS (4) */ + "aes-128-cbc", /* FSCRYPT_MODE_AES_128_CBC (5) */ + "aes-128-cts", /* FSCRYPT_MODE_AES_128_CTS (6) */ + "speck128-256-xts", /* FSCRYPT_MODE_SPECK128_256_XTS (7) */ + "speck128-256-cts", /* FSCRYPT_MODE_SPECK128_256_CTS (8) */ + "adiantum", /* FSCRYPT_MODE_ADIANTUM (9) */ + "aes-256-hctr2", /* FSCRYPT_MODE_AES_256_HCTR2 (10) */ }; int fd, mode, ret; struct fscrypt_get_policy_ex_arg arg; diff --git a/tools/f2fstat.c b/tools/f2fstat.c deleted file mode 100644 index 5b4d683..0000000 --- a/tools/f2fstat.c +++ /dev/null @@ -1,311 +0,0 @@ -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <libgen.h> - -#ifdef DEBUG -#define dbg(fmt, args...) printf(fmt, __VA_ARGS__); -#else -#define dbg(fmt, args...) -#endif - -/* - * f2fs status - */ -#define F2FS_STATUS "/sys/kernel/debug/f2fs/status" - -#define KEY_NODE 0x00000001 -#define KEY_META 0x00000010 - -unsigned long util; -unsigned long used_node_blks; -unsigned long used_data_blks; -//unsigned long inline_inode; - -unsigned long free_segs; -unsigned long valid_segs; -unsigned long dirty_segs; -unsigned long prefree_segs; - -unsigned long gc, bg_gc; -unsigned long cp; -unsigned long gc_data_blks; -unsigned long gc_node_blks; - -//unsigned long extent_hit_ratio; - -unsigned long dirty_node, node_kb; -unsigned long dirty_dents; -unsigned long dirty_meta, meta_kb; -unsigned long nat_caches; -unsigned long dirty_sit; - -unsigned long free_nids; - -unsigned long ssr_blks; -unsigned long lfs_blks; -unsigned long memory_kb; - -struct options { - int delay; - int interval; - char partname[32]; -}; - -struct mm_table { - const char *name; - unsigned long *val; - int flag; -}; - -static int compare_mm_table(const void *a, const void *b) -{ - dbg("[COMPARE] %s, %s\n", ((struct mm_table *)a)->name, ((struct mm_table *)b)->name); - return strcmp(((struct mm_table *)a)->name, ((struct mm_table *)b)->name); -} - -static inline void remove_newline(char **head) -{ -again: - if (**head == '\n') { - *head = *head + 1; - goto again; - } -} - -void f2fstat(struct options *opt) -{ - int fd; - int ret; - char keyname[32]; - char buf[4096]; - struct mm_table key = { keyname, NULL, 0 }; - struct mm_table *found; - int f2fstat_table_cnt; - char *head, *tail; - int found_cnt = 0; - - static struct mm_table f2fstat_table[] = { - { " - Data", &used_data_blks, 0 }, - { " - Dirty", &dirty_segs, 0 }, - { " - Free", &free_segs, 0 }, - { " - NATs", &nat_caches, 0 }, - { " - Node", &used_node_blks, 0 }, - { " - Prefree", &prefree_segs, 0 }, - { " - SITs", &dirty_sit, 0 }, - { " - Valid", &valid_segs, 0 }, - { " - dents", &dirty_dents, 0 }, - { " - free_nids", &free_nids, 0 }, - { " - meta", &dirty_meta, KEY_META }, - { " - nodes", &dirty_node, KEY_NODE }, - { "CP calls", &cp, 0 }, - { "GC calls", &gc, 0 }, - { "LFS", &lfs_blks, 0 }, - { "Memory", &memory_kb, 0 }, - { "SSR", &ssr_blks, 0 }, - { "Utilization", &util, 0 }, - }; - - f2fstat_table_cnt = sizeof(f2fstat_table)/sizeof(struct mm_table); - - fd = open(F2FS_STATUS, O_RDONLY); - if (fd < 0) { - perror("open " F2FS_STATUS); - exit(EXIT_FAILURE); - } - - ret = read(fd, buf, 4096); - if (ret < 0) { - perror("read " F2FS_STATUS); - exit(EXIT_FAILURE); - } - buf[ret] = '\0'; - - head = buf; - - if (opt->partname[0] != '\0') { - head = strstr(buf, opt->partname); - if (head == NULL) - exit(EXIT_FAILURE); - } - - for (;;) { - remove_newline(&head); - tail = strchr(head, ':'); - if (!tail) - break; - *tail = '\0'; - if (strlen(head) >= sizeof(keyname)) { - dbg("[OVER] %s\n", head); - *tail = ':'; - tail = strchr(head, '\n'); - head = tail + 1; - continue; - } - - strcpy(keyname, head); - - found = bsearch(&key, f2fstat_table, f2fstat_table_cnt, sizeof(struct mm_table), compare_mm_table); - dbg("[RESULT] %s (%s)\n", head, (found) ? "O" : "X"); - head = tail + 1; - if (!found) - goto nextline; - - *(found->val) = strtoul(head, &tail, 10); - if (found->flag) { - int npages; - tail = strstr(head, "in"); - head = tail + 2; - npages = strtoul(head, &tail, 10); - switch (found->flag & (KEY_NODE | KEY_META)) { - case KEY_NODE: - node_kb = npages * 4; - break; - case KEY_META: - meta_kb = npages * 4; - break; - } - } - if (++found_cnt == f2fstat_table_cnt) - break; -nextline: - tail = strchr(head, '\n'); - if (!tail) - break; - head = tail + 1; - } - - close(fd); -} - -void usage(void) -{ - printf("Usage: f2fstat [option]\n" - " -d delay (secs)\n" - " -i interval of head info\n" - " -p partition name (e.g. /dev/sda3)\n"); - exit(EXIT_FAILURE); -} - -void parse_option(int argc, char *argv[], struct options *opt) -{ - int option; - const char *option_string = "d:i:p:h"; - - while ((option = getopt(argc, argv, option_string)) != EOF) { - switch (option) { - case 'd': - opt->delay = atoi(optarg); - break; - case 'i': - opt->interval = atoi(optarg); - break; - case 'p': - strcpy(opt->partname, basename(optarg)); - break; - default: - usage(); - break; - } - } -} - -void __make_head(char *head, int index, int i, int len) -{ - char name_h[5][20] = {"main segments", "page/slab caches", "cp/gc", "blks", "memory"}; - int half = (len - strlen(name_h[i])) / 2; - - *(head + index) = '|'; - index++; - memset(head + index, '-', half); - index += half; - strcpy(head + index, name_h[i]); - index += strlen(name_h[i]); - memset(head + index, '-', half); -} - -void print_head(char *res) -{ - char *ptr, *ptr_buf; - char buf[1024], head[1024]; - char name[20][10] = {"util", "node", "data", "free", "valid", "dirty", "prefree", "node", "dent", "meta", - "sit", "nat", "fnid", "cp", "gc", "ssr", "lfs", "total", "node", "meta"}; - int i, len, prev_index = 0; - - ptr_buf = buf; - memset(buf, ' ', 1024); - memset(head, ' ', 1024); - - for (i = 0; i < 20; i++) { - ptr = (i == 0) ? strtok(res, " ") : strtok(NULL, " "); - strcpy(ptr_buf, name[i]); - if (i == 1) { - prev_index = ptr_buf - buf - 1; - } else if (i == 7) { - len = (ptr_buf - buf) - 1 - prev_index; - __make_head(head, prev_index, 0, len); - prev_index = ptr_buf - buf - 1; - } else if (i == 13) { - len = (ptr_buf - buf) - 1 - prev_index; - __make_head(head, prev_index, 1, len); - prev_index = ptr_buf - buf - 1; - } else if (i == 15) { - len = (ptr_buf - buf) - 1 - prev_index; - __make_head(head, prev_index, 2, len); - prev_index = ptr_buf - buf - 1; - } else if (i == 17) { - len = (ptr_buf - buf) - 1 - prev_index; - __make_head(head, prev_index, 3, len); - prev_index = ptr_buf - buf - 1; - } - - len = strlen(ptr); - ptr_buf += (len > strlen(name[i]) ? len : strlen(name[i])) + 1; - } - - len = (ptr_buf - buf) - 1 - prev_index; - __make_head(head, prev_index, 4, len); - - *ptr_buf = 0; - *(head + (ptr_buf - buf - 1)) = '|'; - *(head + (ptr_buf - buf)) = 0; - fprintf(stderr, "%s\n%s\n", head, buf); -} - -int main(int argc, char *argv[]) -{ - char format[] = "%4ld %4ld %4ld %4ld %5ld %5ld %7ld %4ld %4ld %4ld %3ld %3ld %4ld %2ld %2ld %3ld %3ld %5ld %4ld %4ld"; - char buf[1024], tmp[1024]; - int head_interval; - struct options opt = { - .delay = 1, - .interval = 20, - .partname = { 0, }, - }; - - parse_option(argc, argv, &opt); - head_interval = opt.interval; - - while (1) { - memset(buf, 0, 1024); - f2fstat(&opt); - sprintf(buf, format, util, used_node_blks, used_data_blks, - free_segs, valid_segs, dirty_segs, prefree_segs, - dirty_node, dirty_dents, dirty_meta, dirty_sit, nat_caches, free_nids, - cp, gc, ssr_blks, lfs_blks, memory_kb, node_kb, meta_kb); - - strcpy(tmp, buf); - if (head_interval == opt.interval) - print_head(tmp); - if (head_interval-- == 0) - head_interval = opt.interval; - - fprintf(stderr, "%s\n", buf); - - sleep(opt.delay); - } - - return 0; -} |