Show
Ignore:
Timestamp:
06/18/10 20:02:50 (3 years ago)
Author:
nlmills
Message:

initial merge with Orange-Branch. much will be broken

Location:
branches/cu-security-branch
Files:
2 added
14 modified

Legend:

Unmodified
Added
Removed
  • branches/cu-security-branch

    • Property svn:ignore
      •  

        old new  
        33aclocal.m4 
        44autom4te.cache 
        5 config.status 
        6 Makefile 
        7 pvfs2-config.h 
        8 module.mk 
  • branches/cu-security-branch/src/apps/admin

    • Property svn:ignore deleted
  • branches/cu-security-branch/src/apps/admin/pvfs2-change-fsid.c

    r7941 r8397  
    3939    char fs_conf[PATH_MAX]; 
    4040    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]; 
    4243    int32_t old_fsid; 
    4344    int32_t new_fsid; 
     
    314315{ 
    315316    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]; 
    318321    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]; 
    321326    int ret = 0; 
    322327     
    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); 
    328335    if(ret) 
    329336    { 
    330337        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); 
    333348        return -1; 
    334349    } 
     
    341356    } 
    342357     
    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"); 
    352373    if(fptr == NULL) 
    353374    { 
     
    355376        exit(-1); 
    356377    } 
    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); 
    361382        return -1; 
    362383    } 
    363384    pclose(fptr); 
    364385 
     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 
    365401    if(opts.verbose) 
    366402    { 
    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); 
    368405    } 
    369406 
     
    517554        {"dbpath",1,0,0}, 
    518555        {"fsconf",1,0,0}, 
    519         {"storage",1,0,0}, 
     556        {"datastorage",1,0,0}, 
     557        {"metastorage",1,0,0}, 
    520558        {"view",0,0,0}, 
    521559        {0,0,0,0} 
     
    562600                break; 
    563601 
    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 */ 
    569611                opts.view_only = 1; 
    570612                break; 
     
    593635    } 
    594636 
    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"); 
    599649        print_help(argv[0]); 
    600650        return(-1); 
     
    613663    fprintf(stderr,"  --fsconf=</path/to/pvfs2-fs.conf>     " 
    614664            "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"); 
    617669    fprintf(stderr, "\n"); 
    618670    fprintf(stderr,"The following arguments are optional:\n"); 
  • branches/cu-security-branch/src/apps/admin/pvfs2-check-config.c

    r8339 r8397  
    129129        return -1; 
    130130    } 
    131      
     131 
    132132    /* Construct the list of mount points */ 
    133133    mnt = PVFS_util_parse_pvfstab(0); 
  • branches/cu-security-branch/src/apps/admin/pvfs2-cp.c

    r8358 r8397  
    304304        "\n-s <strip_size>\t\t\tsize of access to PVFS2 volume" 
    305305        "\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" 
    307307        "\n-t\t\t\t\tprint some timing information" 
    308308        "\n-v\t\t\t\tprint version number and exit\n"); 
  • branches/cu-security-branch/src/apps/admin/pvfs2-fs-dump.c

    r8358 r8397  
    361361    { 
    362362        PVFS_util_refresh_credential(creds); 
    363         ret = PVFS_mgmt_iterate_handles_list(cur_fs, 
     363        ret = PVFS_mgmt_iterate_handles_list(cur_fs, 
    364364                                             creds, 
    365365                                             handle_matrix, 
  • branches/cu-security-branch/src/apps/admin/pvfs2-fsck.c

    r8358 r8397  
    900900        PVFS_sysresp_getattr getattr_resp; 
    901901 
    902         PVFS_util_refresh_credential(creds); 
     902        PVFS_util_refresh_credential(creds); 
    903903 
    904904        handle_ref.handle = handle; 
     
    983983        PVFS_sysresp_getattr getattr_resp; 
    984984 
    985         PVFS_util_refresh_credential(creds); 
     985        PVFS_util_refresh_credential(creds); 
    986986 
    987987        handle_ref.handle = handle; 
     
    10961096        PVFS_sysresp_getattr getattr_resp; 
    10971097 
    1098         PVFS_util_refresh_credential(creds); 
     1098        PVFS_util_refresh_credential(creds); 
    10991099 
    11001100        handle_ref.handle = handle; 
  • branches/cu-security-branch/src/apps/admin/pvfs2-genconfig

    r8330 r8397  
    1010use Getopt::Long; 
    1111use Math::BigInt; 
    12 use File::Basename; 
    13 use Cwd 'abs_path';; 
    1412 
    1513# turn on strictness 
     
    3129my $opt_logfile = ''; 
    3230my $opt_storage = ''; 
    33 my $opt_pubkey = ''; 
    34 my $opt_privkey = ''; 
    3531my $opt_trovesync = '1'; 
    3632my $opt_trovemethod = ''; 
     
    6157 
    6258my $default_storage = undef; 
     59my $default_meta_storage = undef; 
    6360my $default_logfile = undef; 
    64 my $default_pubkey = undef; 
    65 my $default_privkey = undef; 
    66 my $security_flag = ''; 
    6761 
    6862my $bmi_module = undef; 
     
    7569my $OUT = undef; 
    7670my $term = undef; 
    77 my $dirname = undef; 
    7871 
    7972#$num_unexp_reqs = prompt_num("How many unexpected requests should we be prepared to receive?  "); 
     
    158151    # 
    159152    @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 
    162162        # if we've got a component that has {..}, then expand. 
    163163        # match the prefix (hostname) and curly brackets 
     
    217217    if(defined($default_storage)) 
    218218    { 
    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"; 
    220225    } 
    221226 
     
    228233    { 
    229234        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"; 
    240235    } 
    241236 
     
    391386        print $target "\n<ServerOptions>\n"; 
    392387        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"; 
    394390        print $target "\tLogFile $endpoint->{LOGFILE}\n"; 
    395391        print $target "</ServerOptions>\n"; 
     
    400396sub emit_server_conf 
    401397{ 
    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"; 
    405402    print $target "HostID \"" . get_bmi_endpoint($node) . "\"\n"; 
    406403    print $target "LogFile $logfile\n"; 
     
    853850} 
    854851 
    855 sub get_pubkey 
    856 { 
    857     my $pubkey = $dirname . "/keystore"; 
    858     if ($opt_pubkey) { 
    859         $pubkey = $opt_pubkey; 
     852sub get_meta_storage 
     853{ 
     854    my $metastorage = "/pvfs2-storage-space"; 
     855    if ($opt_storage) { 
     856        $metastorage = $opt_storage; 
    860857    } 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} 
    892863 
    893864# get host port 
     
    995966    my $portmap = shift; 
    996967    my $storage = shift; 
     968    my $metastorage = shift; 
    997969    my $logfile = shift; 
    998     my $pubkey = shift; 
    999     my $privkey = shift; 
    1000970    my $ioline = ''; 
    1001971    if ($opt_ioservers) { 
     
    1026996                HOSTNAME => $io_host,  
    1027997                PORTMAP => $portmap,  
    1028                 STORAGE => $storage,  
    1029                 LOGFILE => $logfile, 
    1030                 PUBKEY => $pubkey, 
    1031                 PRIVKEY => $privkey}; 
     998                STORAGE => $storage, 
     999                METASTORAGE => $metastorage,  
     1000                LOGFILE => $logfile}; 
    10321001        } 
    10331002    } 
     
    10381007    my $portmap = shift; 
    10391008    my $storage = shift; 
     1009    my $metastorage = shift; 
    10401010    my $logfile = shift; 
    1041     my $pubkey = shift; 
    1042     my $privkey = shift; 
    10431011    my $metaline = ''; 
    10441012    my @meta_hosts; 
     
    10851053                HOSTNAME => $meta_host,  
    10861054                PORTMAP => $portmap,  
    1087                 STORAGE => $storage,  
    1088                 LOGFILE => $logfile, 
    1089                 PUBKEY => $pubkey, 
    1090                 PRIVKEY => $privkey}; 
     1055                STORAGE => $storage, 
     1056                METASTORAGE => $metastorage,  
     1057                LOGFILE => $logfile}; 
    10911058        } 
    10921059    } 
     
    11161083    { 
    11171084        my $stor = undef; 
     1085        my $mstor = undef; 
    11181086        my $logf = undef; 
    11191087        my $proto = undef; 
     
    11261094            # endpoint.  We want to match on [...]:storage:logfile 
    11271095            # 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 
    11291098            # 
    11301099            $ep =~ /\[([^\]]+)\](?::([^:]+))?(?::([^:]+))?/; 
    11311100 
    11321101            $stor = $2; 
    1133             $logf = $3; 
     1102            $mstor = $3; 
     1103            $logf = $4; 
    11341104 
    11351105            if(!defined($1)) 
     
    11821152                HOSTNAME => $hostname,  
    11831153                PORTMAP => \%port,  
    1184                 STORAGE => $stor,  
     1154                STORAGE => $stor, 
     1155                METASTORAGE => $mstor,  
    11851156                LOGFILE => $logf}; 
    11861157        } 
     
    12291200            my $pranges = $4; 
    12301201            $stor = $5; 
    1231             $logf = $6; 
     1202            $mstor = $6; 
     1203            $logf = $7; 
    12321204 
    12331205            if($proto !~ /mx/) 
    12341206            { 
    12351207                $logf = $stor; 
    1236                 $stor = $pranges; 
     1208                $stor = $mstor; 
     1209                $mstor = $pranges; 
    12371210                $pranges = $branges; 
    12381211                $branges = undef; 
     
    12761249                                PORTMAP => $portmap,  
    12771250                                STORAGE => $stor,  
     1251                                METASTORAGE => $mstor, 
    12781252                                LOGFILE => $logf}; 
    12791253                        } 
     
    12971271                                    PORTMAP => $portmap, 
    12981272                                    STORAGE => $stor, 
     1273                                    METASTORAGE => $mstor, 
    12991274                                    LOGFILE => $logf}; 
    13001275                            } 
     
    13351310                                        PORTMAP => $portmap, 
    13361311                                        STORAGE => $stor, 
     1312                                        METASTORAGE => $mstor, 
    13371313                                        LOGFILE => $logf}; 
    13381314                                } 
     
    14561432    'client-job-timeout=i' => \$opt_client_job_timeout, 
    14571433    'storage=s'     => \$opt_storage, 
    1458     'pubkey=s'      => \$opt_pubkey, 
    1459     'privkey=s'         => \$opt_privkey, 
    14601434    'help'          => \$show_help, 
    14611435    'quiet!'        => \$opt_quiet, 
     
    15261500    } 
    15271501    $output_target = \*FILEOUT; 
    1528     $dirname = abs_path(dirname($ARGV[0])); 
    15291502} 
    15301503 
     
    15541527 
    15551528    $default_storage = get_storage(); 
     1529    $default_meta_storage = get_meta_storage(); 
    15561530    $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); 
    15621534} 
    15631535 
     
    15751547} 
    15761548 
     1549if(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 
    15771559if(needs_default_value(LOGFILE)) 
    15781560{ 
     
    15841566    set_default_value(LOGFILE, $default_logfile); 
    15851567    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); 
    16081568} 
    16091569 
  • branches/cu-security-branch/src/apps/admin/pvfs2-ls.c

    r8351 r8397  
    3030 * is in place to break up large readdirs into multiple operations 
    3131 */ 
    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 
    3340 
    3441/* 
     
    3744*/ 
    3845#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 
    3956 
    4057/* optional parameters, filled in by parse_args() */ 
     
    5269    int list_no_owner; 
    5370    int list_inode; 
     71    int list_all_times; 
    5472    int list_use_si_units; 
    5573    char *start[MAX_NUM_PATHS]; 
     
    7795    PVFS_sys_attr *attr, 
    7896    int attr_error, 
    79     struct options *opts); 
     97    struct options *opts, 
     98    char* entry_buffer); 
    8099 
    81100static int do_list( 
     
    83102    char *start, 
    84103    int fs_id, 
    85     struct options *opts); 
     104    struct options *opts, 
     105    char *entry_buffer); 
    86106 
    87107static void print_entry_attr( 
     
    89109    char *entry_name, 
    90110    PVFS_sys_attr *attr, 
    91     struct options *opts); 
     111    struct options *opts, 
     112    char *entry_buffer); 
    92113 
    93114#define print_dot_and_dot_dot_info_if_required(refn)        \ 
     
    107128        else if (opts->list_long) {                         \ 
    108129            print_entry(".", refn.handle,                   \ 
    109                         refn.fs_id, NULL, 0, opts);         \ 
     130                        refn.fs_id, NULL, 0, opts,          \ 
     131                        entry_buffer);                      \ 
    110132            print_entry(".. (faked)", refn.handle,          \ 
    111                         refn.fs_id, NULL, 0, opts);         \ 
     133                        refn.fs_id, NULL, 0, opts,          \ 
     134                        entry_buffer);                      \ 
    112135        }                                                   \ 
    113136        else {                                              \ 
     
    189212    char *entry_name, 
    190213    PVFS_sys_attr *attr, 
    191     struct options *opts) 
     214    struct options *opts, 
     215    char *entry_buffer) 
    192216{ 
    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; 
    195219    struct group *grp = NULL; 
    196220    struct passwd *pwd = NULL; 
     
    198222    char *owner = empty_str, *group = empty_str; 
    199223    char *inode = empty_str; 
    200     time_t mtime; 
    201     struct tm *time;     
     224    time_t mtime, atime, ctime; 
     225    struct tm *time; 
    202226    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}; 
    204228    char scratch_size[16] = {0}, scratch_inode[16] = {0}; 
    205229    char f_type = '-'; 
    206230    char group_x_char = '-'; 
     231    int num_bytes = 0; 
    207232 
    208233    if (!opts->list_all && (entry_name[0] == '.')) 
     
    214239        return; 
    215240    } 
     241 
    216242    mtime = (time_t)attr->mtime; 
    217243    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    } 
    218267 
    219268    snprintf(scratch_owner,16,"%d",(int)attr->owner); 
     
    302351    } 
    303352 
    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", 
    306355             inode, 
    307356             f_type, 
     
    318367             formatted_group, 
    319368             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, 
    325370             entry_name); 
    326371 
     
    337382        free(formatted_group); 
    338383    } 
     384    if (formatted_time) 
     385    { 
     386        free(formatted_time); 
     387    } 
    339388 
    340389    if (attr->objtype == PVFS_TYPE_SYMLINK) 
     
    344393        if (opts->list_long) 
    345394        { 
    346             printf("%s -> %s\n", buf, attr->link_target); 
     395            printf("%s -> %s\n", entry_buffer, attr->link_target); 
    347396        } 
    348397        else 
    349398        { 
    350             printf("%s\n",buf); 
     399            printf("%s\n",entry_buffer); 
    351400        } 
    352401    } 
    353402    else 
    354403    { 
    355         printf("%s\n",buf); 
     404        printf("%s\n",entry_buffer); 
    356405    } 
    357406} 
     
    363412    PVFS_sys_attr *attr, 
    364413    int attr_error, 
    365     struct options *opts) 
     414    struct options *opts, 
     415    char *entry_buffer) 
    366416{ 
    367417    int ret = -1; 
     
    410460                return; 
    411461            } 
    412             print_entry_attr(handle, entry_name,  &getattr_response.attr, opts); 
     462            print_entry_attr(handle, entry_name,  &getattr_response.attr, opts, entry_buffer); 
    413463        } 
    414464        else 
    415465        { 
    416             print_entry_attr(handle, entry_name, attr, opts); 
     466            print_entry_attr(handle, entry_name, attr, opts, entry_buffer); 
    417467        } 
    418468    } 
     
    430480    char *start, 
    431481    int fs_id, 
    432     struct options *opts) 
     482    struct options *opts, 
     483    char *entry_buffer) 
    433484{ 
    434485    int i = 0, printed_dot_info = 0; 
     
    504555            { 
    505556                print_entry_attr(ref.handle, segment, 
    506                                  &getattr_response.attr, opts); 
     557                                 &getattr_response.attr, opts, entry_buffer); 
    507558            } 
    508559            else 
     
    511562                        NULL, 
    512563                        0, 
    513                         opts); 
     564                        opts, entry_buffer); 
    514565            } 
    515566            return 0; 
     
    568619                    &rdplus_response.attr_array[i], 
    569620                    rdplus_response.stat_err_array[i], 
    570                     opts); 
     621                    opts, entry_buffer); 
    571622 
    572623            PVFS_sys_attr *attr = &rdplus_response.attr_array[i]; 
     
    649700        { 
    650701            printf("\n"); 
    651             do_list(full_path,current->path,fs_id,opts); 
     702            do_list(full_path,current->path,fs_id,opts,entry_buffer); 
    652703            current = current->next; 
    653704            free(head->path); 
     
    685736        {"inode",0,0,0}, 
    686737        {"size",0,0,0}, 
     738        {"all-times",0,0,0}, 
    687739        {0,0,0,0} 
    688740    }; 
     
    753805                { 
    754806                    goto list_inode; 
     807                } 
     808                else if (strcmp("all-times", cur_option) == 0) 
     809                { 
     810                    goto list_all_times; 
    755811                } 
    756812                else 
     
    805861                tmp_opts->list_inode = 1; 
    806862                break; 
     863          list_all_times: 
     864                tmp_opts->list_all_times = 1; 
     865                break; 
    807866            case 't': 
    808867                do_timing = 1; 
     
    854913    fprintf(stderr,"  -n, --numeric-uid-gid      like -l, but list " 
    855914            "numeric UIDs and GIDs\n"); 
     915    fprintf(stderr,"      --all-times            display atime, mtime," 
     916            " and ctime information\n"); 
    856917    fprintf(stderr,"  -o                         like -l, but do not " 
    857918            "list group information\n"); 
     
    876937    char current_dir[PVFS_NAME_MAX] = {0}; 
    877938    int found_one = 0; 
     939    char *entry_buffer = malloc(ENTRY_MAX); 
    878940 
    879941    process_name = argv[0]; 
    880  
    881942    user_opts = parse_args(argc, argv); 
    882943    if (!user_opts) 
     
    9691030        else /* Root directory case has nothing to match */ 
    9701031        { 
    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)) 
    9751037        { 
    9761038            index++; 
    9771039            j++; 
    9781040        } 
    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); 
    9821045 
    9831046        if (user_opts->num_starts > 1) 
     
    9891052    PVFS_sys_finalize(); 
    9901053    free(user_opts); 
     1054    free(entry_buffer); 
    9911055 
    9921056    return(ret); 
  • branches/cu-security-branch/src/apps/admin/pvfs2-migrate-collection.c

    r8365 r8397  
    6363static int parse_args(int argc, char **argv, options_t *opts); 
    6464static 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, 
    6666    char* ver_string, int ver_string_max); 
    67 static int remove_collection_entry(char* storage_space, char* collname); 
     67static int remove_collection_entry(char* meta_storage_space, char* collname); 
    6868 
    6969int migrate_collection(void * config, void * sconfig); 
     
    7373/* functions specific to reading 0.0.1 collections */ 
    7474static 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,  
    7676    char* ver_string, int ver_string_max); 
    7777static 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,  
    7979    char* coll_name, TROVE_coll_id coll_id); 
    8080static int translate_coll_eattr_0_0_1( 
     
    8888    TROVE_context_id trove_context); 
    8989static int translate_bstreams_0_0_1( 
    90     char* storage_space, char* old_coll_path,  
     90    char* data_storage_space, char* old_coll_path,  
    9191    TROVE_coll_id coll_id, char* coll_name, 
    9292    TROVE_context_id trove_context); 
     
    234234        (struct server_configuration_s *) sconfig; 
    235235 
     236    if(server_config->meta_path == NULL) 
     237    { 
     238        server_config->meta_path = server_config->data_path; 
     239    } 
     240 
    236241    memset(version, 0, 256); 
    237242    /* find version of source storage space */ 
    238243    ret = src_get_version( 
    239         server_config->storage_path,  
     244        server_config->meta_path,  
    240245        fs_config->coll_id,  
    241246        fs_config->file_system_name, 
     
    254259    { 
    255260        sprintf(old_coll_path, "%s/%08x-old-%s", 
    256                 server_config->storage_path,  
     261                server_config->meta_path,  
    257262                fs_config->coll_id, version); 
    258263 
     
    293298 
    294299        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,  
    296303            fs_config->file_system_name,  
    297304            fs_config->coll_id); 
     
    328335             * is anymore 
    329336             */ 
    330             DIR * storage_dir; 
     337            DIR * data_storage_dir; 
     338            DIR * meta_storage_dir; 
    331339            struct dirent * next_dirent; 
    332340            char collname[PATH_MAX]; 
     
    336344            collname_length = sprintf(collname, "%08x-old", fs_config->coll_id); 
    337345 
    338             storage_dir = opendir(server_config->storage_path); 
    339             if(!storage_dir) 
    340             { 
    341                 fprintf(stderr, "Error: failed to open directory: %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); 
    343351                return -1; 
    344352            } 
    345353 
    346             while((next_dirent = readdir(storage_dir)) != NULL) 
     354            while((next_dirent = readdir(data_storage_dir)) != NULL) 
    347355            { 
    348356                int d_namelen = strlen(next_dirent->d_name); 
     
    353361 
    354362                    sprintf(old_coll_path, "%s/%s", 
    355                             server_config->storage_path, next_dirent->d_name); 
     363                            server_config->data_path, next_dirent->d_name); 
    356364 
    357365                    /* found an old version, delete it */ 
     
    366374                            "Error: failed to remove old collection at: %s\n", 
    367375                            old_coll_path); 
    368                         closedir(storage_dir); 
     376                        closedir(data_storage_dir); 
    369377                        return -1; 
    370378                    } 
     
    373381            } 
    374382 
     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 
    375425            if(removed_olddirs == 0) 
    376426            { 
     
    380430            } 
    381431 
    382             closedir(storage_dir); 
     432            closedir(data_storage_dir); 
    383433        } 
    384434        else 
     
    527577 */ 
    528578static int src_get_version( 
    529     char* storage_space,       /**< path to storage space */ 
     579    char* meta_storage_space,       /**< path to storage space */ 
    530580    TROVE_coll_id coll_id,     /**< collection id */ 
    531581    char* coll_name,           /**< collection name */ 
     
    537587 
    538588    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); 
    540590 
    541591    if(ret != 0) 
     
    544594                "Error: all known collection version checks " 
    545595                "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); 
    547597    } 
    548598 
     
    556606 */ 
    557607static int src_get_version_0_0_1( 
    558     char* storage_space,   /**< path to storage space */ 
     608    char* meta_storage_space,   /**< path to storage space */ 
    559609    TROVE_coll_id coll_id, /**< collection id */ 
    560610    char* ver_string,      /**< version in string format */ 
     
    567617 
    568618    sprintf(coll_db, "%s/%08x/collection_attributes.db",  
    569             storage_space, coll_id); 
     619            meta_storage_space, coll_id); 
    570620 
    571621    /* try to find a collections db */ 
     
    630680 */ 
    631681static 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 */ 
    633684    char* old_coll_path,   /**< path to old collection */ 
    634685    char* coll_name,       /**< collection name */ 
     
    645696 
    646697    /* 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); 
    648699 
    649700    if(access(current_path, F_OK) != 0) 
     
    664715    } 
    665716 
    666     ret = remove_collection_entry(storage_space, coll_name); 
     717    ret = remove_collection_entry(meta_storage_space, coll_name); 
    667718    if(ret < 0) 
    668719    { 
     
    679730        printf("VERBOSE Creating temporary collection to migrate to.\n"); 
    680731    ret = pvfs2_mkspace( 
    681         storage_space,  
     732        data_storage_space, 
     733        meta_storage_space, 
    682734        coll_name, 
    683735        coll_id,  
     
    700752        PVFS_perror("PINT_dist_initialize", ret); 
    701753        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); 
    703755        return(-1); 
    704756    } 
     
    706758    /* initialize trove and lookup collection */ 
    707759    ret = trove_initialize( 
    708         TROVE_METHOD_DBPF, NULL, storage_space, 0); 
     760        TROVE_METHOD_DBPF, NULL, data_storage_space, meta_storage_space,0); 
    709761    if (ret < 0) 
    710762    { 
    711763        PVFS_perror("trove_initialize", ret); 
    712764        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); 
    714766        return(-1); 
    715767    } 
     
    720772        fprintf(stderr, "Error: failed to lookup new collection.\n"); 
    721773        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); 
    723775        return -1;  
    724776    }    
     
    738790        fprintf(stderr, "Error: failed to migrate collection extended attributes.\n"); 
    739791        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); 
    741793        return(-1); 
    742794    } 
     
    749801        fprintf(stderr, "Error: failed to migrate dspace attributes.\n"); 
    750802        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); 
    752804        return(-1); 
    753805    } 
     
    760812        fprintf(stderr, "Error: failed to migrate keyvals.\n"); 
    761813        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); 
    763815        return(-1); 
    764816    } 
     
    771823    /* convert bstreams */ 
    772824    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); 
    774826    if(ret < 0) 
    775827    { 
    776828        fprintf(stderr, "Error: failed to migrate bstreams.\n"); 
    777829        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); 
    779831        return(-1); 
    780832    } 
     
    795847} 
    796848 
    797 static int remove_collection_entry(char* storage_space, char* collname) 
     849static int remove_collection_entry(char* meta_storage_space, char* collname) 
    798850{ 
    799851    char collections_db[PATH_MAX]; 
     
    803855    TROVE_coll_id coll_id; 
    804856 
    805     sprintf(collections_db, "%s/collections.db", storage_space); 
     857    sprintf(collections_db, "%s/collections.db", meta_storage_space); 
    806858 
    807859    ret = access(collections_db, F_OK); 
     
    14941546 */ 
    14951547static 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 */ 
    14971549    char* old_coll_path,            /**< path to old collection */ 
    14981550    TROVE_coll_id coll_id,          /**< collection id */ 
     
    15311583                    old_coll_path, i, tmp_ent->d_name); 
    15321584                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); 
    15341586                /* hard link to new location */ 
    15351587                ret = link(bstream_file, new_bstream_file); 
  • branches/cu-security-branch/src/apps/admin/pvfs2-mkspace.c

    r5684 r8397  
    3232    char data_ranges[PATH_MAX]; 
    3333    char collection[PATH_MAX]; 
    34     char storage_space[PATH_MAX]; 
     34    char data_space[PATH_MAX]; 
     35    char meta_space[PATH_MAX]; 
    3536} options_t; 
    3637 
     
    5455        {"verbose",0,0,0}, 
    5556        {"defaults",0,0,0}, 
    56         {"storage-space",1,0,0}, 
     57        {"data-space",1,0,0}, 
     58        {"meta-space",1,0,0}, 
    5759        {"coll-id",1,0,0}, 
    5860        {"coll-name",1,0,0}, 
     
    7173    } 
    7274 
    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:", 
    7476                              long_opts, &option_index)) != -1) 
    7577    { 
     
    9193                    goto do_verbose; 
    9294                } 
    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                                } 
    97103                else if (strcmp("coll-id", cur_option) == 0) 
    98104                { 
     
    173179          do_data_handle_range: 
    174180                strncpy(opts->data_ranges, optarg, PATH_MAX); 
    175                 break; 
    176             case 's': 
    177           do_storage_space: 
    178                 strncpy(opts->storage_space, optarg, PATH_MAX); 
    179181                break; 
    180182            case 'v': 
     
    224226               (strlen(opts->data_ranges) ? 
    225227                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")); 
    229234    } 
    230235} 
     
    259264            "create collection with the specified\n        " 
    260265            "                                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"); 
    263270    fprintf(stderr,"  -v, --verbose                        " 
    264271            "operate in verbose mode\n"); 
     
    297304    print_options(&opts); 
    298305 
    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"); 
    302315        return -1; 
    303316    } 
     
    319332    if (opts.delete_storage) 
    320333    { 
    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); 
    324337    } 
    325338    else 
    326339    { 
    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); 
    331345    } 
    332346    return ret; 
  • branches/cu-security-branch/src/apps/admin/pvfs2-showcoll.c

    r7941 r8397  
    2424size_t strnlen(const char *s, size_t limit); 
    2525 
    26 static char storage_space[PATH_MAX] = "/tmp/pvfs2-test-space"; 
     26static char data_path[PATH_MAX] = "/tmp/pvfs2-test-space"; 
     27static char meta_path[PATH_MAX] = "/tmp/pvfs2-test-space"; 
    2728static char collection[PATH_MAX]; 
    2829static int verbose = 0, got_collection = 0, print_keyvals = 0, got_dspace_handle = 0; 
     
    7273    /* initialize trove, verifying storage space exists */ 
    7374    ret = trove_initialize( 
    74         TROVE_METHOD_DBPF, NULL, storage_space, 0); 
     75      TROVE_METHOD_DBPF, NULL, data_path, meta_path, 0); 
    7576    if (ret < 0)  
    7677    { 
     
    8283 
    8384    if (verbose) fprintf(stderr, 
    84                          "%s: info: initialized with storage space '%s'.\n", 
     85                         "%s: info: initialized with storage spaces '%s' and '%s'.\n", 
    8586                         argv[0], 
    86                          storage_space); 
     87                         data_path, meta_path); 
    8788 
    8889    /* if no collection was specified, simply print out the collections and exit */ 
     
    165166    if (no_root_handle) { 
    166167        fprintf(stdout, 
    167                 "Storage space %s, collection %s (coll_id = %d, " 
     168                "Storage space %s and %s, collection %s (coll_id = %d, " 
    168169                "*** no root_handle found ***):\n", 
    169                 storage_space, 
     170                data_path, 
     171                meta_path, 
    170172                collection, 
    171173                coll_id); 
     
    173175    else { 
    174176        fprintf(stdout, 
    175                 "Storage space %s, collection %s (coll_id = %d, " 
     177                "Storage space %s and %s, collection %s (coll_id = %d, " 
    176178                "root_handle = 0x%08llx):\n", 
    177                 storage_space, 
     179                data_path, 
     180                meta_path, 
    178181                collection, 
    179182                coll_id, 
     
    201204    int c; 
    202205 
    203     while ((c = getopt(argc, argv, "s:c:d:kvh")) != EOF) { 
     206    while ((c = getopt(argc, argv, "s:m:c:d:kvh")) != EOF) { 
    204207        switch (c) { 
    205             case 's': 
    206                 strncpy(storage_space, optarg, PATH_MAX); 
     208                case 's': 
     209                strncpy(data_path, optarg, PATH_MAX); 
    207210                break; 
     211                case 'm': 
     212                strncpy(meta_path, optarg, PATH_MAX); 
    208213            case 'c': /* collection */ 
    209214                got_collection = 1; 
     
    225230            case 'h': 
    226231                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"); 
    228233                fprintf(stderr, "\tdefault storage space is '/tmp/pvfs2-test-space'.\n"); 
    229234                fprintf(stderr, "\t'-v' turns on verbose output.\n"); 
     
    499504    pos = TROVE_ITERATE_START; 
    500505 
    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); 
    502508 
    503509    while (count > 0) { 
  • branches/cu-security-branch/src/apps/admin/pvfs2-stat.c

    r8351 r8397  
    5555{ 
    5656   int               ret          = -1, 
     57                     ret_agg      =  0, 
    5758                     i            =  0; 
    5859   char           ** ppszPvfsPath = NULL; 
     
    151152         fprintf(stderr, "Error stating [%s]\n", user_opts.pszFiles[i]); 
    152153      } 
     154      ret_agg |= ret; 
    153155   } 
    154156 
     
    179181   } 
    180182 
    181    return(0); 
     183   return(ret_agg); 
    182184} 
    183185 
     
    478480      fprintf(stdout, "  datafiles     : %d\n", attr->dfile_count); 
    479481   } 
     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 
    480489   /* dirent_count is only valid on directories */ 
    481490   if( (attr->mask & PVFS_ATTR_SYS_DIRENT_COUNT) && 
  • branches/cu-security-branch/src/apps/admin/pvfs2-xattr.c

    r8351 r8397  
    33 *  
    44 * 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 
    58 */ 
    69 
     
    2629#include "xattr-utils.h" 
    2730 
     31#include "pvfs2-mirror.h" 
     32 
    2833#define VALBUFSZ 1024 
    2934 
     
    4146struct options 
    4247{ 
    43     PVFS_ds_keyval key; 
    44     PVFS_ds_keyval val; 
     48    PVFS_ds_keyval *key; 
     49    PVFS_ds_keyval *val; 
    4550    char* srcfile; 
    46     int get, text; 
     51    int get, text, key_count; 
    4752}; 
    4853 
     
    7883static struct options* parse_args(int argc, char* argv[]); 
    7984static 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 
     86static 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 
    8293static void usage(int argc, char** argv); 
    8394static int resolve_filename(file_object *obj, char *filename); 
     
    92103  file_object src; 
    93104  PVFS_credential credentials; 
     105  int i; 
    94106 
    95107  memset(&src, 0, sizeof(src)); 
     
    124136      return -1; 
    125137  } 
    126   if (!eattr_is_prefixed(user_opts->key.buffer)) 
     138 
     139  if (!eattr_is_prefixed(user_opts->key[0].buffer)) 
    127140  { 
    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); 
    129143      return -1; 
    130144  } 
    131145  if (!user_opts->get) 
    132146  { 
    133       if (!permit_set(&user_opts->key)) 
     147      if (!permit_set(&user_opts->key[0])) 
    134148      { 
    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); 
    136151          return -1; 
    137152      } 
    138       if (modify_val(&user_opts->key, &user_opts->val) < 0) 
     153      if (modify_val(&user_opts->key[0], &user_opts->val[0]) < 0) 
    139154      { 
    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); 
    141158          return -1; 
    142159      } 
    143160  } 
    144161 
    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); 
    146168    if (ret != 0)  
    147169    { 
     
    150172    if (user_opts->get && user_opts->text)   
    151173    { 
    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); 
    155180            if (hint->flags & PVFS_IMMUTABLE_FL) { 
    156                 printf("immutable file "); 
     181                printf(" :immutable file "); 
    157182            } 
    158183            if (hint->flags & PVFS_APPEND_FL) { 
    159                 printf("Append-only file "); 
     184                printf(" :Append-only file "); 
    160185            } 
    161186            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"); 
    163191            } 
    164192            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*/ 
    165246        } 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); 
    169250        } 
    170251    } 
     
    175256static int modify_val(PVFS_ds_keyval *key_p, PVFS_ds_keyval *val_p) 
    176257{ 
    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) 
    178260    { 
    179261        PVFS_metafile_hint hint; 
     
    195277        memcpy(val_p->buffer, &hint, sizeof(hint)); 
    196278        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 
    198291    return 0; 
    199292} 
     
    214307 * returns zero on success and negative one on failure 
    215308 */ 
    216 static int pvfs2_eattr(int get, file_object *obj, PVFS_ds_keyval *key_p, 
    217         PVFS_ds_keyval *val_p, PVFS_credential *creds)  
     309static 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)  
    218315{ 
    219316  int ret = -1; 
     
    224321      { 
    225322#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) 
    227327#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) 
    229334#endif 
    230335        { 
     
    253358  else 
    254359  { 
    255       if (get == 1) 
     360      if (get == 1 && key_count == 1) 
    256361      { 
    257362          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 { 
    260388          ret = PVFS_sys_seteattr(obj->u.pvfs2.ref, creds, key_p, val_p, 0, NULL); 
    261389      } 
     
    291419    memset(tmp_opts, 0, sizeof(struct options)); 
    292420 
     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 
    293442    /* fill in defaults */ 
    294     memset(&tmp_opts->key, 0, sizeof(PVFS_ds_keyval)); 
    295     memset(&tmp_opts->val, 0, sizeof(PVFS_ds_keyval)); 
    296443    tmp_opts->srcfile = strdup(argv[argc-1]); 
    297444    tmp_opts->get = 1; 
     
    308455                break; 
    309456            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; 
    312459                break; 
    313460            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                } 
    317483            case('?'): 
    318484                printf("?\n"); 
     
    321487        } 
    322488    } 
     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 
    323507    if (tmp_opts->get == 1) 
    324508    { 
    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"); 
    337570            usage(argc, argv); 
    338571            exit(EXIT_FAILURE); 
    339572        } 
    340573    } 
    341     if (tmp_opts->key.buffer == NULL) 
     574    if (tmp_opts->key[0].buffer == NULL) 
    342575    { 
    343576        fprintf(stderr, "Please specify key if getting extended attributes\n"); 
     
    351584static void usage(int argc, char** argv) 
    352585{ 
    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]); 
    354588    return; 
    355589} 
     
    450684        memcpy(&obj->u.pvfs2.attr, &resp_getattr.attr, 
    451685               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; 
    453691        obj->u.pvfs2.ref = ref; 
    454692    }