From: Marko O. <d0...@us...> - 2011-01-23 13:19:15
|
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 5f6f7bea9fe13feb17d8b82e774b0128ba1a433c (commit) from 00dc235ac628ff542a43a25d667a44dcf1cc91f9 (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 5f6f7bea9fe13feb17d8b82e774b0128ba1a433c Author: Marko Obrovac <mar...@in...> Date: Sun Jan 23 15:14:51 2011 +0100 [ADD] The kdfs_convert utility Given a file on the kDFS file system, this utility prints out the physical path of the kDFS inode. Usage: kdfs_convert filename ... (a variable number of file names can be supplied) diff --git a/tools/Makefile.am b/tools/Makefile.am index b933e82..539886e 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -11,7 +11,7 @@ dist_sbin_SCRIPTS = krginit_helper krg_legacy_scheduler bin_PROGRAMS = migrate checkpoint restart krgcapset krgcr-run ipccheckpoint ipcrestart -sbin_PROGRAMS = krgadm krginit mkfs.kdfs kdfs_stat netclient +sbin_PROGRAMS = krgadm krginit mkfs.kdfs kdfs_stat netclient kdfs_convert INCLUDES = -I@top_srcdir@/libs/include LDADD = @top_builddir@/libs/libkerrighed/libkerrighed.la @top_builddir@/libs/libkrgcb/libkrgcb.la @@ -29,6 +29,7 @@ ipcrestart_SOURCES = ipcrestart.c mkfs_kdfs_SOURCES = mkfs_kdfs.c netclient_SOURCES = netclient.c kdfs_stat_SOURCES = kdfs_stat.c +kdfs_convert_SOURCES = kdfs_convert.c EXTRA_DIST = \ krginit_helper.conf \ diff --git a/tools/kdfs_convert.c b/tools/kdfs_convert.c new file mode 100644 index 0000000..56c42d7 --- /dev/null +++ b/tools/kdfs_convert.c @@ -0,0 +1,91 @@ +#include <unistd.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> + +/** from super.h **/ +#define KDFS_NODEID_MASK 0xFF000000 /* the nodeid in the ino */ +#define KDFS_INO_HIGH_MASK 0x00FFF000 /* the high part of the ino */ +#define KDFS_INO_LOW_MASK 0x00000FFF /* the low part of the ino */ +#define KDFS_EXTRACT_HIGH(x) (((x) & KDFS_INO_HIGH_MASK) >> 12) +#define KDFS_EXTRACT_LOW(x) ((x) & KDFS_INO_LOW_MASK) +/** for extracting the node id **/ +#define KDFS_EXTRACT_NODEID(x) (((x) & KDFS_NODEID_MASK) >> 24) + + +/** + * Prints the util's usage on the specified stream + * + * @prog the nme of the utility + * @fp the stream to output to + */ +void usage(char *prog, FILE *fp) { + + fprintf(fp, "Usage: %s filename ...", prog); + +} + + +/** + * Stats the file, etracts the ino and prints the result on the given stream + * + * @fname the file name in the kDFS system to stat + * @output the output stream on which to print the result + * + * @returns EXIT_SUCCESS on success, + * EXIT_FAILURE otherwise + */ +int print_kdfs_path(char *fname, FILE *output) { + + struct stat buf; + short nodeid, high, low; + + if (stat(fname, &buf) != 0) { + fprintf(output, "%s\n", fname); + return EXIT_FAILURE; + } + + nodeid = KDFS_EXTRACT_NODEID(buf.st_ino); + high = KDFS_EXTRACT_HIGH(buf.st_ino); + low = KDFS_EXTRACT_LOW(buf.st_ino); + + fprintf(output, "%s\t%u/%u/%u\n", fname, nodeid, high, low); + + return EXIT_SUCCESS; + +} + + +/** + * The entry point function + * + * @argc the number of arguments supplied on the command line + * @argv the arguments themselves + * + * @returns EXIT_SUCCESS on success, + * EXIT_FAILURE otherwise + */ +int main(int argc, char **argv) { + + int index, no_ok = 0; + + /* check that the user supplied at least one argument */ + if (argc == 1) { + usage(argv[0], stderr); + return EXIT_FAILURE; + } + + /* process all the filenames given on the command line */ + for(index = 1; index < argc; index++) { + if (print_kdfs_path(argv[index], stdout) == EXIT_SUCCESS) + no_ok++; + } + + if (no_ok > 0) + return EXIT_SUCCESS; + + return EXIT_FAILURE; + +} + ----------------------------------------------------------------------- Summary of changes: tools/Makefile.am | 3 +- tools/kdfs_convert.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletions(-) create mode 100644 tools/kdfs_convert.c hooks/post-receive -- UNNAMED PROJECT |