From: Marko O. <d0...@us...> - 2010-03-25 16:55:50
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "UNNAMED PROJECT". The branch, master has been updated via 4078b40ab923092c6ef6b49dac3e885bafadbe56 (commit) from 00d7530dbb8e59541120635b9a349954c1c0484e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4078b40ab923092c6ef6b49dac3e885bafadbe56 Author: Marko Obrovac <mar...@in...> Date: Thu Mar 25 18:53:59 2010 +0100 Add the kdfs_stat utility The kdfs_stat lists the extents found in the kdfs meta file as pointed to by the argument passed to it. Modify Makefile accordingly. diff --git a/scripts/Makefile.in b/scripts/Makefile.in index b55c34b..62d9529 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, diff --git a/tools/Makefile.am b/tools/Makefile.am index 4c48a7d..9ccb68d 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -11,7 +11,7 @@ sbindir=$(exec-prefix)/sbin dist_bin_SCRIPTS = krg_legacy_scheduler krgboot_helper krginit_helper -bin_PROGRAMS = migrate checkpoint restart krgadm krgcapset krgcr-run krgboot krginit ipccheckpoint ipcrestart netclient +bin_PROGRAMS = migrate checkpoint restart krgadm krgcapset krgcr-run krgboot krginit ipccheckpoint ipcrestart netclient kdfs_stat sbin_PROGRAMS = mkfs.kdfs INCLUDES = -I@top_srcdir@/libs/include @@ -29,6 +29,7 @@ ipccheckpoint_SOURCES = ipccheckpoint.c ipcrestart_SOURCES = ipcrestart.c mkfs_kdfs_SOURCES = mkfs_kdfs.c netclient_SOURCES = netclient.c +kdfs_stat_SOURCES = kdfs_stat.c EXTRA_DIST = krginit_helper.conf diff --git a/tools/kdfs_stat.c b/tools/kdfs_stat.c new file mode 100644 index 0000000..9eae9fd --- /dev/null +++ b/tools/kdfs_stat.c @@ -0,0 +1,77 @@ +#include <stdio.h> + + +typedef long long loff_t; +typedef unsigned long pgoff_t; +typedef short kdfs_node_t; +typedef unsigned short umode_t; +typedef unsigned int uid_t; +typedef unsigned int gid_t; + +struct timespec { + long tv_sec; + long tv_nsec; +}; + +struct kdfs_physical_inode { + loff_t size; + umode_t mode; + unsigned int nlink; + unsigned long version; + uid_t uid; + gid_t gid; + struct timespec atime; + struct timespec mtime; + struct timespec ctime; +}; + +struct kdfs_file_extent_info { + pgoff_t page_first; /* the first page no owned by a node */ + pgoff_t page_last; /* the last page no owned by a node */ + kdfs_node_t extent_owner; /* the node holding the pages contents */ +}; + + +int main(int argc, char **argv) { + + FILE *f; + struct kdfs_physical_inode kdfs_inode; + struct kdfs_file_extent_info info; + size_t no_extents, rec; + + if( argc == 1 ) { + fprintf( stderr, "Usage: %s <kdfs_meta_file_to_stat>\n", argv[0] ); + return 1; + } + + f = fopen( argv[1], "rb" ); + if( !f ) { + fprintf( stderr, "Error opening file %s.\n", argv[1] ); + return 1; + } + + /* read the kdfs inode info */ + fread( ( void * )&kdfs_inode, sizeof( struct kdfs_physical_inode ), 1, f ); + + if( !feof( f ) ) { + fread( ( void *)&no_extents, sizeof( size_t ), 1, f ); + fprintf( stdout, "Number of extent records found: %d\n\n", ( int )no_extents ); + if( no_extents > 0 ) { + fprintf( stdout, "+-----+---------------------+---------------------+---------------------+------+\n" ); + fprintf( stdout, "| Rec | Frst page in extent | Last page in extent | No of pages in ext | Node |\n" ); + fprintf( stdout, "+-----+---------------------+---------------------+---------------------+------+\n" ); + } + for( rec = 0; rec < no_extents; rec++ ) { + fread( ( void *)&info, sizeof( struct kdfs_file_extent_info ), 1, f ); + fprintf( stdout, "| %3d | %19lu | %19lu | %19lu | %4d |\n", ( int )rec, info.page_first, info.page_last, info.page_last - info.page_first + 1, info.extent_owner ); + } + fprintf( stdout, "+-----+---------------------+---------------------+---------------------+------+\n\n" ); + } else { + fprintf( stdout, "No extents info has been yet registered...\n" ); + } + + fclose( f ); + + return 0; + +} ----------------------------------------------------------------------- Summary of changes: scripts/Makefile.in | 2 +- tools/Makefile.am | 3 +- tools/kdfs_stat.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 tools/kdfs_stat.c hooks/post-receive -- UNNAMED PROJECT |