From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5267 invoked by alias); 9 Jun 2008 19:32:54 -0000 Received: (qmail 5233 invoked by uid 9582); 9 Jun 2008 19:32:54 -0000 Date: Mon, 09 Jun 2008 19:32:00 -0000 Message-ID: <20080609193254.5217.qmail@sourceware.org> From: rpeterso@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. cluster-2.99.04-6-g05b3793 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 4af22a3b269b517a542e38aaec5092cb2fcf202f X-Git-Newrev: 05b3793aa23b44f2c4c6e139f8fa3658eb6db311 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q2/txt/msg00452.txt.bz2 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 "Cluster Project". http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=05b3793aa23b44f2c4c6e139f8fa3658eb6db311 The branch, master has been updated via 05b3793aa23b44f2c4c6e139f8fa3658eb6db311 (commit) via cc3c26a4fef64eaee072ff62f4bb6194a6c2fa3d (commit) via 4b6c6cc589ef333235316f5813ef47cbe3e2b360 (commit) from 4af22a3b269b517a542e38aaec5092cb2fcf202f (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 05b3793aa23b44f2c4c6e139f8fa3658eb6db311 Author: Bob Peterson Date: Mon Jun 9 14:13:08 2008 -0500 Fix compiler warning. commit cc3c26a4fef64eaee072ff62f4bb6194a6c2fa3d Author: Bob Peterson Date: Mon Jun 9 13:52:50 2008 -0500 Ability to specify starting block or structure with -s commit 4b6c6cc589ef333235316f5813ef47cbe3e2b360 Author: Bob Peterson Date: Mon Jun 9 13:37:45 2008 -0500 Allow keywords in block number input ----------------------------------------------------------------------- Summary of changes: gfs2/edit/hexedit.c | 228 ++++++++++++++++++++++++------------------------- gfs2/edit/hexedit.h | 1 + gfs2/man/gfs2_edit.8 | 7 ++- 3 files changed, 119 insertions(+), 117 deletions(-) diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index 080daf4..99af162 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -712,6 +712,30 @@ void gfs_rgrp_print(struct gfs_rgrp *rg) } /* ------------------------------------------------------------------------ */ +/* get_rg_addr */ +/* ------------------------------------------------------------------------ */ +uint64_t get_rg_addr(int rgnum) +{ + struct gfs2_buffer_head *bh; + uint64_t rgblk = 0, block; + struct gfs2_inode *riinode; + + if (gfs1) + block = sbd1->sb_rindex_di.no_addr; + else + block = masterblock("rindex"); + bh = bread(&sbd, block); + riinode = inode_get(&sbd, bh); + if (rgnum < riinode->i_di.di_size / risize()) + rgblk = find_rgrp_block(riinode, rgnum); + else + fprintf(stderr, "Error: File system only has %lld RGs.\n", + riinode->i_di.di_size / risize()); + inode_put(riinode, not_updated); + return rgblk; +} + +/* ------------------------------------------------------------------------ */ /* set_rgrp_flags - Set an rgrp's flags to a given value */ /* rgnum: which rg to print or modify flags for (0 - X) */ /* new_flags: value to set new rg_flags to (if modify == TRUE) */ @@ -724,24 +748,10 @@ void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full) struct gfs2_rgrp rg2; struct gfs_rgrp rg1; } rg; - struct gfs2_buffer_head *bh, *ribh; - uint64_t rgblk, block; - struct gfs2_inode *riinode; + struct gfs2_buffer_head *bh; + uint64_t rgblk; - if (gfs1) - block = sbd1->sb_rindex_di.no_addr; - else - block = masterblock("rindex"); - ribh = bread(&sbd, block); - riinode = inode_get(&sbd, ribh); - if (rgnum >= riinode->i_di.di_size / risize()) { - fprintf(stderr, "Error: File system only has %lld RGs.\n", - riinode->i_di.di_size / risize()); - inode_put(riinode, not_updated); - brelse(ribh, not_updated); - return; - } - rgblk = find_rgrp_block(riinode, rgnum); + rgblk = get_rg_addr(rgnum); bh = bread(&sbd, rgblk); if (gfs1) gfs_rgrp_in(&rg.rg1, bh->b_data); @@ -773,7 +783,6 @@ void set_rgrp_flags(int rgnum, uint32_t new_flags, int modify, int full) (unsigned long long)rgblk, rg.rg2.rg_flags); brelse(bh, not_updated); } - inode_put(riinode, not_updated); if (modify) bsync(&sbd); } @@ -1621,6 +1630,65 @@ uint64_t pop_block(void) } /* ------------------------------------------------------------------------ */ +/* Check if the word is a keyword such as "sb" or "rindex" */ +/* Returns: block number if it is, else 0 */ +/* ------------------------------------------------------------------------ */ +uint64_t check_keywords(const char *kword) +{ + uint64_t blk = 0; + + if (!strcmp(kword, "sb") ||!strcmp(kword, "superblock")) + blk = 0x10 * (4096 / sbd.bsize); /* superblock */ + else if (!strcmp(kword, "root") || !strcmp(kword, "rootdir")) + blk = sbd.sd_sb.sb_root_dir.no_addr; + else if (!strcmp(kword, "master")) { + if (!gfs1) + blk = sbd.sd_sb.sb_master_dir.no_addr; + else + fprintf(stderr, "This is GFS1; there's no master directory.\n"); + } + else if (!strcmp(kword, "jindex")) { + if (gfs1) + blk = sbd1->sb_jindex_di.no_addr; + else + blk = masterblock("jindex"); /* journal index */ + } + else if (!gfs1 && !strcmp(kword, "per_node")) + blk = masterblock("per_node"); + else if (!gfs1 && !strcmp(kword, "inum")) + blk = masterblock("inum"); + else if (!strcmp(kword, "statfs")) { + if (gfs1) + blk = gfs1_license_di.no_addr; + else + blk = masterblock("statfs"); + } + else if (!strcmp(kword, "rindex") || !strcmp(kword, "rgindex")) { + if (gfs1) + blk = sbd1->sb_rindex_di.no_addr; + else + blk = masterblock("rindex"); + } else if (!strcmp(kword, "rgs")) { + blk = RGLIST_DUMMY_BLOCK; + } else if (!strcmp(kword, "quota")) { + if (gfs1) + blk = gfs1_quota_di.no_addr; + else + blk = masterblock("quota"); + } else if (!strncmp(kword, "rg ", 3)) { + int rgnum = 0; + + rgnum = atoi(kword + 3); + blk = get_rg_addr(rgnum); + } else if (kword[0]=='0' && kword[1]=='x') /* hex addr */ + sscanf(kword, "%"SCNx64, &blk);/* retrieve in hex */ + else + sscanf(kword, "%" PRIu64, &blk); /* retrieve decimal */ + + return blk; +} + +/* ------------------------------------------------------------------------ */ /* goto_block - go to a desired block entered by the user */ /* ------------------------------------------------------------------------ */ uint64_t goto_block(void) @@ -1631,32 +1699,8 @@ uint64_t goto_block(void) memset(string, 0, sizeof(string)); sprintf(string,"%"PRId64, block); if (bobgets(string, 1, 7, 16, &ch)) { - if (!strcmp(string,"root")) - temp_blk = sbd.sd_sb.sb_root_dir.no_addr; - else if (!strcmp(string,"master")) { - if (!gfs1) - temp_blk = sbd.sd_sb.sb_master_dir.no_addr; - else - ; /* maybe put out an error message at some point */ - } - else if (isalpha(string[0])) { - if (gfs1) { - if (!strcmp(string, "jindex")) - temp_blk = sbd1->sb_jindex_di.no_addr; - else if (!strcmp(string, "rindex")) - temp_blk = sbd1->sb_rindex_di.no_addr; - else if (!strcmp(string, "quota")) - temp_blk = gfs1_quota_di.no_addr; - else if (!strcmp(string, "rgs")) - temp_blk = RGLIST_DUMMY_BLOCK; - } - else { - if (!strcmp(string, "rgs")) - temp_blk = RGLIST_DUMMY_BLOCK; - else - temp_blk = masterblock(string); - } - } + if (isalnum(string[0])) + temp_blk = check_keywords(string); else if (string[0] == '+') { if (string[1] == '0' && string[2] == 'x') sscanf(string, "%"SCNx64, &temp_blk); @@ -1671,10 +1715,6 @@ uint64_t goto_block(void) sscanf(string, "%" PRIu64, &temp_blk); temp_blk -= block; } - else if (string[0] == '0' && string[1] == 'x') - sscanf(string, "%"SCNx64, &temp_blk); /* retrieve in hex */ - else - sscanf(string, "%" PRIu64, &temp_blk); /* retrieve decimal */ if (temp_blk == RGLIST_DUMMY_BLOCK || temp_blk < max_block) { offset = 0; @@ -2317,6 +2357,7 @@ void usage(void) fprintf(stderr," rg X - print resource group X.\n"); fprintf(stderr," rgs - prints all the resource groups (rgs).\n"); fprintf(stderr," quota - prints the quota file.\n"); + fprintf(stderr,"-s specifies a starting block such as root, rindex, quota, inum.\n"); fprintf(stderr,"-x print in hexmode.\n"); fprintf(stderr,"-h prints this help.\n\n"); fprintf(stderr,"Examples:\n"); @@ -2394,8 +2435,25 @@ void process_parameters(int argc, char *argv[], int pass) strcpy(device, argv[i]); } else { /* second pass */ - if (!termlines && !strchr(argv[i],'/')) { /* if print, no slash */ - if (!strcasecmp(argv[i], "-x")) + if (!strcasecmp(argv[i], "-s")) { + i++; + if (i >= argc - 1) { + printf("Error: starting block not specified with -s.\n"); + printf("%s -s [starting block | keyword] \n", + argv[0]); + printf("For example: %s -s \"rg 3\" /dev/exxon_vg/exxon_lv\n", + argv[0]); + exit(EXIT_FAILURE); + } + starting_blk = check_keywords(argv[i]); + } + else if (!termlines && !strchr(argv[i],'/')) { /* if print, no slash */ + uint64_t keyword_blk; + + keyword_blk = check_keywords(argv[i]); + if (keyword_blk) + push_block(keyword_blk); + else if (!strcasecmp(argv[i], "-x")) dmode = HEX_MODE; else if (argv[i][0] == '-') /* if it starts with a dash */ ; /* ignore it--meant for pass == 0 */ @@ -2404,64 +2462,6 @@ void process_parameters(int argc, char *argv[], int pass) else if (!strcmp(argv[i], "size")) printf("Device size: %" PRIu64 " (0x%" PRIx64 ")\n", max_block, max_block); - else if (!strcmp(argv[i], "sb") || - !strcmp(argv[i], "superblock")) - push_block(0x10 * (4096 / sbd.bsize)); /* superblock */ - else if (!strcmp(argv[i], "root") || - !strcmp(argv[i], "rootdir")) - push_block(sbd.sd_sb.sb_root_dir.no_addr); - else if (!strcmp(argv[i], "master")) { - if (gfs1) { - fprintf(stderr, "Error: 'master' is invalid " - "for GFS (1) file systems.\n"); - exit(-1); - } - push_block(sbd.sd_sb.sb_master_dir.no_addr); - } - else if (!strcmp(argv[i], "jindex")) { - if (gfs1) - push_block(sbd1->sb_jindex_di.no_addr); - else - push_block(masterblock("jindex"));/* journal index */ - } - else if (!strcmp(argv[i], "per_node")) { - if (gfs1) { - fprintf(stderr, "Error: 'per_node' is invalid " - "for GFS (1) file systems.\n"); - exit(-1); - } - push_block(masterblock("per_node")); - } - else if (!strcmp(argv[i], "inum")) { - if (gfs1) { - fprintf(stderr, "Error: 'inum' is invalid " - "for GFS (1) file systems.\n"); - exit(-1); - } - push_block(masterblock("inum")); - } - else if (!strcmp(argv[i], "statfs")) { - if (gfs1) - push_block(gfs1_license_di.no_addr); - else - push_block(masterblock("statfs")); - } - else if (!strcmp(argv[i], "rindex") || - !strcmp(argv[i], "rgindex")) { - if (gfs1) - push_block(sbd1->sb_rindex_di.no_addr); - else - push_block(masterblock("rindex")); - } - else if (!strcmp(argv[i], "rgs")) { - push_block(RGLIST_DUMMY_BLOCK); - } - else if (!strcmp(argv[i], "quota")) { - if (gfs1) - push_block(gfs1_quota_di.no_addr); - else - push_block(masterblock("quota")); - } else if (!strcmp(argv[i], "rgcount")) rgcount(); else if (!strcmp(argv[i], "rgflags")) { @@ -2519,10 +2519,6 @@ void process_parameters(int argc, char *argv[], int pass) savemeta(argv[i+2], 1); else if (!strcasecmp(argv[i], "savergs")) savemeta(argv[i+2], 2); - else if (argv[i][0]=='0' && argv[i][1]=='x') { /* hex addr */ - sscanf(argv[i], "%"SCNx64, &temp_blk);/* retrieve in hex */ - push_block(temp_blk); - } else if (isdigit(argv[i][0])) { /* decimal addr */ sscanf(argv[i], "%"SCNd64, &temp_blk); push_block(temp_blk); @@ -2570,7 +2566,7 @@ int main(int argc, char *argv[]) dmode = HEX_MODE; sbd.bsize = 4096; type_alloc(buf, char, sbd.bsize); /* allocate/malloc a new 4K buffer */ - block = 0x10; + block = starting_blk = 0x10; for (i = 0; i < BLOCK_STACK_SIZE; i++) { blockstack[i].dmode = dmode; blockstack[i].block = block; @@ -2596,13 +2592,13 @@ int main(int argc, char *argv[]) read_superblock(fd); max_block = lseek(fd, 0, SEEK_END) / sbd.bsize; - blockstack[0].block = 0x10 * (4096 / sbd.bsize); strcpy(sbd.device_name, device); if (!gfs1) read_master_dir(); block_in_mem = -1; - if (!termlines) /* if printing to stdout */ - process_parameters(argc, argv, 1); /* get what to print from cmdline */ + process_parameters(argc, argv, 1); /* get what to print from cmdline */ + + block = blockstack[0].block = starting_blk * (4096 / sbd.bsize); if (termlines) interactive_mode(); diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h index 0afe1e3..2486b04 100644 --- a/gfs2/edit/hexedit.h +++ b/gfs2/edit/hexedit.h @@ -87,6 +87,7 @@ EXTERN WINDOW *wind; EXTERN int gfs1 INIT(0); EXTERN int editing INIT(0); EXTERN uint64_t temp_blk; +EXTERN uint64_t starting_blk; struct gfs_jindex { uint64_t ji_addr; /* starting block of the journal */ diff --git a/gfs2/man/gfs2_edit.8 b/gfs2/man/gfs2_edit.8 index 3565680..0be8bf8 100644 --- a/gfs2/man/gfs2_edit.8 +++ b/gfs2/man/gfs2_edit.8 @@ -42,7 +42,7 @@ You can specify the following data structure names with the -p option. \fIrindex\fR, \fIrgindex\fR - Print the resource group index system file. -\fIrg X\fR - Print the resource group information for RG X. +\fIrg X\fR - Print the resource group information for RG X (zero-based). \fIrgs\fR - Print the resource group information. @@ -71,6 +71,11 @@ For example, "gfs2_edit -p inum statfs /dev/sda1" prints the system inum file and the system statfs file on /dev/sda1. .TP +\fB-s\fP [\fIstructure\fR | \fIblock\fR] +Specify a starting block for interactive mode. Any of the keywords found +in the -p option may be specified. If you want to start on a particular +resource group, specify it in quotes. For example, gfs2_edit -s "rg 3" +.TP \fB-h, -help, -usage\fP Print help information. .TP hooks/post-receive -- Cluster Project