⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 procfs.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* -*- linux-c -*- *//* fs/reiserfs/procfs.c *//* * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README *//* proc info support a la one created by Sizif@Botik.RU for PGC *//* $Id: procfs.c,v 1.1.8.2 2001/07/15 17:08:42 god Exp $ */#include <linux/module.h>#include <linux/time.h>#include <linux/seq_file.h>#include <asm/uaccess.h>#include <linux/reiserfs_fs.h>#include <linux/reiserfs_fs_sb.h>#include <linux/init.h>#include <linux/proc_fs.h>#ifdef CONFIG_REISERFS_PROC_INFO/* * LOCKING: * * We rely on new Alexander Viro's super-block locking. * */static int show_version(struct seq_file *m, struct super_block *sb){	char *format;	if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {		format = "3.6";	} else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) {		format = "3.5";	} else {		format = "unknown";	}	seq_printf(m, "%s format\twith checks %s\n", format,#if defined( CONFIG_REISERFS_CHECK )		   "on"#else		   "off"#endif	    );	return 0;}int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,				    int count, int *eof, void *data){	*start = buffer;	*eof = 1;	return 0;}#define SF( x ) ( r -> x )#define SFP( x ) SF( s_proc_info_data.x )#define SFPL( x ) SFP( x[ level ] )#define SFPF( x ) SFP( scan_bitmap.x )#define SFPJ( x ) SFP( journal.x )#define D2C( x ) le16_to_cpu( x )#define D4C( x ) le32_to_cpu( x )#define DF( x ) D2C( rs -> s_v1.x )#define DFL( x ) D4C( rs -> s_v1.x )#define objectid_map( s, rs ) (old_format_only (s) ?				\                         (__le32 *)((struct reiserfs_super_block_v1 *)rs + 1) :	\			 (__le32 *)(rs + 1))#define MAP( i ) D4C( objectid_map( sb, rs )[ i ] )#define DJF( x ) le32_to_cpu( rs -> x )#define DJV( x ) le32_to_cpu( s_v1 -> x )#define DJP( x ) le32_to_cpu( jp -> x )#define JF( x ) ( r -> s_journal -> x )static int show_super(struct seq_file *m, struct super_block *sb){	struct reiserfs_sb_info *r = REISERFS_SB(sb);	seq_printf(m, "state: \t%s\n"		   "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n"		   "gen. counter: \t%i\n"		   "s_disk_reads: \t%i\n"		   "s_disk_writes: \t%i\n"		   "s_fix_nodes: \t%i\n"		   "s_do_balance: \t%i\n"		   "s_unneeded_left_neighbor: \t%i\n"		   "s_good_search_by_key_reada: \t%i\n"		   "s_bmaps: \t%i\n"		   "s_bmaps_without_search: \t%i\n"		   "s_direct2indirect: \t%i\n"		   "s_indirect2direct: \t%i\n"		   "\n"		   "max_hash_collisions: \t%i\n"		   "breads: \t%lu\n"		   "bread_misses: \t%lu\n"		   "search_by_key: \t%lu\n"		   "search_by_key_fs_changed: \t%lu\n"		   "search_by_key_restarted: \t%lu\n"		   "insert_item_restarted: \t%lu\n"		   "paste_into_item_restarted: \t%lu\n"		   "cut_from_item_restarted: \t%lu\n"		   "delete_solid_item_restarted: \t%lu\n"		   "delete_item_restarted: \t%lu\n"		   "leaked_oid: \t%lu\n"		   "leaves_removable: \t%lu\n",		   SF(s_mount_state) == REISERFS_VALID_FS ?		   "REISERFS_VALID_FS" : "REISERFS_ERROR_FS",		   reiserfs_r5_hash(sb) ? "FORCE_R5 " : "",		   reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "",		   reiserfs_tea_hash(sb) ? "FORCE_TEA " : "",		   reiserfs_hash_detect(sb) ? "DETECT_HASH " : "",		   reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ",		   reiserfs_no_unhashed_relocation(sb) ?		   "NO_UNHASHED_RELOCATION " : "",		   reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "",		   reiserfs_test4(sb) ? "TEST4 " : "",		   have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ?		   "SMALL_TAILS " : "NO_TAILS ",		   replay_only(sb) ? "REPLAY_ONLY " : "",		   convert_reiserfs(sb) ? "CONV " : "",		   atomic_read(&r->s_generation_counter),		   SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),		   SF(s_do_balance), SF(s_unneeded_left_neighbor),		   SF(s_good_search_by_key_reada), SF(s_bmaps),		   SF(s_bmaps_without_search), SF(s_direct2indirect),		   SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads),		   SFP(bread_miss), SFP(search_by_key),		   SFP(search_by_key_fs_changed), SFP(search_by_key_restarted),		   SFP(insert_item_restarted), SFP(paste_into_item_restarted),		   SFP(cut_from_item_restarted),		   SFP(delete_solid_item_restarted), SFP(delete_item_restarted),		   SFP(leaked_oid), SFP(leaves_removable));	return 0;}static int show_per_level(struct seq_file *m, struct super_block *sb){	struct reiserfs_sb_info *r = REISERFS_SB(sb);	int level;	seq_printf(m, "level\t"		   "     balances"		   " [sbk:  reads"		   "   fs_changed"		   "   restarted]"		   "   free space"		   "        items"		   "   can_remove"		   "         lnum"		   "         rnum"		   "       lbytes"		   "       rbytes"		   "     get_neig"		   " get_neig_res" "  need_l_neig" "  need_r_neig" "\n");	for (level = 0; level < MAX_HEIGHT; ++level) {		seq_printf(m, "%i\t"			   " %12lu"			   " %12lu"			   " %12lu"			   " %12lu"			   " %12lu"			   " %12lu"			   " %12lu"			   " %12li"			   " %12li"			   " %12li"			   " %12li"			   " %12lu"			   " %12lu"			   " %12lu"			   " %12lu"			   "\n",			   level,			   SFPL(balance_at),			   SFPL(sbk_read_at),			   SFPL(sbk_fs_changed),			   SFPL(sbk_restarted),			   SFPL(free_at),			   SFPL(items_at),			   SFPL(can_node_be_removed),			   SFPL(lnum),			   SFPL(rnum),			   SFPL(lbytes),			   SFPL(rbytes),			   SFPL(get_neighbors),			   SFPL(get_neighbors_restart),			   SFPL(need_l_neighbor), SFPL(need_r_neighbor)		    );	}	return 0;}static int show_bitmap(struct seq_file *m, struct super_block *sb){	struct reiserfs_sb_info *r = REISERFS_SB(sb);	seq_printf(m, "free_block: %lu\n"		   "  scan_bitmap:"		   "          wait"		   "          bmap"		   "         retry"		   "        stolen"		   "  journal_hint"		   "journal_nohint"		   "\n"		   " %14lu"		   " %14lu"		   " %14lu"		   " %14lu"		   " %14lu"		   " %14lu"		   " %14lu"		   "\n",		   SFP(free_block),		   SFPF(call),		   SFPF(wait),		   SFPF(bmap),		   SFPF(retry),		   SFPF(stolen),		   SFPF(in_journal_hint), SFPF(in_journal_nohint));	return 0;}static int show_on_disk_super(struct seq_file *m, struct super_block *sb){	struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);	struct reiserfs_super_block *rs = sb_info->s_rs;	int hash_code = DFL(s_hash_function_code);	__u32 flags = DJF(s_flags);	seq_printf(m, "block_count: \t%i\n"		   "free_blocks: \t%i\n"		   "root_block: \t%i\n"		   "blocksize: \t%i\n"		   "oid_maxsize: \t%i\n"		   "oid_cursize: \t%i\n"		   "umount_state: \t%i\n"		   "magic: \t%10.10s\n"		   "fs_state: \t%i\n"		   "hash: \t%s\n"		   "tree_height: \t%i\n"		   "bmap_nr: \t%i\n"		   "version: \t%i\n"		   "flags: \t%x[%s]\n"		   "reserved_for_journal: \t%i\n",		   DFL(s_block_count),		   DFL(s_free_blocks),		   DFL(s_root_block),		   DF(s_blocksize),		   DF(s_oid_maxsize),		   DF(s_oid_cursize),		   DF(s_umount_state),		   rs->s_v1.s_magic,		   DF(s_fs_state),		   hash_code == TEA_HASH ? "tea" :		   (hash_code == YURA_HASH) ? "rupasov" :		   (hash_code == R5_HASH) ? "r5" :		   (hash_code == UNSET_HASH) ? "unset" : "unknown",		   DF(s_tree_height),		   DF(s_bmap_nr),		   DF(s_version), flags, (flags & reiserfs_attrs_cleared)		   ? "attrs_cleared" : "", DF(s_reserved_for_journal));	return 0;}static int show_oidmap(struct seq_file *m, struct super_block *sb){	struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);	struct reiserfs_super_block *rs = sb_info->s_rs;	unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);	unsigned long total_used = 0;	int i;	for (i = 0; i < mapsize; ++i) {		__u32 right;		right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1);		seq_printf(m, "%s: [ %x .. %x )\n",			   (i & 1) ? "free" : "used", MAP(i), right);		if (!(i & 1)) {			total_used += right - MAP(i);		}	}#if defined( REISERFS_USE_OIDMAPF )	if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {		loff_t size = sb_info->oidmap.mapf->f_path.dentry->d_inode->i_size;		total_used += size / sizeof(reiserfs_oidinterval_d_t);	}#endif	seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",		   mapsize,		   mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);	return 0;}static int show_journal(struct seq_file *m, struct super_block *sb){	struct reiserfs_sb_info *r = REISERFS_SB(sb);	struct reiserfs_super_block *rs = r->s_rs;	struct journal_params *jp = &rs->s_v1.s_journal;	char b[BDEVNAME_SIZE];	seq_printf(m,		/* on-disk fields */		   "jp_journal_1st_block: \t%i\n"		   "jp_journal_dev: \t%s[%x]\n"		   "jp_journal_size: \t%i\n"		   "jp_journal_trans_max: \t%i\n"		   "jp_journal_magic: \t%i\n"		   "jp_journal_max_batch: \t%i\n"		   "jp_journal_max_commit_age: \t%i\n"		   "jp_journal_max_trans_age: \t%i\n"		   /* incore fields */		   "j_1st_reserved_block: \t%i\n"		   "j_state: \t%li\n"		   "j_trans_id: \t%lu\n"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -