Changeset 8397 for branches/cu-security-branch/src/apps/admin
- Timestamp:
- 06/18/10 20:02:50 (3 years ago)
- Location:
- branches/cu-security-branch
- Files:
-
- 2 added
- 14 modified
-
. (modified) (1 prop)
-
src/apps/admin (modified) (1 prop)
-
src/apps/admin/pvfs2-change-fsid.c (modified) (8 diffs)
-
src/apps/admin/pvfs2-check-config.c (modified) (1 diff)
-
src/apps/admin/pvfs2-cp.c (modified) (1 diff)
-
src/apps/admin/pvfs2-fs-dump.c (modified) (1 diff)
-
src/apps/admin/pvfs2-fsck.c (modified) (3 diffs)
-
src/apps/admin/pvfs2-genconfig (modified) (26 diffs)
-
src/apps/admin/pvfs2-getmattr (added)
-
src/apps/admin/pvfs2-ls.c (modified) (28 diffs)
-
src/apps/admin/pvfs2-migrate-collection.c (modified) (32 diffs)
-
src/apps/admin/pvfs2-mkspace.c (modified) (9 diffs)
-
src/apps/admin/pvfs2-setmattr (added)
-
src/apps/admin/pvfs2-showcoll.c (modified) (8 diffs)
-
src/apps/admin/pvfs2-stat.c (modified) (4 diffs)
-
src/apps/admin/pvfs2-xattr.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cu-security-branch
- Property svn:ignore
-
old new 3 3 aclocal.m4 4 4 autom4te.cache 5 config.status6 Makefile7 pvfs2-config.h8 module.mk
-
- Property svn:ignore
-
branches/cu-security-branch/src/apps/admin
- Property svn:ignore deleted
-
branches/cu-security-branch/src/apps/admin/pvfs2-change-fsid.c
r7941 r8397 39 39 char fs_conf[PATH_MAX]; 40 40 char fs_name[PATH_MAX]; 41 char storage_path[PATH_MAX]; 41 char data_storage_path[PATH_MAX]; 42 char meta_storage_path[PATH_MAX]; 42 43 int32_t old_fsid; 43 44 int32_t new_fsid; … … 314 315 { 315 316 FILE * fptr = NULL; 316 char command[PATH_MAX]; 317 char output[PATH_MAX]; 317 char datacommand[PATH_MAX]; 318 char metacommand[PATH_MAX]; 319 char dataoutput[PATH_MAX]; 320 char metaoutput[PATH_MAX]; 318 321 struct stat buf; 319 char path[PATH_MAX]; 320 char new_path[PATH_MAX]; 322 char datapath[PATH_MAX]; 323 char new_datapath[PATH_MAX]; 324 char metapath[PATH_MAX]; 325 char new_metapath[PATH_MAX]; 321 326 int ret = 0; 322 327 323 memset(path,0,sizeof(path)); 324 sprintf(path,"%s/%s", opts.storage_path, opts.old_fsid_hex); 325 326 /* See if directory exists */ 327 ret = stat(path, &buf); 328 memset(datapath, 0, sizeof(datapath)); 329 memset(metapath, 0, sizeof(metapath)); 330 sprintf(datapath, "%s%s", opts.data_storage_path, opts.old_fsid_hex); 331 sprintf(metapath, "%s/%s", opts.meta_storage_path, opts.old_fsid_hex); 332 333 /* See if each directory exists */ 334 ret = stat(datapath, &buf); 328 335 if(ret) 329 336 { 330 337 fprintf(stderr, 331 "Error checking for directory's existance. [%s]\n", 332 path); 338 "Error checking for data directory's existance. [%s]\n", 339 datapath); 340 return -1; 341 } 342 ret = stat(metapath, &buf); 343 if(ret) 344 { 345 fprintf(stderr, 346 "Error checking for meta directory's existance. [%s]\n", 347 metapath); 333 348 return -1; 334 349 } … … 341 356 } 342 357 343 memset(command,0,sizeof(command)); 344 memset(output,0,sizeof(output)); 345 memset(new_path,0,sizeof(new_path)); 346 347 /* Move the directory */ 348 sprintf(new_path, "%s/%s", opts.storage_path, opts.new_fsid_hex); 349 sprintf(command, "mv %s %s", path, new_path); 350 351 fptr = popen(command, "r"); 358 memset(datacommand, 0, sizeof(datacommand)); 359 memset(metacommand, 0, sizeof(metacommand)); 360 memset(dataoutput, 0, sizeof(dataoutput)); 361 memset(metaoutput, 0, sizeof(metaoutput)); 362 memset(new_datapath, 0, sizeof(new_datapath)); 363 memset(new_metapath, 0, sizeof(new_metapath)); 364 365 /* Move the directories */ 366 sprintf(new_datapath, "%s/%s", opts.data_storage_path, opts.new_fsid_hex); 367 sprintf(new_metapath, "%s%s", opts.meta_storage_path, opts.new_fsid_hex); 368 sprintf(datacommand, "mv %s %s", datapath, new_datapath); 369 sprintf(metacommand, "mv %s %s", metapath, new_metapath); 370 371 /* move the data dir */ 372 fptr = popen(datacommand, "r"); 352 373 if(fptr == NULL) 353 374 { … … 355 376 exit(-1); 356 377 } 357 ret = fscanf(fptr, "%s", output);358 if(ret && strncmp( output,"",PATH_MAX))359 { 360 printf("mv from [%s] to [%s] failed.\n", path, new_path);378 ret = fscanf(fptr, "%s", dataoutput); 379 if(ret && strncmp(dataoutput,"",PATH_MAX)) 380 { 381 printf("mv from [%s] to [%s] failed.\n", datapath, new_datapath); 361 382 return -1; 362 383 } 363 384 pclose(fptr); 364 385 386 /* move the meta dir */ 387 fptr = popen(metacommand, "r"); 388 if(fptr == NULL) 389 { 390 fprintf(stderr,"Error opening pipe. errno=%d",errno); 391 exit(-1); 392 } 393 ret = fscanf(fptr, "%s", metaoutput); 394 if(ret && strncmp(metaoutput,"",PATH_MAX)) 395 { 396 printf("mv from [%s] to [%s] failed.\n", metapath, new_metapath); 397 return -1; 398 } 399 pclose(fptr); 400 365 401 if(opts.verbose) 366 402 { 367 printf("Successful dir move from [%s] to [%s]\n", path, new_path); 403 printf("Successful data dir move from [%s] to [%s]\n", datapath, new_datapath); 404 printf("Successful meta dir move from [%s] to [%s]\n", metapath, new_metapath); 368 405 } 369 406 … … 517 554 {"dbpath",1,0,0}, 518 555 {"fsconf",1,0,0}, 519 {"storage",1,0,0}, 556 {"datastorage",1,0,0}, 557 {"metastorage",1,0,0}, 520 558 {"view",0,0,0}, 521 559 {0,0,0,0} … … 562 600 break; 563 601 564 case 7: /* storage */ 565 strncpy(opts.storage_path, optarg, PATH_MAX); 566 break; 567 568 case 8: /* view */ 602 case 7: /* data storage */ 603 strncpy(opts.data_storage_path, optarg, PATH_MAX); 604 break; 605 606 case 8: /* meta storage */ 607 strncpy(opts.meta_storage_path, optarg, PATH_MAX); 608 break; 609 610 case 9: /* view */ 569 611 opts.view_only = 1; 570 612 break; … … 593 635 } 594 636 595 /* storage_path must be set */ 596 if(!strncmp(opts.storage_path,"",PATH_MAX)) 597 { 598 fprintf(stderr,"Error: --storage option must be given.\n"); 637 /* data storage_path must be set */ 638 if(!strncmp(opts.data_storage_path,"",PATH_MAX)) 639 { 640 fprintf(stderr,"Error: --datastorage option must be given.\n"); 641 print_help(argv[0]); 642 return(-1); 643 } 644 645 /* meta storage_path must be set */ 646 if(!strncmp(opts.meta_storage_path,"",PATH_MAX)) 647 { 648 fprintf(stderr,"Error: --metastorage option must be given.\n"); 599 649 print_help(argv[0]); 600 650 return(-1); … … 613 663 fprintf(stderr," --fsconf=</path/to/pvfs2-fs.conf> " 614 664 "Fs config file for the the file system being modified.\n"); 615 fprintf(stderr," --storage=</path/to/pvfs2-storage-space> " 616 "Local storage space for the the file system being modified.\n"); 665 fprintf(stderr," --datastorage=</path/to/pvfs2-data-storage-space> " 666 "Local data storage space for the the file system being modified.\n"); 667 fprintf(stderr," --metastorage=</path/to/pvfs2-meta-storage-space> " 668 "Local meta storage space for the the file system being modified.\n"); 617 669 fprintf(stderr, "\n"); 618 670 fprintf(stderr,"The following arguments are optional:\n"); -
branches/cu-security-branch/src/apps/admin/pvfs2-check-config.c
r8339 r8397 129 129 return -1; 130 130 } 131 131 132 132 /* Construct the list of mount points */ 133 133 mnt = PVFS_util_parse_pvfstab(0); -
branches/cu-security-branch/src/apps/admin/pvfs2-cp.c
r8358 r8397 304 304 "\n-s <strip_size>\t\t\tsize of access to PVFS2 volume" 305 305 "\n-n <num_datafiles>\t\tnumber of PVFS2 datafiles to use" 306 "\n-b <buffer_size >\t\thow much data to read/write at once"306 "\n-b <buffer_size in bytes>\thow much data to read/write at once" 307 307 "\n-t\t\t\t\tprint some timing information" 308 308 "\n-v\t\t\t\tprint version number and exit\n"); -
branches/cu-security-branch/src/apps/admin/pvfs2-fs-dump.c
r8358 r8397 361 361 { 362 362 PVFS_util_refresh_credential(creds); 363 ret = PVFS_mgmt_iterate_handles_list(cur_fs,363 ret = PVFS_mgmt_iterate_handles_list(cur_fs, 364 364 creds, 365 365 handle_matrix, -
branches/cu-security-branch/src/apps/admin/pvfs2-fsck.c
r8358 r8397 900 900 PVFS_sysresp_getattr getattr_resp; 901 901 902 PVFS_util_refresh_credential(creds);902 PVFS_util_refresh_credential(creds); 903 903 904 904 handle_ref.handle = handle; … … 983 983 PVFS_sysresp_getattr getattr_resp; 984 984 985 PVFS_util_refresh_credential(creds);985 PVFS_util_refresh_credential(creds); 986 986 987 987 handle_ref.handle = handle; … … 1096 1096 PVFS_sysresp_getattr getattr_resp; 1097 1097 1098 PVFS_util_refresh_credential(creds);1098 PVFS_util_refresh_credential(creds); 1099 1099 1100 1100 handle_ref.handle = handle; -
branches/cu-security-branch/src/apps/admin/pvfs2-genconfig
r8330 r8397 10 10 use Getopt::Long; 11 11 use Math::BigInt; 12 use File::Basename;13 use Cwd 'abs_path';;14 12 15 13 # turn on strictness … … 31 29 my $opt_logfile = ''; 32 30 my $opt_storage = ''; 33 my $opt_pubkey = '';34 my $opt_privkey = '';35 31 my $opt_trovesync = '1'; 36 32 my $opt_trovemethod = ''; … … 61 57 62 58 my $default_storage = undef; 59 my $default_meta_storage = undef; 63 60 my $default_logfile = undef; 64 my $default_pubkey = undef;65 my $default_privkey = undef;66 my $security_flag = '';67 61 68 62 my $bmi_module = undef; … … 75 69 my $OUT = undef; 76 70 my $term = undef; 77 my $dirname = undef;78 71 79 72 #$num_unexp_reqs = prompt_num("How many unexpected requests should we be prepared to receive? "); … … 158 151 # 159 152 @components = $inputline =~ /(?:,?[ ]*([^{,]+(?:{[^}]+})?[^,]*))/g; 160 foreach my $comp (@components) 161 { 153 foreach my $comp_ws (@components) 154 { 155 my $comp; 156 157 # Trim leading and trailing whitespace 158 $comp = $comp_ws; 159 $comp =~ s/^\s+//; 160 $comp =~ s/\s+$//; 161 162 162 # if we've got a component that has {..}, then expand. 163 163 # match the prefix (hostname) and curly brackets … … 217 217 if(defined($default_storage)) 218 218 { 219 print $target "\n\tStorageSpace " . $default_storage . "\n"; 219 print $target "\n\tDataStorageSpace " . $default_storage . "\n"; 220 } 221 222 if(defined($default_meta_storage)) 223 { 224 print $target "\tMetadataStorageSpace " . $default_meta_storage . "\n\n"; 220 225 } 221 226 … … 228 233 { 229 234 print $target "\tTCPBindSpecific yes\n"; 230 }231 232 if(!($default_pubkey eq ""))233 {234 print $target "\tKeyStore " . $default_pubkey . "\n";235 }236 237 if(!($default_privkey eq ""))238 {239 print $target "\tServerKey " . $default_privkey . "\n";240 235 } 241 236 … … 391 386 print $target "\n<ServerOptions>\n"; 392 387 print $target "\tServer $alias\n"; 393 print $target "\tStorageSpace $endpoint->{STORAGE}\n"; 388 print $target "\tDataStorageSpace $endpoint->{STORAGE}\n"; 389 print $target "\tMetadataStorageSpace $endpoint->{METASTORAGE}\n"; 394 390 print $target "\tLogFile $endpoint->{LOGFILE}\n"; 395 391 print $target "</ServerOptions>\n"; … … 400 396 sub emit_server_conf 401 397 { 402 my($target, $node, $storage, $logfile) = @_; 403 404 print $target "StorageSpace $storage\n"; 398 my($target, $node, $storage, $metastorage, $logfile) = @_; 399 400 print $target "DataStorageSpace $storage\n"; 401 print $target "MetadataStorageSpace $metastorage\n"; 405 402 print $target "HostID \"" . get_bmi_endpoint($node) . "\"\n"; 406 403 print $target "LogFile $logfile\n"; … … 853 850 } 854 851 855 sub get_ pubkey856 { 857 my $ pubkey = $dirname . "/keystore";858 if ($opt_ pubkey) {859 $ pubkey = $opt_pubkey;852 sub get_meta_storage 853 { 854 my $metastorage = "/pvfs2-storage-space"; 855 if ($opt_storage) { 856 $metastorage = $opt_storage; 860 857 } elsif (!$opt_quiet) { 861 if($security_flag eq "") 862 { 863 print $OUT "Choose whether or not you compiled with encryption enabled.\n"; 864 $security_flag = prompt_word("Did you compile with encryption [Default is n]? ","n"); 865 } 866 if(($security_flag eq "n" or $security_flag eq "no")) 867 { 868 return ""; 869 } 870 print $OUT "Choose the path to the public key file.\n"; 871 $pubkey = prompt_word("Enter public key file path: [Default is " . $dirname . "/keystore]: ",$dirname . "/keystore"); 872 } 873 return $pubkey; 874 } 875 876 sub get_privkey 877 { 878 if(($security_flag eq "n" or $security_flag eq "no")) 879 { 880 return ""; 881 } 882 my $privkey = $dirname . "/privkey.pem"; 883 if ($opt_privkey) { 884 $privkey = $opt_privkey; 885 } elsif (!$opt_quiet) { 886 print $OUT "Choose the path to the private key file.\n"; 887 $privkey = prompt_word("Enter private key file path: [Default is " . $dirname . "/privkey.pem]: ",$dirname . "/privkey.pem"); 888 } 889 return $privkey; 890 } 891 858 print $OUT "Choose a directory for each server to store metadata in.\n"; 859 $metastorage = prompt_word("Enter directory name: [Default is /pvfs2-storage-space]: ","/pvfs2-storage-space"); 860 } 861 return $metastorage; 862 } 892 863 893 864 # get host port … … 995 966 my $portmap = shift; 996 967 my $storage = shift; 968 my $metastorage = shift; 997 969 my $logfile = shift; 998 my $pubkey = shift;999 my $privkey = shift;1000 970 my $ioline = ''; 1001 971 if ($opt_ioservers) { … … 1026 996 HOSTNAME => $io_host, 1027 997 PORTMAP => $portmap, 1028 STORAGE => $storage, 1029 LOGFILE => $logfile, 1030 PUBKEY => $pubkey, 1031 PRIVKEY => $privkey}; 998 STORAGE => $storage, 999 METASTORAGE => $metastorage, 1000 LOGFILE => $logfile}; 1032 1001 } 1033 1002 } … … 1038 1007 my $portmap = shift; 1039 1008 my $storage = shift; 1009 my $metastorage = shift; 1040 1010 my $logfile = shift; 1041 my $pubkey = shift;1042 my $privkey = shift;1043 1011 my $metaline = ''; 1044 1012 my @meta_hosts; … … 1085 1053 HOSTNAME => $meta_host, 1086 1054 PORTMAP => $portmap, 1087 STORAGE => $storage, 1088 LOGFILE => $logfile, 1089 PUBKEY => $pubkey, 1090 PRIVKEY => $privkey}; 1055 STORAGE => $storage, 1056 METASTORAGE => $metastorage, 1057 LOGFILE => $logfile}; 1091 1058 } 1092 1059 } … … 1116 1083 { 1117 1084 my $stor = undef; 1085 my $mstor = undef; 1118 1086 my $logf = undef; 1119 1087 my $proto = undef; … … 1126 1094 # endpoint. We want to match on [...]:storage:logfile 1127 1095 # and place the stuff between the [] in $1, and optionally 1128 # place the matched storage path and logfile in $2 and $3 1096 # place the matched storage path and meta path in $2 and $3, 1097 # logfile is in $4 1129 1098 # 1130 1099 $ep =~ /\[([^\]]+)\](?::([^:]+))?(?::([^:]+))?/; 1131 1100 1132 1101 $stor = $2; 1133 $logf = $3; 1102 $mstor = $3; 1103 $logf = $4; 1134 1104 1135 1105 if(!defined($1)) … … 1182 1152 HOSTNAME => $hostname, 1183 1153 PORTMAP => \%port, 1184 STORAGE => $stor, 1154 STORAGE => $stor, 1155 METASTORAGE => $mstor, 1185 1156 LOGFILE => $logf}; 1186 1157 } … … 1229 1200 my $pranges = $4; 1230 1201 $stor = $5; 1231 $logf = $6; 1202 $mstor = $6; 1203 $logf = $7; 1232 1204 1233 1205 if($proto !~ /mx/) 1234 1206 { 1235 1207 $logf = $stor; 1236 $stor = $pranges; 1208 $stor = $mstor; 1209 $mstor = $pranges; 1237 1210 $pranges = $branges; 1238 1211 $branges = undef; … … 1276 1249 PORTMAP => $portmap, 1277 1250 STORAGE => $stor, 1251 METASTORAGE => $mstor, 1278 1252 LOGFILE => $logf}; 1279 1253 } … … 1297 1271 PORTMAP => $portmap, 1298 1272 STORAGE => $stor, 1273 METASTORAGE => $mstor, 1299 1274 LOGFILE => $logf}; 1300 1275 } … … 1335 1310 PORTMAP => $portmap, 1336 1311 STORAGE => $stor, 1312 METASTORAGE => $mstor, 1337 1313 LOGFILE => $logf}; 1338 1314 } … … 1456 1432 'client-job-timeout=i' => \$opt_client_job_timeout, 1457 1433 'storage=s' => \$opt_storage, 1458 'pubkey=s' => \$opt_pubkey,1459 'privkey=s' => \$opt_privkey,1460 1434 'help' => \$show_help, 1461 1435 'quiet!' => \$opt_quiet, … … 1526 1500 } 1527 1501 $output_target = \*FILEOUT; 1528 $dirname = abs_path(dirname($ARGV[0]));1529 1502 } 1530 1503 … … 1554 1527 1555 1528 $default_storage = get_storage(); 1529 $default_meta_storage = get_meta_storage(); 1556 1530 $default_logfile = get_logfile(); 1557 $default_pubkey = get_pubkey(); 1558 $default_privkey = get_privkey(); 1559 1560 get_ionames($portmap, $default_storage, $default_logfile, $default_pubkey, $default_privkey); 1561 get_metanames($portmap, $default_storage, $default_logfile, $default_pubkey, $default_privkey); 1531 1532 get_ionames($portmap, $default_storage, $default_logfile); 1533 get_metanames($portmap, $default_meta_storage, $default_logfile); 1562 1534 } 1563 1535 … … 1575 1547 } 1576 1548 1549 if(needs_default_value(METASTORAGE)) 1550 { 1551 if(!defined($default_meta_storage)) 1552 { 1553 $default_meta_storage = get_meta_storage(); 1554 } 1555 set_default_value(METASTORAGE, $default_meta_storage); 1556 set_default_value(METASTORAGE, $default_meta_storage); 1557 } 1558 1577 1559 if(needs_default_value(LOGFILE)) 1578 1560 { … … 1584 1566 set_default_value(LOGFILE, $default_logfile); 1585 1567 set_default_value(LOGFILE, $default_logfile); 1586 }1587 1588 if(needs_default_value(PUBKEY))1589 {1590 if(!defined($default_pubkey))1591 {1592 $default_pubkey = get_pubkey();1593 }1594 1595 set_default_value(PUBKEY, $default_pubkey);1596 set_default_value(PUBKEY, $default_pubkey);1597 }1598 1599 if(needs_default_value(PRIVKEY))1600 {1601 if(!defined($default_pubkey))1602 {1603 $default_privkey = get_privkey();1604 }1605 1606 set_default_value(PRIVKEY, $default_privkey);1607 set_default_value(PRIVKEY, $default_privkey);1608 1568 } 1609 1569 -
branches/cu-security-branch/src/apps/admin/pvfs2-ls.c
r8351 r8397 30 30 * is in place to break up large readdirs into multiple operations 31 31 */ 32 #define MAX_NUM_DIRENTS 113 32 /* MAX_NUM_DIRENTS cannot be any larger than PVFS_REQ_LIMIT_LISTATTR */ 33 #define MAX_NUM_DIRENTS 60 34 35 /* 36 Define the maximum length of a single line of output. This is about the 37 size of 256 maximum path segments, a file name, and attributes. 38 */ 39 #define ENTRY_MAX 66560 33 40 34 41 /* … … 37 44 */ 38 45 #define MAX_NUM_PATHS 8 46 47 /* 48 Max length of the fully formatted date/time fields 49 */ 50 #define MAX_TIME_LENGTH 128 51 52 /* 53 Length of the formatted date/time for --all-times option 54 */ 55 #define ALL_TIMES_LENGTH 25 39 56 40 57 /* optional parameters, filled in by parse_args() */ … … 52 69 int list_no_owner; 53 70 int list_inode; 71 int list_all_times; 54 72 int list_use_si_units; 55 73 char *start[MAX_NUM_PATHS]; … … 77 95 PVFS_sys_attr *attr, 78 96 int attr_error, 79 struct options *opts); 97 struct options *opts, 98 char* entry_buffer); 80 99 81 100 static int do_list( … … 83 102 char *start, 84 103 int fs_id, 85 struct options *opts); 104 struct options *opts, 105 char *entry_buffer); 86 106 87 107 static void print_entry_attr( … … 89 109 char *entry_name, 90 110 PVFS_sys_attr *attr, 91 struct options *opts); 111 struct options *opts, 112 char *entry_buffer); 92 113 93 114 #define print_dot_and_dot_dot_info_if_required(refn) \ … … 107 128 else if (opts->list_long) { \ 108 129 print_entry(".", refn.handle, \ 109 refn.fs_id, NULL, 0, opts); \ 130 refn.fs_id, NULL, 0, opts, \ 131 entry_buffer); \ 110 132 print_entry(".. (faked)", refn.handle, \ 111 refn.fs_id, NULL, 0, opts); \ 133 refn.fs_id, NULL, 0, opts, \ 134 entry_buffer); \ 112 135 } \ 113 136 else { \ … … 189 212 char *entry_name, 190 213 PVFS_sys_attr *attr, 191 struct options *opts) 214 struct options *opts, 215 char *entry_buffer) 192 216 { 193 char buf[128] = {0},*formatted_size = NULL;194 char *formatted_owner = NULL, *formatted_group = NULL ;217 char *formatted_size = NULL; 218 char *formatted_owner = NULL, *formatted_group = NULL, *formatted_time = NULL; 195 219 struct group *grp = NULL; 196 220 struct passwd *pwd = NULL; … … 198 222 char *owner = empty_str, *group = empty_str; 199 223 char *inode = empty_str; 200 time_t mtime ;201 struct tm *time; 224 time_t mtime, atime, ctime; 225 struct tm *time; 202 226 PVFS_size size = 0; 203 char scratch_owner[16] = {0}, scratch_group[16] = {0} ;227 char scratch_owner[16] = {0}, scratch_group[16] = {0}, scratch_time[MAX_TIME_LENGTH] = {0}, scratch_big_time[MAX_TIME_LENGTH] = {0}; 204 228 char scratch_size[16] = {0}, scratch_inode[16] = {0}; 205 229 char f_type = '-'; 206 230 char group_x_char = '-'; 231 int num_bytes = 0; 207 232 208 233 if (!opts->list_all && (entry_name[0] == '.')) … … 214 239 return; 215 240 } 241 216 242 mtime = (time_t)attr->mtime; 217 243 time = localtime(&mtime); 244 if(opts->list_all_times) 245 { 246 atime = (time_t)attr->atime; 247 ctime = (time_t)attr->ctime; 248 249 num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+1,"%F %H:%M:%S %z",time ); 250 strncpy(scratch_big_time,scratch_time,num_bytes); 251 252 time = localtime(&atime); 253 num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+3," %F %H:%M:%S %z",time ); 254 strncat(scratch_big_time,scratch_time,num_bytes); 255 256 time = localtime(&ctime); 257 num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+3," %F %H:%M:%S %z",time ); 258 strncat(scratch_big_time,scratch_time,num_bytes); 259 260 format_size_string(scratch_big_time,strlen(scratch_big_time),&formatted_time,0,1); 261 } 262 else 263 { 264 strftime( scratch_time,17,"%F %H:%M",time ); 265 format_size_string(scratch_time,16,&formatted_time,0,1); 266 } 218 267 219 268 snprintf(scratch_owner,16,"%d",(int)attr->owner); … … 302 351 } 303 352 304 snprintf( buf,128,"%s%c%c%c%c%c%c%c%c%c%c 1 %s %s %s "305 "% .4d-%.2d-%.2d %.2d:%.2d%s",353 snprintf(entry_buffer,ENTRY_MAX,"%s%c%c%c%c%c%c%c%c%c%c 1 %s %s %s " 354 "%s %s", 306 355 inode, 307 356 f_type, … … 318 367 formatted_group, 319 368 formatted_size, 320 (time->tm_year + 1900), 321 (time->tm_mon + 1), 322 time->tm_mday, 323 (time->tm_hour), 324 (time->tm_min), 369 formatted_time, 325 370 entry_name); 326 371 … … 337 382 free(formatted_group); 338 383 } 384 if (formatted_time) 385 { 386 free(formatted_time); 387 } 339 388 340 389 if (attr->objtype == PVFS_TYPE_SYMLINK) … … 344 393 if (opts->list_long) 345 394 { 346 printf("%s -> %s\n", buf, attr->link_target);395 printf("%s -> %s\n", entry_buffer, attr->link_target); 347 396 } 348 397 else 349 398 { 350 printf("%s\n", buf);399 printf("%s\n",entry_buffer); 351 400 } 352 401 } 353 402 else 354 403 { 355 printf("%s\n", buf);404 printf("%s\n",entry_buffer); 356 405 } 357 406 } … … 363 412 PVFS_sys_attr *attr, 364 413 int attr_error, 365 struct options *opts) 414 struct options *opts, 415 char *entry_buffer) 366 416 { 367 417 int ret = -1; … … 410 460 return; 411 461 } 412 print_entry_attr(handle, entry_name, &getattr_response.attr, opts );462 print_entry_attr(handle, entry_name, &getattr_response.attr, opts, entry_buffer); 413 463 } 414 464 else 415 465 { 416 print_entry_attr(handle, entry_name, attr, opts );466 print_entry_attr(handle, entry_name, attr, opts, entry_buffer); 417 467 } 418 468 } … … 430 480 char *start, 431 481 int fs_id, 432 struct options *opts) 482 struct options *opts, 483 char *entry_buffer) 433 484 { 434 485 int i = 0, printed_dot_info = 0; … … 504 555 { 505 556 print_entry_attr(ref.handle, segment, 506 &getattr_response.attr, opts );557 &getattr_response.attr, opts, entry_buffer); 507 558 } 508 559 else … … 511 562 NULL, 512 563 0, 513 opts );564 opts, entry_buffer); 514 565 } 515 566 return 0; … … 568 619 &rdplus_response.attr_array[i], 569 620 rdplus_response.stat_err_array[i], 570 opts );621 opts, entry_buffer); 571 622 572 623 PVFS_sys_attr *attr = &rdplus_response.attr_array[i]; … … 649 700 { 650 701 printf("\n"); 651 do_list(full_path,current->path,fs_id,opts );702 do_list(full_path,current->path,fs_id,opts,entry_buffer); 652 703 current = current->next; 653 704 free(head->path); … … 685 736 {"inode",0,0,0}, 686 737 {"size",0,0,0}, 738 {"all-times",0,0,0}, 687 739 {0,0,0,0} 688 740 }; … … 753 805 { 754 806 goto list_inode; 807 } 808 else if (strcmp("all-times", cur_option) == 0) 809 { 810 goto list_all_times; 755 811 } 756 812 else … … 805 861 tmp_opts->list_inode = 1; 806 862 break; 863 list_all_times: 864 tmp_opts->list_all_times = 1; 865 break; 807 866 case 't': 808 867 do_timing = 1; … … 854 913 fprintf(stderr," -n, --numeric-uid-gid like -l, but list " 855 914 "numeric UIDs and GIDs\n"); 915 fprintf(stderr," --all-times display atime, mtime," 916 " and ctime information\n"); 856 917 fprintf(stderr," -o like -l, but do not " 857 918 "list group information\n"); … … 876 937 char current_dir[PVFS_NAME_MAX] = {0}; 877 938 int found_one = 0; 939 char *entry_buffer = malloc(ENTRY_MAX); 878 940 879 941 process_name = argv[0]; 880 881 942 user_opts = parse_args(argc, argv); 882 943 if (!user_opts) … … 969 1030 else /* Root directory case has nothing to match */ 970 1031 { 971 substr = &user_opts->start[i][strlen(user_opts->start[i])-1]; 972 } 973 974 while (index != substr) 1032 substr = &user_opts->start[i][strlen(user_opts->start[i])]; 1033 } 1034 1035 1036 while ((index != substr) && (substr != NULL)) 975 1037 { 976 1038 index++; 977 1039 j++; 978 1040 } 979 user_opts->start[i][j] = '\0'; 980 981 do_list(user_opts->start[i], pvfs_path[i], fs_id_array[i], user_opts); 1041 1042 user_opts->start[i][++j] = '\0'; 1043 1044 do_list(user_opts->start[i], pvfs_path[i], fs_id_array[i], user_opts, entry_buffer); 982 1045 983 1046 if (user_opts->num_starts > 1) … … 989 1052 PVFS_sys_finalize(); 990 1053 free(user_opts); 1054 free(entry_buffer); 991 1055 992 1056 return(ret); -
branches/cu-security-branch/src/apps/admin/pvfs2-migrate-collection.c
r8365 r8397 63 63 static int parse_args(int argc, char **argv, options_t *opts); 64 64 static int src_get_version( 65 char* storage_space, TROVE_coll_id coll_id, char* coll_name,65 char* meta_storage_space, TROVE_coll_id coll_id, char* coll_name, 66 66 char* ver_string, int ver_string_max); 67 static int remove_collection_entry(char* storage_space, char* collname);67 static int remove_collection_entry(char* meta_storage_space, char* collname); 68 68 69 69 int migrate_collection(void * config, void * sconfig); … … 73 73 /* functions specific to reading 0.0.1 collections */ 74 74 static int src_get_version_0_0_1( 75 char* storage_space, TROVE_coll_id coll_id,75 char* meta_storage_space, TROVE_coll_id coll_id, 76 76 char* ver_string, int ver_string_max); 77 77 static int translate_0_0_1( 78 char* storage_space, char* old_coll_path,78 char* data_storage_space, char* meta_storage_space, char* old_coll_path, 79 79 char* coll_name, TROVE_coll_id coll_id); 80 80 static int translate_coll_eattr_0_0_1( … … 88 88 TROVE_context_id trove_context); 89 89 static int translate_bstreams_0_0_1( 90 char* storage_space, char* old_coll_path,90 char* data_storage_space, char* old_coll_path, 91 91 TROVE_coll_id coll_id, char* coll_name, 92 92 TROVE_context_id trove_context); … … 234 234 (struct server_configuration_s *) sconfig; 235 235 236 if(server_config->meta_path == NULL) 237 { 238 server_config->meta_path = server_config->data_path; 239 } 240 236 241 memset(version, 0, 256); 237 242 /* find version of source storage space */ 238 243 ret = src_get_version( 239 server_config-> storage_path,244 server_config->meta_path, 240 245 fs_config->coll_id, 241 246 fs_config->file_system_name, … … 254 259 { 255 260 sprintf(old_coll_path, "%s/%08x-old-%s", 256 server_config-> storage_path,261 server_config->meta_path, 257 262 fs_config->coll_id, version); 258 263 … … 293 298 294 299 ret = translate_0_0_1( 295 server_config->storage_path, old_coll_path, 300 server_config->data_path, 301 server_config->meta_path, 302 old_coll_path, 296 303 fs_config->file_system_name, 297 304 fs_config->coll_id); … … 328 335 * is anymore 329 336 */ 330 DIR * storage_dir; 337 DIR * data_storage_dir; 338 DIR * meta_storage_dir; 331 339 struct dirent * next_dirent; 332 340 char collname[PATH_MAX]; … … 336 344 collname_length = sprintf(collname, "%08x-old", fs_config->coll_id); 337 345 338 storage_dir = opendir(server_config->storage_path);339 if(! storage_dir)340 { 341 fprintf(stderr, "Error: failed to open d irectory: %s\n",342 server_config-> storage_path);346 data_storage_dir = opendir(server_config->data_path); 347 if(!data_storage_dir) 348 { 349 fprintf(stderr, "Error: failed to open data directory: %s\n", 350 server_config->data_path); 343 351 return -1; 344 352 } 345 353 346 while((next_dirent = readdir( storage_dir)) != NULL)354 while((next_dirent = readdir(data_storage_dir)) != NULL) 347 355 { 348 356 int d_namelen = strlen(next_dirent->d_name); … … 353 361 354 362 sprintf(old_coll_path, "%s/%s", 355 server_config-> storage_path, next_dirent->d_name);363 server_config->data_path, next_dirent->d_name); 356 364 357 365 /* found an old version, delete it */ … … 366 374 "Error: failed to remove old collection at: %s\n", 367 375 old_coll_path); 368 closedir( storage_dir);376 closedir(data_storage_dir); 369 377 return -1; 370 378 } … … 373 381 } 374 382 383 /* if the meta and data paths are the same, don't try to remove twice */ 384 if (strcmp(server_config->data_path, server_config->meta_path)) 385 { 386 meta_storage_dir = opendir(server_config->meta_path); 387 if(!meta_storage_dir) 388 { 389 fprintf(stderr, "Error: failed to open meta directory: %s\n", 390 server_config->meta_path); 391 return -1; 392 } 393 394 while((next_dirent = readdir(meta_storage_dir)) != NULL) 395 { 396 int d_namelen = strlen(next_dirent->d_name); 397 if(collname_length < d_namelen && 398 strncmp(next_dirent->d_name, collname, collname_length) == 0) 399 { 400 char old_coll_path[PATH_MAX]; 401 402 sprintf(old_coll_path, "%s/%s", 403 server_config->meta_path, next_dirent->d_name); 404 405 /* found an old version, delete it */ 406 if(verbose) 407 printf("VERBOSE Removing old collection at: %s\n", 408 old_coll_path); 409 ret = recursive_rmdir(old_coll_path); 410 if(ret < 0) 411 { 412 fprintf( 413 stderr, 414 "Error: failed to remove old collection at: %s\n", 415 old_coll_path); 416 closedir(meta_storage_dir); 417 return -1; 418 } 419 removed_olddirs = 1; 420 } 421 } 422 closedir(meta_storage_dir); 423 } 424 375 425 if(removed_olddirs == 0) 376 426 { … … 380 430 } 381 431 382 closedir( storage_dir);432 closedir(data_storage_dir); 383 433 } 384 434 else … … 527 577 */ 528 578 static int src_get_version( 529 char* storage_space, /**< path to storage space */579 char* meta_storage_space, /**< path to storage space */ 530 580 TROVE_coll_id coll_id, /**< collection id */ 531 581 char* coll_name, /**< collection name */ … … 537 587 538 588 ret = src_get_version_0_0_1( 539 storage_space, coll_id, ver_string, ver_string_max);589 meta_storage_space, coll_id, ver_string, ver_string_max); 540 590 541 591 if(ret != 0) … … 544 594 "Error: all known collection version checks " 545 595 "failed for \ncollection %s (%08x) in storage space %s\n", 546 coll_name, coll_id, storage_space);596 coll_name, coll_id, meta_storage_space); 547 597 } 548 598 … … 556 606 */ 557 607 static int src_get_version_0_0_1( 558 char* storage_space, /**< path to storage space */608 char* meta_storage_space, /**< path to storage space */ 559 609 TROVE_coll_id coll_id, /**< collection id */ 560 610 char* ver_string, /**< version in string format */ … … 567 617 568 618 sprintf(coll_db, "%s/%08x/collection_attributes.db", 569 storage_space, coll_id);619 meta_storage_space, coll_id); 570 620 571 621 /* try to find a collections db */ … … 630 680 */ 631 681 static int translate_0_0_1( 632 char* storage_space, /**< path to storage space */ 682 char* data_storage_space, /**< path to data storage space */ 683 char* meta_storage_space, /**< path to metadata storage space */ 633 684 char* old_coll_path, /**< path to old collection */ 634 685 char* coll_name, /**< collection name */ … … 645 696 646 697 /* rename old collection */ 647 snprintf(current_path, PATH_MAX, "%s/%08x", storage_space, coll_id);698 snprintf(current_path, PATH_MAX, "%s/%08x", meta_storage_space, coll_id); 648 699 649 700 if(access(current_path, F_OK) != 0) … … 664 715 } 665 716 666 ret = remove_collection_entry( storage_space, coll_name);717 ret = remove_collection_entry(meta_storage_space, coll_name); 667 718 if(ret < 0) 668 719 { … … 679 730 printf("VERBOSE Creating temporary collection to migrate to.\n"); 680 731 ret = pvfs2_mkspace( 681 storage_space, 732 data_storage_space, 733 meta_storage_space, 682 734 coll_name, 683 735 coll_id, … … 700 752 PVFS_perror("PINT_dist_initialize", ret); 701 753 if(verbose) printf("VERBOSE Destroying temporary collection.\n"); 702 pvfs2_rmspace( storage_space, coll_name, coll_id, 1, 0);754 pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0); 703 755 return(-1); 704 756 } … … 706 758 /* initialize trove and lookup collection */ 707 759 ret = trove_initialize( 708 TROVE_METHOD_DBPF, NULL, storage_space,0);760 TROVE_METHOD_DBPF, NULL, data_storage_space, meta_storage_space,0); 709 761 if (ret < 0) 710 762 { 711 763 PVFS_perror("trove_initialize", ret); 712 764 if(verbose) printf("VERBOSE Destroying temporary collection.\n"); 713 pvfs2_rmspace( storage_space, coll_name, coll_id, 1, 0);765 pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0); 714 766 return(-1); 715 767 } … … 720 772 fprintf(stderr, "Error: failed to lookup new collection.\n"); 721 773 if(verbose) printf("VERBOSE Destroying temporary collection.\n"); 722 pvfs2_rmspace( storage_space, coll_name, coll_id, 1, 0);774 pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0); 723 775 return -1; 724 776 } … … 738 790 fprintf(stderr, "Error: failed to migrate collection extended attributes.\n"); 739 791 if(verbose) printf("VERBOSE Destroying temporary collection.\n"); 740 pvfs2_rmspace( storage_space, coll_name, coll_id, 1, 0);792 pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0); 741 793 return(-1); 742 794 } … … 749 801 fprintf(stderr, "Error: failed to migrate dspace attributes.\n"); 750 802 if(verbose) printf("VERBOSE Destroying temporary collection.\n"); 751 pvfs2_rmspace( storage_space, coll_name, coll_id, 1, 0);803 pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0); 752 804 return(-1); 753 805 } … … 760 812 fprintf(stderr, "Error: failed to migrate keyvals.\n"); 761 813 if(verbose) printf("VERBOSE Destroying temporary collection.\n"); 762 pvfs2_rmspace( storage_space, coll_name, coll_id, 1, 0);814 pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0); 763 815 return(-1); 764 816 } … … 771 823 /* convert bstreams */ 772 824 ret = translate_bstreams_0_0_1( 773 storage_space, old_coll_path, coll_id, coll_name, trove_context);825 data_storage_space, old_coll_path, coll_id, coll_name, trove_context); 774 826 if(ret < 0) 775 827 { 776 828 fprintf(stderr, "Error: failed to migrate bstreams.\n"); 777 829 if(verbose) printf("VERBOSE Destroying temporary collection.\n"); 778 pvfs2_rmspace( storage_space, coll_name, coll_id, 1, 0);830 pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0); 779 831 return(-1); 780 832 } … … 795 847 } 796 848 797 static int remove_collection_entry(char* storage_space, char* collname)849 static int remove_collection_entry(char* meta_storage_space, char* collname) 798 850 { 799 851 char collections_db[PATH_MAX]; … … 803 855 TROVE_coll_id coll_id; 804 856 805 sprintf(collections_db, "%s/collections.db", storage_space);857 sprintf(collections_db, "%s/collections.db", meta_storage_space); 806 858 807 859 ret = access(collections_db, F_OK); … … 1494 1546 */ 1495 1547 static int translate_bstreams_0_0_1( 1496 char* storage_space, /**< path to trove storage space */1548 char* data_storage_space, /**< path to trove storage space */ 1497 1549 char* old_coll_path, /**< path to old collection */ 1498 1550 TROVE_coll_id coll_id, /**< collection id */ … … 1531 1583 old_coll_path, i, tmp_ent->d_name); 1532 1584 snprintf(new_bstream_file, PATH_MAX, "%s/%08x/bstreams/%.8d/%s", 1533 storage_space, coll_id, i, tmp_ent->d_name);1585 data_storage_space, coll_id, i, tmp_ent->d_name); 1534 1586 /* hard link to new location */ 1535 1587 ret = link(bstream_file, new_bstream_file); -
branches/cu-security-branch/src/apps/admin/pvfs2-mkspace.c
r5684 r8397 32 32 char data_ranges[PATH_MAX]; 33 33 char collection[PATH_MAX]; 34 char storage_space[PATH_MAX]; 34 char data_space[PATH_MAX]; 35 char meta_space[PATH_MAX]; 35 36 } options_t; 36 37 … … 54 55 {"verbose",0,0,0}, 55 56 {"defaults",0,0,0}, 56 {"storage-space",1,0,0}, 57 {"data-space",1,0,0}, 58 {"meta-space",1,0,0}, 57 59 {"coll-id",1,0,0}, 58 60 {"coll-name",1,0,0}, … … 71 73 } 72 74 73 while ((ret = getopt_long(argc, argv, " s:c:i:r:vVhadDM:N:",75 while ((ret = getopt_long(argc, argv, "c:i:r:vVhadDM:N:", 74 76 long_opts, &option_index)) != -1) 75 77 { … … 91 93 goto do_verbose; 92 94 } 93 else if (strcmp("storage-space", cur_option) == 0) 94 { 95 goto do_storage_space; 96 } 95 else if (strcmp("data-space", cur_option) == 0) 96 { 97 strncpy(opts->data_space, optarg, PATH_MAX); 98 } 99 else if (strcmp("meta-space", cur_option) == 0) 100 { 101 strncpy(opts->meta_space, optarg, PATH_MAX); 102 } 97 103 else if (strcmp("coll-id", cur_option) == 0) 98 104 { … … 173 179 do_data_handle_range: 174 180 strncpy(opts->data_ranges, optarg, PATH_MAX); 175 break;176 case 's':177 do_storage_space:178 strncpy(opts->storage_space, optarg, PATH_MAX);179 181 break; 180 182 case 'v': … … 224 226 (strlen(opts->data_ranges) ? 225 227 opts->data_ranges : "None specified")); 226 printf("\tstorage space : %s\n", 227 (strlen(opts->storage_space) ? 228 opts->storage_space : "None specified")); 228 printf("\tdata storage space : %s\n", 229 (strlen(opts->data_space) ? 230 opts->data_space : "None specified")); 231 printf("metadata storage space : %s\n", 232 (strlen(opts->meta_space) ? 233 opts->meta_space : "None specified")); 229 234 } 230 235 } … … 259 264 "create collection with the specified\n " 260 265 " data handle range\n"); 261 fprintf(stderr," -s, --storage-space=PATH " 262 "create storage space at this location\n"); 266 fprintf(stderr," --data-space=PATH " 267 "create data storage space at this location\n"); 268 fprintf(stderr," --meta-space=PATH " 269 "create metadata storage space at this location\n"); 263 270 fprintf(stderr," -v, --verbose " 264 271 "operate in verbose mode\n"); … … 297 304 print_options(&opts); 298 305 299 if (strlen(opts.storage_space) == 0) 300 { 301 fprintf(stderr, "Error: You MUST specify a storage space\n"); 306 if (strlen(opts.data_space) == 0) 307 { 308 fprintf(stderr, "Error: You MUST specify a data storage space\n"); 309 return -1; 310 } 311 312 if (strlen(opts.meta_space) == 0) 313 { 314 fprintf(stderr, "Error: You MUST specify a metadata storage space\n"); 302 315 return -1; 303 316 } … … 319 332 if (opts.delete_storage) 320 333 { 321 ret = pvfs2_rmspace(opts. storage_space, opts.collection,322 opts.coll_id, opts.collection_only, 323 opts.verbose);334 ret = pvfs2_rmspace(opts.data_space, opts.meta_space, 335 opts.collection, opts.coll_id, 336 opts.collection_only, opts.verbose); 324 337 } 325 338 else 326 339 { 327 ret = pvfs2_mkspace(opts.storage_space, opts.collection, 328 opts.coll_id, opts.root_handle, 329 opts.meta_ranges, opts.data_ranges, 330 opts.collection_only, opts.verbose); 340 ret = pvfs2_mkspace(opts.data_space, opts.meta_space, 341 opts.collection, opts.coll_id, 342 opts.root_handle, opts.meta_ranges, 343 opts.data_ranges, opts.collection_only, 344 opts.verbose); 331 345 } 332 346 return ret; -
branches/cu-security-branch/src/apps/admin/pvfs2-showcoll.c
r7941 r8397 24 24 size_t strnlen(const char *s, size_t limit); 25 25 26 static char storage_space[PATH_MAX] = "/tmp/pvfs2-test-space"; 26 static char data_path[PATH_MAX] = "/tmp/pvfs2-test-space"; 27 static char meta_path[PATH_MAX] = "/tmp/pvfs2-test-space"; 27 28 static char collection[PATH_MAX]; 28 29 static int verbose = 0, got_collection = 0, print_keyvals = 0, got_dspace_handle = 0; … … 72 73 /* initialize trove, verifying storage space exists */ 73 74 ret = trove_initialize( 74 TROVE_METHOD_DBPF, NULL, storage_space, 0);75 TROVE_METHOD_DBPF, NULL, data_path, meta_path, 0); 75 76 if (ret < 0) 76 77 { … … 82 83 83 84 if (verbose) fprintf(stderr, 84 "%s: info: initialized with storage space '%s'.\n",85 "%s: info: initialized with storage spaces '%s' and '%s'.\n", 85 86 argv[0], 86 storage_space);87 data_path, meta_path); 87 88 88 89 /* if no collection was specified, simply print out the collections and exit */ … … 165 166 if (no_root_handle) { 166 167 fprintf(stdout, 167 "Storage space %s , collection %s (coll_id = %d, "168 "Storage space %s and %s, collection %s (coll_id = %d, " 168 169 "*** no root_handle found ***):\n", 169 storage_space, 170 data_path, 171 meta_path, 170 172 collection, 171 173 coll_id); … … 173 175 else { 174 176 fprintf(stdout, 175 "Storage space %s , collection %s (coll_id = %d, "177 "Storage space %s and %s, collection %s (coll_id = %d, " 176 178 "root_handle = 0x%08llx):\n", 177 storage_space, 179 data_path, 180 meta_path, 178 181 collection, 179 182 coll_id, … … 201 204 int c; 202 205 203 while ((c = getopt(argc, argv, "s: c:d:kvh")) != EOF) {206 while ((c = getopt(argc, argv, "s:m:c:d:kvh")) != EOF) { 204 207 switch (c) { 205 case 's':206 strncpy( storage_space, optarg, PATH_MAX);208 case 's': 209 strncpy(data_path, optarg, PATH_MAX); 207 210 break; 211 case 'm': 212 strncpy(meta_path, optarg, PATH_MAX); 208 213 case 'c': /* collection */ 209 214 got_collection = 1; … … 225 230 case 'h': 226 231 fprintf(stderr, 227 "usage: pvfs2-showcoll [-s storage_space] [-c collection_name] [-d dspace_handle] [-v] [-k] [-h]\n");232 "usage: pvfs2-showcoll [-s data_storage_space] [-m metadata storage space] [-c collection_name] [-d dspace_handle] [-v] [-k] [-h]\n"); 228 233 fprintf(stderr, "\tdefault storage space is '/tmp/pvfs2-test-space'.\n"); 229 234 fprintf(stderr, "\t'-v' turns on verbose output.\n"); … … 499 504 pos = TROVE_ITERATE_START; 500 505 501 fprintf(stdout, "Storage space %s collections:\n", storage_space); 506 fprintf(stdout, "Storage space %s and %s collections:\n", 507 data_path, meta_path); 502 508 503 509 while (count > 0) { -
branches/cu-security-branch/src/apps/admin/pvfs2-stat.c
r8351 r8397 55 55 { 56 56 int ret = -1, 57 ret_agg = 0, 57 58 i = 0; 58 59 char ** ppszPvfsPath = NULL; … … 151 152 fprintf(stderr, "Error stating [%s]\n", user_opts.pszFiles[i]); 152 153 } 154 ret_agg |= ret; 153 155 } 154 156 … … 179 181 } 180 182 181 return( 0);183 return(ret_agg); 182 184 } 183 185 … … 478 480 fprintf(stdout, " datafiles : %d\n", attr->dfile_count); 479 481 } 482 483 if( (attr->mask & PVFS_ATTR_SYS_BLKSIZE) && 484 (attr->objtype == PVFS_TYPE_METAFILE)) 485 { 486 fprintf(stdout, " blksize : %lld\n", lld(attr->blksize)); 487 } 488 480 489 /* dirent_count is only valid on directories */ 481 490 if( (attr->mask & PVFS_ATTR_SYS_DIRENT_COUNT) && -
branches/cu-security-branch/src/apps/admin/pvfs2-xattr.c
r8351 r8397 3 3 * 4 4 * See COPYING in top-level directory. 5 * 6 * 03/19/07 - Added set and get for user.pvfs2.mirror.mode and ..mirror.copies. 7 * Added get for user.pvfs2.mirror.handles and ..mirror.status 5 8 */ 6 9 … … 26 29 #include "xattr-utils.h" 27 30 31 #include "pvfs2-mirror.h" 32 28 33 #define VALBUFSZ 1024 29 34 … … 41 46 struct options 42 47 { 43 PVFS_ds_keyval key;44 PVFS_ds_keyval val;48 PVFS_ds_keyval *key; 49 PVFS_ds_keyval *val; 45 50 char* srcfile; 46 int get, text ;51 int get, text, key_count; 47 52 }; 48 53 … … 78 83 static struct options* parse_args(int argc, char* argv[]); 79 84 static int generic_open(file_object *obj, PVFS_credential *credentials); 80 static int pvfs2_eattr(int get, file_object *, PVFS_ds_keyval *key_p, 81 PVFS_ds_keyval *val_p, PVFS_credential *creds); 85 86 static int pvfs2_eattr(int get 87 ,file_object *obj 88 ,PVFS_ds_keyval *key_p 89 ,PVFS_ds_keyval *val_p 90 ,PVFS_credential *creds 91 ,int key_count); 92 82 93 static void usage(int argc, char** argv); 83 94 static int resolve_filename(file_object *obj, char *filename); … … 92 103 file_object src; 93 104 PVFS_credential credentials; 105 int i; 94 106 95 107 memset(&src, 0, sizeof(src)); … … 124 136 return -1; 125 137 } 126 if (!eattr_is_prefixed(user_opts->key.buffer)) 138 139 if (!eattr_is_prefixed(user_opts->key[0].buffer)) 127 140 { 128 fprintf(stderr, "extended attribute key is not prefixed %s\n", (char *) user_opts->key.buffer); 141 fprintf(stderr, "extended attribute key is not prefixed %s\n" 142 , (char *) user_opts->key[0].buffer); 129 143 return -1; 130 144 } 131 145 if (!user_opts->get) 132 146 { 133 if (!permit_set(&user_opts->key ))147 if (!permit_set(&user_opts->key[0])) 134 148 { 135 fprintf(stderr, "Not permitted to set key %s\n", (char *) user_opts->key.buffer); 149 fprintf(stderr, "Not permitted to set key %s\n" 150 , (char *) user_opts->key[0].buffer); 136 151 return -1; 137 152 } 138 if (modify_val(&user_opts->key , &user_opts->val) < 0)153 if (modify_val(&user_opts->key[0], &user_opts->val[0]) < 0) 139 154 { 140 fprintf(stderr, "Invalid value for user-settable hint %s, %s\n", (char *) user_opts->key.buffer, (char *) user_opts->val.buffer); 155 fprintf(stderr, "Invalid value for user-settable attribute %s, %s\n" 156 , (char *) user_opts->key[0].buffer 157 , (char *) user_opts->val[0].buffer); 141 158 return -1; 142 159 } 143 160 } 144 161 145 ret = pvfs2_eattr(user_opts->get, &src, &user_opts->key, &user_opts->val, &credentials); 162 ret = pvfs2_eattr(user_opts->get 163 ,&src 164 ,user_opts->key 165 ,user_opts->val 166 ,&credentials 167 ,user_opts->key_count); 146 168 if (ret != 0) 147 169 { … … 150 172 if (user_opts->get && user_opts->text) 151 173 { 152 if (strncmp(user_opts->key.buffer, "user.pvfs2.meta_hint", SPECIAL_METAFILE_HINT_KEYLEN) == 0) { 153 PVFS_metafile_hint *hint = (PVFS_metafile_hint *) user_opts->val.buffer; 154 printf("Metafile hints: "); 174 if (strncmp(user_opts->key[0].buffer 175 ,"user.pvfs2.meta_hint" 176 ,SPECIAL_METAFILE_HINT_KEYLEN) == 0) { 177 PVFS_metafile_hint *hint = 178 (PVFS_metafile_hint *) user_opts->val[0].buffer; 179 printf("Metafile hints (0x%08x)",(unsigned int)hint->flags); 155 180 if (hint->flags & PVFS_IMMUTABLE_FL) { 156 printf(" immutable file ");181 printf(" :immutable file "); 157 182 } 158 183 if (hint->flags & PVFS_APPEND_FL) { 159 printf(" Append-only file ");184 printf(" :Append-only file "); 160 185 } 161 186 if (hint->flags & PVFS_NOATIME_FL) { 162 printf("Atime updates disabled."); 187 printf(" :Atime updates disabled"); 188 } 189 if (hint->flags & PVFS_MIRROR_FL) { 190 printf(" :Mirroring is enabled"); 163 191 } 164 192 printf("\n"); 193 } else if ( strncmp(user_opts->key[0].buffer 194 ,"user.pvfs2.mirror.handles" 195 ,sizeof("user.pvfs2.mirror.handles")) == 0) 196 { 197 PVFS_handle *myHandles = (PVFS_handle *)user_opts->val[0].buffer; 198 int copies = *(int *)user_opts->val[1].buffer; 199 int dfile_count = src.u.pvfs2.attr.dfile_count; 200 for (i=0; i<(copies * dfile_count); i++) 201 { 202 printf("Handle(%d):%llu\n",i,llu(myHandles[i])); 203 } 204 } else if ( strncmp(user_opts->key[0].buffer 205 ,"user.pvfs2.mirror.copies" 206 ,sizeof("user.pvfs2.mirror.copies")) == 0) 207 { 208 int *myCopies = (int *)user_opts->val[0].buffer; 209 printf("Number of Mirrored Copies : %d\n",*myCopies); 210 } else if ( strncmp(user_opts->key[0].buffer 211 ,"user.pvfs2.mirror.status" 212 ,sizeof("user.pvfs2.mirror.status")) == 0) 213 { 214 int copies = *(int *)user_opts->val[1].buffer; 215 int dfile_count = src.u.pvfs2.attr.dfile_count; 216 PVFS_handle *status = (PVFS_handle *)user_opts->val[0].buffer; 217 for (i=0; i<(dfile_count * copies); i++) 218 printf("src handle(%d) : status(%s) : value(%llu)\n" 219 ,i 220 ,status[i]==0?"usable":"UNusable" 221 ,llu(status[i])); 222 } else if ( strncmp(user_opts->key[0].buffer 223 ,"user.pvfs2.mirror.mode" 224 , sizeof("user.pvfs2.mirror.mode")) == 0) 225 { 226 printf("Mirroring Mode : "); 227 switch(*(MIRROR_MODE *)user_opts->val[0].buffer) 228 { 229 case NO_MIRRORING : 230 { 231 printf("Turned OFF\n"); 232 break; 233 } 234 case MIRROR_ON_IMMUTABLE : 235 { 236 printf("Create Mirror when IMMUTABLE is set\n"); 237 break; 238 } 239 default: 240 { 241 printf("Unknown mode(%d)\n" 242 ,*(int *)user_opts->val[0].buffer); 243 break; 244 } 245 }/*end switch*/ 165 246 } else { 166 printf("key :%s Value:\n%s\n",167 (char *)user_opts->key .buffer,168 (char *)user_opts->val .buffer);247 printf("key : \"%s\" \tValue : \"%s\"\n", 248 (char *)user_opts->key[0].buffer, 249 (char *)user_opts->val[0].buffer); 169 250 } 170 251 } … … 175 256 static int modify_val(PVFS_ds_keyval *key_p, PVFS_ds_keyval *val_p) 176 257 { 177 if (strncmp(key_p->buffer, "user.pvfs2.meta_hint", SPECIAL_METAFILE_HINT_KEYLEN) == 0) 258 if (strncmp(key_p->buffer,"user.pvfs2.meta_hint" 259 , SPECIAL_METAFILE_HINT_KEYLEN) == 0) 178 260 { 179 261 PVFS_metafile_hint hint; … … 195 277 memcpy(val_p->buffer, &hint, sizeof(hint)); 196 278 val_p->buffer_sz = sizeof(hint); 197 } 279 } else if (strncmp(key_p->buffer,"user.pvfs2.mirror.mode" 280 ,sizeof("user.pvfs2.mirror.mode")) == 0) 281 { 282 printf("Setting mirror mode to %d\n",*(int *)val_p->buffer); 283 } else if (strncmp(key_p->buffer,"user.pvfs2.mirror.copies" 284 ,sizeof("user.pvfs2.mirror.mode")) == 0) 285 { 286 printf("Setting number of mirrored copies to %d\n" 287 ,*(int *)val_p->buffer); 288 } 289 290 198 291 return 0; 199 292 } … … 214 307 * returns zero on success and negative one on failure 215 308 */ 216 static int pvfs2_eattr(int get, file_object *obj, PVFS_ds_keyval *key_p, 217 PVFS_ds_keyval *val_p, PVFS_credential *creds) 309 static int pvfs2_eattr(int get 310 ,file_object *obj 311 ,PVFS_ds_keyval *key_p 312 ,PVFS_ds_keyval *val_p 313 ,PVFS_credential *creds 314 ,int key_count) 218 315 { 219 316 int ret = -1; … … 224 321 { 225 322 #ifndef HAVE_FGETXATTR_EXTRA_ARGS 226 if ((ret = fgetxattr(obj->u.ufs.fd, key_p->buffer, val_p->buffer, val_p->buffer_sz)) < 0) 323 if ((ret = fgetxattr(obj->u.ufs.fd 324 ,key_p->buffer 325 ,val_p->buffer 326 ,val_p->buffer_sz)) < 0) 227 327 #else 228 if ((ret = fgetxattr(obj->u.ufs.fd, key_p->buffer, val_p->buffer, val_p->buffer_sz, 0, 0)) < 0) 328 if ((ret = fgetxattr(obj->u.ufs.fd 329 ,key_p->buffer 330 ,val_p->buffer 331 ,val_p->buffer_sz 332 ,0 333 ,0)) < 0) 229 334 #endif 230 335 { … … 253 358 else 254 359 { 255 if (get == 1 )360 if (get == 1 && key_count == 1) 256 361 { 257 362 ret = PVFS_sys_geteattr(obj->u.pvfs2.ref, creds, key_p, val_p, NULL); 258 } 259 else { 363 } else if (get == 1 && key_count == 2) 364 { 365 PVFS_sysresp_geteattr *resp = malloc(sizeof(*resp)); 366 if (!resp) 367 { 368 fprintf(stderr,"Unable to allocate resp structure.\n"); 369 exit(EXIT_FAILURE); 370 } 371 memset(resp,0,sizeof(*resp)); 372 resp->val_array = val_p; 373 resp->err_array = malloc(2 * sizeof(PVFS_error)); 374 if (!resp->err_array) 375 { 376 fprintf(stderr,"Unable to allocate err_array.\n"); 377 exit(EXIT_FAILURE); 378 } 379 memset(resp->err_array,0,sizeof(2 * sizeof(PVFS_error))); 380 381 ret = PVFS_sys_geteattr_list(obj->u.pvfs2.ref 382 ,creds 383 ,key_count 384 ,key_p 385 ,resp 386 ,NULL ); 387 } else { 260 388 ret = PVFS_sys_seteattr(obj->u.pvfs2.ref, creds, key_p, val_p, 0, NULL); 261 389 } … … 291 419 memset(tmp_opts, 0, sizeof(struct options)); 292 420 421 /*create one key structure*/ 422 tmp_opts->key = malloc(sizeof(PVFS_ds_keyval)); 423 if (!tmp_opts->key) 424 { 425 fprintf(stderr,"Unable to allocate tmp_opts->key.\n"); 426 exit(EXIT_FAILURE); 427 } 428 memset(tmp_opts->key,0,sizeof(PVFS_ds_keyval)); 429 430 /*create one val structure*/ 431 tmp_opts->val = malloc(sizeof(PVFS_ds_keyval)); 432 if (!tmp_opts->val) 433 { 434 fprintf(stderr,"Unable to allocate tmp_opts->val.\n"); 435 exit(EXIT_FAILURE); 436 } 437 memset(tmp_opts->val,0,sizeof(PVFS_ds_keyval)); 438 439 /*set default key_count*/ 440 tmp_opts->key_count = 1; 441 293 442 /* fill in defaults */ 294 memset(&tmp_opts->key, 0, sizeof(PVFS_ds_keyval));295 memset(&tmp_opts->val, 0, sizeof(PVFS_ds_keyval));296 443 tmp_opts->srcfile = strdup(argv[argc-1]); 297 444 tmp_opts->get = 1; … … 308 455 break; 309 456 case 'k': 310 tmp_opts->key .buffer = strdup(optarg);311 tmp_opts->key .buffer_sz = strlen(tmp_opts->key.buffer) + 1;457 tmp_opts->key[0].buffer = strdup(optarg); 458 tmp_opts->key[0].buffer_sz = strlen(tmp_opts->key[0].buffer) + 1; 312 459 break; 313 460 case 'v': 314 tmp_opts->val.buffer = strdup(optarg); 315 tmp_opts->val.buffer_sz = strlen(tmp_opts->val.buffer) + 1; 316 break; 461 if (strncmp(tmp_opts->key[0].buffer 462 ,"user.pvfs2.mirror.mode" 463 ,sizeof("user.pvfs2.mirror.mode")) == 0 || 464 strncmp(tmp_opts->key[0].buffer 465 ,"user.pvfs2.mirror.copies" 466 ,sizeof("user.pvfs2.mirror.copies")) == 0) 467 { /*convert string argument into numeric argument*/ 468 tmp_opts->val[0].buffer = malloc(sizeof(int)); 469 if (!tmp_opts->val[0].buffer) 470 { 471 printf("Unable to allocate memory for key value.\n"); 472 exit(EXIT_FAILURE); 473 } 474 memset(tmp_opts->val[0].buffer,0,sizeof(int)); 475 *(int *)tmp_opts->val[0].buffer = atoi(optarg); 476 tmp_opts->val[0].buffer_sz = sizeof(int); 477 break; 478 } else { 479 tmp_opts->val[0].buffer = strdup(optarg); 480 tmp_opts->val[0].buffer_sz = strlen(tmp_opts->val[0].buffer); 481 break; 482 } 317 483 case('?'): 318 484 printf("?\n"); … … 321 487 } 322 488 } 489 /*ensure that the given mode is supported by PVFS*/ 490 if (!tmp_opts->get && 491 strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.mode") == 0) 492 { 493 if (*(int *)tmp_opts->val[0].buffer < BEGIN_MIRROR_MODE || 494 *(int *)tmp_opts->val[0].buffer > END_MIRROR_MODE ) 495 { 496 fprintf(stderr,"Invalid Mirror Mode ==> %d\n" 497 "\tValid Modes\n" 498 "\t1. %d == No Mirroring\n" 499 "\t2. %d == Mirroring on Immutable\n" 500 ,*(int *)tmp_opts->val[0].buffer 501 ,NO_MIRRORING,MIRROR_ON_IMMUTABLE); 502 503 exit(EXIT_FAILURE); 504 } 505 } 506 323 507 if (tmp_opts->get == 1) 324 508 { 325 tmp_opts->val.buffer = calloc(1, VALBUFSZ); 326 tmp_opts->val.buffer_sz = VALBUFSZ; 327 if (tmp_opts->val.buffer == NULL) 328 { 329 fprintf(stderr, "Could not allocate val\n"); 330 exit(EXIT_FAILURE); 331 } 332 } 333 else { 334 if (tmp_opts->val.buffer == NULL) 335 { 336 fprintf(stderr, "Please specify value if setting extended attributes\n"); 509 /*if user wants mirror.handles or mirror.status, then we must also */ 510 /*retrieve the number of copies, so we know how to display the */ 511 /*information properly. */ 512 if (strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.handles") == 0 || 513 strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.status") == 0 ) 514 { 515 tmp_opts->key_count = 2; 516 PVFS_ds_keyval *myKeys = malloc(tmp_opts->key_count * 517 sizeof(PVFS_ds_keyval)); 518 if (!myKeys) 519 { 520 fprintf(stderr,"Unable to allocate myKeys.\n"); 521 exit(EXIT_FAILURE); 522 } 523 memset(myKeys,0,sizeof(tmp_opts->key_count * 524 sizeof(PVFS_ds_keyval))); 525 myKeys[0] = *tmp_opts->key; 526 myKeys[1].buffer = strdup("user.pvfs2.mirror.copies"); 527 myKeys[1].buffer_sz = sizeof("user.pvfs2.mirror.copies"); 528 free(tmp_opts->key); 529 tmp_opts->key = myKeys; 530 }/*end if handles or status*/ 531 532 533 534 tmp_opts->val[0].buffer = calloc(1, VALBUFSZ); 535 if (!tmp_opts->val[0].buffer) 536 { 537 fprintf(stderr,"Unable to allocate tmp_opts->val[0].buffer.\n"); 538 exit(EXIT_FAILURE); 539 } 540 tmp_opts->val[0].buffer_sz = VALBUFSZ; 541 542 if (tmp_opts->key_count == 2) 543 { 544 PVFS_ds_keyval *myVals = malloc(tmp_opts->key_count * 545 sizeof(PVFS_ds_keyval)); 546 if (!myVals) 547 { 548 fprintf(stderr,"Unable to allocate myVals.\n"); 549 exit(EXIT_FAILURE); 550 } 551 memset(myVals,0,sizeof(tmp_opts->key_count * 552 sizeof(PVFS_ds_keyval))); 553 myVals[0] = *tmp_opts->val; 554 free(tmp_opts->val); 555 556 myVals[1].buffer = malloc(sizeof(int)); 557 if (!myVals[1].buffer) 558 { 559 fprintf(stderr,"Unable to allocate myVals[1].buffer.\n"); 560 exit(EXIT_FAILURE); 561 } 562 myVals[1].buffer_sz = sizeof(int); 563 tmp_opts->val = myVals; 564 }/*end if*/ 565 } else { 566 if (tmp_opts->val[0].buffer == NULL) 567 { 568 fprintf(stderr, "Please specify value if setting extended " 569 "attributes\n"); 337 570 usage(argc, argv); 338 571 exit(EXIT_FAILURE); 339 572 } 340 573 } 341 if (tmp_opts->key .buffer == NULL)574 if (tmp_opts->key[0].buffer == NULL) 342 575 { 343 576 fprintf(stderr, "Please specify key if getting extended attributes\n"); … … 351 584 static void usage(int argc, char** argv) 352 585 { 353 fprintf(stderr,"Usage: %s -s {set xattrs} -k <key> -v <val> -t {print attributes} filename\n",argv[0]); 586 fprintf(stderr,"Usage: %s -s {set xattrs} -k <key> -v <val> " 587 "-t {print attributes} filename\n",argv[0]); 354 588 return; 355 589 } … … 450 684 memcpy(&obj->u.pvfs2.attr, &resp_getattr.attr, 451 685 sizeof(PVFS_sys_attr)); 452 obj->u.pvfs2.attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; 686 /* we should not modify the returned mask, so we know which data fields 687 * in the attribute structure are valid. I don't see any reason why 688 * it is being reset here. 689 */ 690 //obj->u.pvfs2.attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; 453 691 obj->u.pvfs2.ref = ref; 454 692 }
