Changeset 8899

Show
Ignore:
Timestamp:
06/28/11 12:18:43 (23 months ago)
Author:
walt
Message:

added IO byte counters for small_io
added IO byte counters for ONLY small_io and ONLY flows
minor format edit
debug fixes to usrint code

Location:
branches/Orange-Branch
Files:
15 modified

Legend:

Unmodified
Added
Removed
  • branches/Orange-Branch/include/pvfs2-mgmt.h

    r8891 r8899  
    6868    PINT_PERF_REQSCHED = 6,             /* instantaneous active requests */ 
    6969    PINT_PERF_REQUESTS = 7,             /* requests received */ 
     70    PINT_PERF_SMALL_READ = 8,           /* bytes read by small_io */ 
     71    PINT_PERF_SMALL_WRITE = 9,          /* bytes written by small_io */ 
     72    PINT_PERF_FLOW_READ = 10,           /* bytes read by flow */ 
     73    PINT_PERF_FLOW_WRITE = 11,          /* bytes written by flow */ 
    7074}; 
    7175 
  • branches/Orange-Branch/src/apps/admin/pvfs2-perf-mon-snmp.c

    r8891 r8899  
    3434#define OID_REQSCHED ".1.3.6.1.4.1.7778.6" 
    3535#define OID_REQUESTS ".1.3.6.1.4.1.7778.7" 
     36#define OID_SMALL_READ ".1.3.6.1.4.1.7778.8" 
     37#define OID_SMALL_WRITE ".1.3.6.1.4.1.7778.9" 
     38#define OID_FLOW_READ ".1.3.6.1.4.1.7778.10" 
     39#define OID_FLOW_WRITE ".1.3.6.1.4.1.7778.11" 
    3640 
    3741#define INT_TYPE "INTEGER" 
     
    6165   {OID_REQSCHED, INT_TYPE, PINT_PERF_REQSCHED, "Requests Active"}, 
    6266   {OID_REQUESTS, CNT_TYPE, PINT_PERF_REQUESTS, "Requests Received"}, 
     67   {OID_SMALL_READ, CNT_TYPE, PINT_PERF_SMALL_READ, "Bytes Read by Small_IO"}, 
     68   {OID_SMALL_WRITE, CNT_TYPE, PINT_PERF_SMALL_WRITE, "Bytes Written by Small_IO"}, 
     69   {OID_FLOW_READ, CNT_TYPE, PINT_PERF_FLOW_READ, "Bytes Read by Flow"}, 
     70   {OID_FLOW_WRITE, CNT_TYPE, PINT_PERF_FLOW_WRITE, "Bytes Written by Flow"}, 
    6371   {NULL, NULL, -1, NULL}   /* this halts the key count */ 
    6472}; 
     
    293301                    strcmp(cmd_buffer, key_table[k].key_oid); k++); 
    294302            /* out of for loop k equals selected key */ 
    295             if (k <= max_keys) 
     303            if (k < max_keys) 
    296304            { 
    297305                returnType = key_table[k].key_type; 
  • branches/Orange-Branch/src/client/usrint/Makefile

    r8890 r8899  
    44LIBDIR= 
    55 
    6 CFLAGS=$(INCDIR) $(LIBDIR) 
     6CFLAGS=-g -O0 $(INCDIR) $(LIBDIR) 
    77 
    88OBJS=iocommon.o openfile-util.o posix-pvfs.o posix.o stdio.o request.o 
     
    1212all: $(OBJS) 
    1313 
    14 clean:  
     14clean:: 
    1515        rm *.o 
    1616 
  • branches/Orange-Branch/src/client/usrint/iocommon.c

    r8890 r8899  
    1616#include <iocommon.h> 
    1717 
    18 int init=0; 
    19  
    20 /* Perform PVFS initialization if not already finished */ 
    21 void iocommon_ensure_init() 
    22 { 
    23  
    24     /* Initialize the file system with mount points */ 
    25     int ret; 
    26     if (!init) 
    27     { 
    28         ret = PVFS_util_init_defaults(); 
    29         assert(ret==PVFS_FD_SUCCESS); 
    30         init=1; 
    31     } 
    32  
    33 } 
    3418 
    3519void iocommon_cred(PVFS_credentials **credentials) 
     
    5236{ 
    5337    PVFS_credentials *credentials; 
     38 
     39    pvfs_sys_init(); 
    5440    iocommon_cred(&credentials); 
    5541    return PVFS_sys_flush(pd->pvfs_ref, credentials, PVFS_HINT_NULL); 
     
    7157    memset(&resp_lookup, 0, sizeof(resp_lookup)); 
    7258 
     59    pvfs_sys_init(); 
     60    iocommon_cred(&credentials); 
     61 
    7362    /* Determine the fs_id and pvfs_path */ 
    7463    rc = PVFS_util_resolve(abs_path, &lookup_fs_id, pvfs_path, 256); 
    75     if (rc == -1) 
     64    if (rc < 0) 
    7665    { 
    7766        return -1; 
    7867    } 
    7968 
    80     iocommon_cred(&credentials); 
    8169    rc = PVFS_sys_lookup(lookup_fs_id, pvfs_path, 
    8270                         credentials, &resp_lookup, 
     
    10088 
    10189    /* Initialize any variables */ 
     90    pvfs_sys_init(); 
    10291    memset(&resp_lookup, 0, sizeof(resp_lookup)); 
    10392 
     
    135124 
    136125    /* Initialize */ 
     126    pvfs_sys_init(); 
    137127    memset(&attr, 0, sizeof(attr)); 
    138128    memset(&resp_create, 0, sizeof(resp_create)); 
     
    155145#endif 
    156146 
    157     attr.owner = getuid(); 
    158     attr.group = getgid(); 
     147    attr.owner = geteuid(); 
     148    attr.group = getegid(); 
    159149    attr.atime = time(NULL); 
    160150    attr.mtime = attr.atime; 
     
    260250    memset(&attributes_resp, 0, sizeof(attributes_resp)); 
    261251 
     252    pvfs_sys_init(); 
     253    iocommon_cred(&credentials); 
     254 
    262255    /* Split the path into a directory and file */ 
    263     rc = split_pathname(pathname, &directory, &filename); 
    264     if (rc == -1) 
     256    rc = split_pathname(pathname, 0, &directory, &filename); 
     257    if (rc < 0) 
    265258    { 
    266259        goto errorout; 
     
    281274    { 
    282275        rc = iocommon_lookup_absolute(directory, &parent_ref); 
    283         if (rc == -1) 
     276        if (rc < 0) 
    284277        { 
    285278            goto errorout; 
     
    294287                                          follow_link, 
    295288                                          &parent_ref); 
    296             if (rc == -1) 
     289            if (rc < 0) 
    297290            { 
    298291                goto errorout; 
     
    335328            /* create failed, the file must have been */ 
    336329            /* created by a different process, so just open it */ 
    337             if (rc != -1) 
     330            if (rc < 0) 
    338331            { 
    339332                /* get existing handle */ 
     
    342335                                              follow_link, 
    343336                                              &file_ref); 
    344                 if (rc == -1) 
     337                if (rc < 0) 
    345338                { 
    346339                    /* not sure what is wrong */ 
     
    360353 
    361354    /* Get the file's type information from its attributes */ 
    362     PVFS_sys_getattr(pd->pvfs_ref, PVFS_ATTR_SYS_ALL_NOHINT, 
    363                      credentials, &attributes_resp, NULL); 
     355    rc = PVFS_sys_getattr(pd->pvfs_ref, 
     356                          PVFS_ATTR_SYS_ALL_NOHINT, 
     357                          credentials, 
     358                          &attributes_resp, 
     359                          NULL); 
     360    if (rc < 0) 
     361    { 
     362        goto errorout; 
     363    } 
    364364    pd->mode = attributes_resp.attr.perms; /* this may change */ 
    365365    if (attributes_resp.attr.objtype & PVFS_TYPE_METAFILE) 
     
    379379    if (flag & O_TRUNC) 
    380380    { 
    381         PVFS_credentials *credentials; 
    382         iocommon_cred(&credentials); 
    383         PVFS_sys_truncate(file_ref, 0, credentials, NULL); 
     381        rc = PVFS_sys_truncate(file_ref, 0, credentials, NULL); 
     382        if (rc < 0) 
     383        { 
     384            goto errorout; 
     385        } 
    384386    } 
    385387 
     
    387389    if (flag & O_APPEND) 
    388390    { 
    389         iocommon_lseek(pd, 0, 0, SEEK_END); 
     391        rc = iocommon_lseek(pd, 0, 0, SEEK_END); 
    390392    } 
    391393 
     
    401403        free(filename); 
    402404    } 
    403     if (rc == -1) 
     405    if (rc < 0) 
    404406    { 
    405407        return NULL; 
     
    409411        return pd; 
    410412    } 
     413} 
     414 
     415/** 
     416 * Implementation of truncate via PVFS 
     417 * 
     418 */ 
     419int iocommon_truncate(PVFS_object_ref file_ref, off64_t length) 
     420{ 
     421    PVFS_credentials *credentials; 
     422 
     423    pvfs_sys_init(); 
     424    iocommon_cred(&credentials); 
     425    return PVFS_sys_truncate(file_ref, length, credentials, NULL); 
    411426} 
    412427 
     
    451466        { 
    452467            /* Get the file's size in bytes as the ending offset */ 
    453             rc = PVFS_sys_getattr(pd->pvfs_ref, PVFS_ATTR_SYS_SIZE, 
    454                                   credentials, &attributes_resp, NULL); 
     468            rc = PVFS_sys_getattr(pd->pvfs_ref, 
     469                                  PVFS_ATTR_SYS_SIZE, 
     470                                  credentials, 
     471                                  &attributes_resp, 
     472                                  NULL); 
    455473            if(rc) 
    456474            { 
     
    481499                                  &readdir_resp, 
    482500                                  NULL); 
    483             if(rc == -1) 
     501            if(rc < 0) 
    484502            { 
    485503                return -1; 
     
    492510} 
    493511 
    494 /* 
    495  * pvfs_unlink implementation 
    496  * need to verify this is a file or symlink 
    497  * use rmdir for directory 
     512/** 
     513 * implements unlink and rmdir 
     514 *  
     515 * dirflag indicates trying to remove a dir (rmdir) 
    498516 */ 
    499517int iocommon_remove (const char *pathname, 
     
    514532 
    515533    /* Initialize the system interface for this process */ 
    516     iocommon_ensure_init(); 
     534    pvfs_sys_init(); 
    517535    iocommon_cred(&credentials); 
    518536 
    519     rc = split_pathname(pathname, &parentdir, &file); 
    520     if (rc == -1) 
     537    rc = split_pathname(pathname, dirflag, &parentdir, &file); 
     538    if (rc < 0) 
    521539    { 
    522540        return -1; 
     
    526544    { 
    527545        rc = iocommon_lookup_absolute(parentdir, &parent_ref); 
    528         if (rc == -1) 
     546        if (rc < 0) 
    529547        { 
    530548            goto errorout; 
     
    533551    else 
    534552    { 
    535         if (!parentdir) 
     553        if (parentdir) 
    536554        { 
    537555            rc = iocommon_lookup_relative(parentdir, *pdir, 
    538556                            PVFS2_LOOKUP_LINK_FOLLOW, &parent_ref); 
    539             if (rc == -1) 
     557            if (rc < 0) 
    540558            { 
    541559                goto errorout; 
     
    552570    rc = iocommon_lookup_relative(file, parent_ref, 
    553571                PVFS2_LOOKUP_LINK_NO_FOLLOW, &file_ref); 
    554     if (rc == -1) 
     572    if (rc < 0) 
    555573    { 
    556574        goto errorout; 
    557575    } 
    558576    rc = iocommon_getattr(file_ref, &attr); 
    559     if (rc == -1) 
     577    if (rc < 0) 
    560578    { 
    561579        goto errorout; 
    562580    } 
    563     if ((attr.objtype & PVFS_TYPE_DIRECTORY) && dirflag) 
     581    if ((attr.objtype & PVFS_TYPE_DIRECTORY) && !dirflag) 
    564582    { 
    565583        errno = EISDIR; 
    566584        goto errorout; 
    567585    } 
    568     else if (!(attr.objtype & PVFS_TYPE_DIRECTORY) && !dirflag) 
     586    else if (!(attr.objtype & PVFS_TYPE_DIRECTORY) && dirflag) 
    569587    { 
    570588        errno = ENOTDIR; 
     
    572590    } 
    573591 
     592    /* should check to see if any process has file open */ 
    574593    rc = PVFS_sys_remove(file, parent_ref, credentials, PVFS_HINT_NULL); 
    575594 
     
    583602        free(file); 
    584603    } 
    585     if (rc == -1) 
     604    if (rc < 0) 
    586605    { 
    587606        return -1; 
     
    593612} 
    594613 
     614/** 
     615 * wrapper for unlink 
     616 */ 
    595617int iocommon_unlink(const char *pathname, 
    596618                    PVFS_object_ref *pdir) 
    597619{ 
    598     return iocommon_remove(pathname, pdir, 1); 
    599 } 
    600  
     620    return iocommon_remove(pathname, pdir, 0); 
     621} 
     622 
     623/** 
     624 * wrapper for rmdir 
     625 */ 
    601626int iocommon_rmdir(const char *pathname, 
    602627                   PVFS_object_ref *pdir) 
    603628{ 
    604     return iocommon_remove(pathname, pdir, 0); 
     629    return iocommon_remove(pathname, pdir, 1); 
    605630} 
    606631 
     
    620645 
    621646    iocommon_cred(&creds); 
    622     rc = split_pathname(oldpath, &olddir, &oldname); 
    623     if (rc == -1) 
     647    rc = split_pathname(oldpath, 0, &olddir, &oldname); 
     648    if (rc < 0) 
    624649    { 
    625650        return -1; 
    626651    } 
    627     if (!olddir) 
     652    if (!oldpdir) 
    628653    { 
    629654        rc = iocommon_lookup_absolute(olddir, &oldref); 
    630         if (rc == -1) 
     655        if (rc < 0) 
    631656        { 
    632657            goto errorout; 
     
    635660    else 
    636661    { 
    637         if (!olddir) 
     662        if (olddir) 
    638663        { 
    639664            rc = iocommon_lookup_relative(olddir, *oldpdir,  
    640665                                PVFS2_LOOKUP_LINK_FOLLOW, &oldref); 
    641             if (rc == -1) 
     666            if (rc < 0) 
    642667            { 
    643668                goto errorout; 
     
    649674        } 
    650675    } 
    651     rc = split_pathname(newpath, &olddir, &oldname); 
    652     if (rc == -1) 
     676    rc = split_pathname(newpath, 0, &newdir, &newname); 
     677    if (rc < 0) 
    653678    { 
    654679        goto errorout; 
     
    657682    { 
    658683        rc = iocommon_lookup_absolute(newdir, &newref); 
    659         if (rc == -1) 
     684        if (rc < 0) 
    660685        { 
    661686            goto errorout; 
     
    664689    else 
    665690    { 
    666         if (!olddir) 
     691        if (newdir) 
    667692        { 
    668693            rc = iocommon_lookup_relative(newdir, *newpdir, 
    669694                            PVFS2_LOOKUP_LINK_FOLLOW, &newref); 
    670             if (rc == -1) 
     695            if (rc < 0) 
    671696            { 
    672697                goto errorout; 
     
    847872} 
    848873 
    849 /* WBL - question - should attr not be a pointer */ 
    850874int iocommon_setattr(PVFS_object_ref obj, PVFS_sys_attr *attr) 
    851875{ 
     
    963987    { 
    964988        attr.owner = owner; 
     989        attr.mask |= PVFS_ATTR_SYS_UID; 
    965990    } 
    966991    if (owner != -1) 
    967992    { 
    968993        attr.group = group; 
    969     } 
    970     attr.mask = PVFS_ATTR_SYS_UID | PVFS_ATTR_SYS_GID; 
     994        attr.mask |= PVFS_ATTR_SYS_GID; 
     995    } 
    971996 
    972997    rc = iocommon_setattr(pd->pvfs_ref, &attr); 
     
    9791004    int                  rc = 0; 
    9801005    PVFS_sys_attr        attr; 
     1006 
     1007    /* Initialize */ 
     1008    memset(&attr, 0, sizeof(attr)); 
    9811009 
    9821010    attr.perms = mode & 07777; /* mask off any stray bits */ 
     
    10071035    memset(&resp_mkdir,  0, sizeof(resp_mkdir)); 
    10081036 
     1037    pvfs_sys_init(); 
    10091038    iocommon_cred(&credentials); 
    10101039 
    1011     rc = split_pathname(pvfs_path, &parentdir, &filename); 
    1012     if (rc == -1) 
     1040    rc = split_pathname(pvfs_path, 1, &parentdir, &filename); 
     1041    if (rc < 0) 
    10131042    { 
    10141043        return -1; 
     
    10211050    { 
    10221051        rc = iocommon_lookup_absolute(parentdir, &parent_ref); 
    1023         if (rc == -1) 
     1052        if (rc < 0) 
    10241053        { 
    10251054            goto errorout; 
     
    10281057    else 
    10291058    { 
    1030         if (!parentdir) 
     1059        if (parentdir) 
    10311060        { 
    10321061            rc = iocommon_lookup_relative(parentdir, *pdir, 
    10331062                            PVFS2_LOOKUP_LINK_FOLLOW, &parent_ref); 
    1034             if (rc == -1) 
     1063            if (rc < 0) 
    10351064            { 
    10361065                goto errorout; 
     
    10441073    
    10451074    /* Set the attributes for the new directory */ 
    1046     attr.owner = (int)getuid; 
    1047     attr.group = (int)getgid; 
    1048     attr.perms = mode; 
     1075    attr.owner = geteuid(); 
     1076    attr.group = getegid(); 
     1077    attr.perms = mode & 07777; /* mask off stray bits */ 
    10491078    attr.mask = (PVFS_ATTR_SYS_ALL_SETABLE); 
    10501079 
     
    11081137    memset(&resp_symlink,0, sizeof(resp_symlink)); 
    11091138 
     1139    pvfs_sys_init(); 
    11101140    iocommon_cred(&credentials); 
    11111141 
    11121142 
    1113     rc = split_pathname(pvfs_path, &parentdir, &filename); 
    1114     if (rc == -1) 
     1143    rc = split_pathname(pvfs_path, 0, &parentdir, &filename); 
     1144    if (rc < 0) 
    11151145    { 
    11161146        return -1; 
     
    11231153    { 
    11241154        rc = iocommon_lookup_absolute(parentdir, &parent_ref); 
    1125         if (rc == -1) 
     1155        if (rc < 0) 
    11261156        { 
    11271157            goto errorout; 
     
    11301160    else 
    11311161    { 
    1132         if (!parentdir) 
     1162        if (parentdir) 
    11331163        { 
    11341164            rc = iocommon_lookup_relative(parentdir, *pdir, 
    11351165                            PVFS2_LOOKUP_LINK_FOLLOW, &parent_ref); 
    1136             if (rc == -1) 
     1166            if (rc < 0) 
    11371167            { 
    11381168                goto errorout; 
     
    12061236                          &readdir_resp, 
    12071237                          NULL); 
    1208     if(rc == -1) 
     1238    if(rc < 0) 
    12091239    { 
    12101240        return -1; 
    12111241    } 
    12121242    pd->token = readdir_resp.token; 
    1213     name_max = MIN(NAME_MAX, PVFS_NAME_MAX); 
     1243    name_max = PVFS_util_min(NAME_MAX, PVFS_NAME_MAX); 
    12141244    while(readdir_resp.pvfs_dirent_outcount--) 
    12151245    { 
     
    12181248        dirp->d_off = pd->file_pointer; 
    12191249        dirp->d_reclen = sizeof(PVFS_dirent); 
    1220         memncpy(dirp->d_name, readdir_resp.dirent_array[i].d_name, name_max); 
     1250        memcpy(dirp->d_name, readdir_resp.dirent_array[i].d_name, name_max); 
    12211251        dirp->d_name[name_max] = 0; 
    12221252        pd->file_pointer += sizeof(PVFS_dirent); 
     
    12781308 
    12791309    /* Initialize the system interface for this process */ 
    1280     iocommon_ensure_init(); 
     1310    pvfs_sys_init(); 
    12811311    iocommon_cred(&credentials); 
    12821312 
    1283     rc = split_pathname(pvfs_path, &parentdir, &file); 
    1284     if (rc == -1) 
     1313    rc = split_pathname(pvfs_path, 0, &parentdir, &file); 
     1314    if (rc < 0) 
    12851315    { 
    12861316        return -1; 
     
    12901320    { 
    12911321        rc = iocommon_lookup_absolute(parentdir, &parent_ref); 
    1292         if (rc == -1) 
     1322        if (rc < 0) 
    12931323        { 
    12941324            goto errorout; 
     
    12971327    else 
    12981328    { 
    1299         if (!parentdir) 
     1329        if (parentdir) 
    13001330        { 
    13011331            rc = iocommon_lookup_relative(parentdir, *pdir, 
    13021332                            PVFS2_LOOKUP_LINK_FOLLOW, &parent_ref); 
    1303             if (rc == -1) 
     1333            if (rc < 0) 
    13041334            { 
    13051335                goto errorout; 
  • branches/Orange-Branch/src/client/usrint/iocommon.h

    r8890 r8899  
    6868                               mode_t file_permission, 
    6969                               PVFS_object_ref *pdir); 
     70 
     71int iocommon_truncate(PVFS_object_ref file_ref, off64_t length); 
    7072 
    7173off64_t iocommon_lseek(pvfs_descriptor *pd, off64_t offset, PVFS_size unit_size, int whence); 
  • branches/Orange-Branch/src/client/usrint/openfile-util.c

    r8890 r8899  
    1414#include <posix-ops.h> 
    1515#include <openfile-util.h> 
    16  
    17 static int pvfs_is_sys_initialized = 0;  
    1816 
    1917#define PREALLOC 3 
     
    2220static int next_descriptor = 0;  
    2321static pvfs_descriptor **descriptor_table;  
     22static char rstate[256];  /* used for random number generation */ 
     23 
     24posix_ops glibc_ops; 
    2425 
    2526pvfs_descriptor pvfs_stdin = 
     
    6566}; 
    6667 
     68void load_glibc(void) 
     69{  
     70    glibc_ops.open = dlsym(RTLD_NEXT, "open"); 
     71    glibc_ops.open64 = dlsym(RTLD_NEXT, "open64"); 
     72    glibc_ops.openat = dlsym(RTLD_NEXT, "openat"); 
     73    glibc_ops.openat64 = dlsym(RTLD_NEXT, "openat64"); 
     74    glibc_ops.creat = dlsym(RTLD_NEXT, "creat"); 
     75    glibc_ops.creat64 = dlsym(RTLD_NEXT, "creat64"); 
     76    glibc_ops.unlink = dlsym(RTLD_NEXT, "unlink"); 
     77    glibc_ops.unlinkat = dlsym(RTLD_NEXT, "unlinkat"); 
     78    glibc_ops.rename = dlsym(RTLD_NEXT, "rename"); 
     79    glibc_ops.renameat = dlsym(RTLD_NEXT, "renameat"); 
     80    glibc_ops.read = dlsym(RTLD_NEXT, "read"); 
     81    glibc_ops.pread = dlsym(RTLD_NEXT, "pread"); 
     82    glibc_ops.readv = dlsym(RTLD_NEXT, "readv"); 
     83    glibc_ops.pread64 = dlsym(RTLD_NEXT, "pread64"); 
     84    glibc_ops.write = dlsym(RTLD_NEXT, "write"); 
     85    glibc_ops.pwrite = dlsym(RTLD_NEXT, "pwrite"); 
     86    glibc_ops.writev = dlsym(RTLD_NEXT, "writev"); 
     87/*  glibc_ops.write64 = dlsym(RTLD_NEXT, "write64"); */ 
     88    glibc_ops.lseek = dlsym(RTLD_NEXT, "lseek"); 
     89    glibc_ops.lseek64 = dlsym(RTLD_NEXT, "lseek64"); 
     90    glibc_ops.truncate = dlsym(RTLD_NEXT, "truncate"); 
     91    glibc_ops.truncate64 = dlsym(RTLD_NEXT, "truncate64"); 
     92    glibc_ops.ftruncate = dlsym(RTLD_NEXT, "ftruncate"); 
     93    glibc_ops.ftruncate64 = dlsym(RTLD_NEXT, "ftruncate64"); 
     94    glibc_ops.close = dlsym(RTLD_NEXT, "close"); 
     95    glibc_ops.flush = dlsym(RTLD_NEXT, "flush"); 
     96    glibc_ops.stat = dlsym(RTLD_NEXT, "stat"); 
     97    glibc_ops.stat64 = dlsym(RTLD_NEXT, "stat64"); 
     98    glibc_ops.fstat = dlsym(RTLD_NEXT, "fstat"); 
     99    glibc_ops.fstat64 = dlsym(RTLD_NEXT, "fstat64"); 
     100    glibc_ops.fstatat = dlsym(RTLD_NEXT, "fstatat"); 
     101    glibc_ops.fstatat64 = dlsym(RTLD_NEXT, "fstatat64"); 
     102    glibc_ops.lstat = dlsym(RTLD_NEXT, "lstat"); 
     103    glibc_ops.lstat64 = dlsym(RTLD_NEXT, "lstat64"); 
     104    glibc_ops.dup = dlsym(RTLD_NEXT, "dup"); 
     105    glibc_ops.dup2 = dlsym(RTLD_NEXT, "dup2"); 
     106    glibc_ops.chown = dlsym(RTLD_NEXT, "chown"); 
     107    glibc_ops.fchown = dlsym(RTLD_NEXT, "fchown"); 
     108    glibc_ops.fchownat = dlsym(RTLD_NEXT, "fchownat"); 
     109    glibc_ops.lchown = dlsym(RTLD_NEXT, "lchown"); 
     110    glibc_ops.chmod = dlsym(RTLD_NEXT, "chmod"); 
     111    glibc_ops.fchmod = dlsym(RTLD_NEXT, "fchmod"); 
     112    glibc_ops.fchmodat = dlsym(RTLD_NEXT, "fchmodat"); 
     113    glibc_ops.lchmod = dlsym(RTLD_NEXT, "lchmod"); 
     114    glibc_ops.mkdir = dlsym(RTLD_NEXT, "mkdir"); 
     115    glibc_ops.mkdirat = dlsym(RTLD_NEXT, "mkdirat"); 
     116    glibc_ops.rmdir = dlsym(RTLD_NEXT, "rmdir"); 
     117    glibc_ops.readlink = dlsym(RTLD_NEXT, "readlink"); 
     118    glibc_ops.readlinkat = dlsym(RTLD_NEXT, "readlinkat"); 
     119    glibc_ops.symlink = dlsym(RTLD_NEXT, "symlink"); 
     120    glibc_ops.symlinkat = dlsym(RTLD_NEXT, "symlinkat"); 
     121    glibc_ops.link = dlsym(RTLD_NEXT, "link"); 
     122    glibc_ops.linkat = dlsym(RTLD_NEXT, "linkat"); 
     123    glibc_ops.readdir = dlsym(RTLD_NEXT, "readdir"); 
     124    glibc_ops.getdents = dlsym(RTLD_NEXT, "getdents"); 
     125    glibc_ops.access = dlsym(RTLD_NEXT, "access"); 
     126    glibc_ops.faccessat = dlsym(RTLD_NEXT, "faccessat"); 
     127    glibc_ops.flock = dlsym(RTLD_NEXT, "flock"); 
     128    glibc_ops.fcntl = dlsym(RTLD_NEXT, "fcntl"); 
     129    glibc_ops.sync = dlsym(RTLD_NEXT, "sync"); 
     130    glibc_ops.fsync = dlsym(RTLD_NEXT, "fsync"); 
     131    glibc_ops.fdatasync = dlsym(RTLD_NEXT, "fdatasync"); 
     132    glibc_ops.umask = dlsym(RTLD_NEXT, "umask"); 
     133    glibc_ops.getumask = dlsym(RTLD_NEXT, "getumask"); 
     134    glibc_ops.getdtablesize = dlsym(RTLD_NEXT, "getdtablesize"); 
     135} 
    67136 
    68137/*  
     
    70139 */  
    71140 
    72 int pvfs_sys_init() {  
     141void pvfs_sys_init(void) {  
    73142        struct rlimit rl;  
    74143        int rc;  
    75  
    76         /* initalize the file system */  
    77         PVFS_util_init_defaults();  
     144    static int pvfs_lib_init_flag = 0;  
     145 
     146    if (pvfs_lib_init_flag) 
     147    { 
     148        return; 
     149    } 
     150    pvfs_lib_init_flag = 1; /* should only run this once */ 
     151 
     152    /* this allows system calls to run */ 
     153    load_glibc(); 
    78154 
    79155        rc = getrlimit(RLIMIT_NOFILE, &rl);  
    80156        /* need to check for "INFINITY" */ 
    81157 
     158    /* set up descriptor table */ 
    82159        descriptor_table_size = rl.rlim_max; 
    83160        descriptor_table = 
     
    89166    descriptor_table[1] = &pvfs_stdout; 
    90167    descriptor_table[2] = &pvfs_stderr; 
     168    descriptor_table_count = PREALLOC; 
    91169        next_descriptor = PREALLOC; 
    92170 
    93         /* Mark the initialization complete */  
    94         pvfs_is_sys_initialized = 1;  
    95         return PVFS_FD_SUCCESS;  
     171        /* initalize PVFS */  
     172        PVFS_util_init_defaults();  
     173 
     174    /* call other initialization routines */ 
     175    PINT_initrand(); 
    96176} 
    97177 
     
    100180    return descriptor_table_size; 
    101181} 
    102  
    103182 
    104183/* 
     
    109188 { 
    110189        int i;  
     190    if (fsops == NULL) 
     191    { 
     192        errno = EINVAL; 
     193        return NULL; 
     194    } 
     195    pvfs_sys_init(); 
     196 
     197    /* table should be initialized now - check for available slot */ 
    111198        if (descriptor_table_count == (descriptor_table_size - PREALLOC)) 
    112199        { 
     200        errno = ENOMEM; 
    113201                return NULL; 
    114202        } 
     
    116204   /* find next empty slot in table */ 
    117205        for (i = next_descriptor; descriptor_table[i]; 
    118                         i = (i == descriptor_table_size - 1) ? PREALLOC : i++); 
     206                        i = (i == descriptor_table_size - 1) ? PREALLOC : i + 1); 
    119207 
    120208   /* found a slot */ 
     
    124212                return NULL; 
    125213        } 
    126         next_descriptor = ((i == descriptor_table_size - 1) ? PREALLOC : i++); 
     214        next_descriptor = ((i == descriptor_table_size - 1) ? PREALLOC : i + 1); 
    127215        descriptor_table_count++; 
    128216 
     
    140228        descriptor_table[i]->is_in_use = PVFS_FS; 
    141229 
    142    return descriptor_table[i]; 
     230    return descriptor_table[i]; 
    143231} 
    144232 
     
    148236int pvfs_dup_descriptor(int oldfd, int newfd) 
    149237{ 
     238    if (oldfd < 0 || oldfd >= descriptor_table_size) 
     239    { 
     240        errno = EBADF; 
     241        return -1; 
     242    } 
    150243    if (newfd == -1) 
    151244    { 
     
    174267pvfs_descriptor *pvfs_find_descriptor(int fd) 
    175268{ 
     269    if (fd < 0 || fd >= descriptor_table_size) 
     270    { 
     271        errno = EBADF; 
     272        return NULL; 
     273    } 
    176274        return descriptor_table[fd]; 
    177275} 
     
    181279    pvfs_descriptor *pd; 
    182280 
     281    if (fd < 0 || fd >= descriptor_table_size) 
     282    { 
     283        errno = EBADF; 
     284        return -1; 
     285    } 
    183286    pd = descriptor_table[fd]; 
    184287 
     
    187290 
    188291        /* keep up with used descriptors */ 
    189         descriptor_table_count++; 
     292        descriptor_table_count--; 
    190293 
    191294    /* check if last copy */ 
     
    251354} 
    252355 
    253 /*  
    254  *Determines if a path is part of a PVFS Filesystem  
     356/** 
     357 * Determines if a path is part of a PVFS Filesystem  
     358 * 
     359 * returns 1 if PVFS 0 otherwise 
    255360 */ 
    256361 
     
    261366    char *str; 
    262367 
     368    pvfs_sys_init(); 
     369    memset(&file_system, 0, sizeof(file_system)); 
     370    /* add current working dir to front of relative path */ 
     371    /* and copy to temp string working area */ 
    263372    if(path[0] != '/') 
    264373    { 
     
    282391    } 
    283392 
     393    /* lop off the last segment of the path */ 
    284394    int count; 
    285395    for(count = strlen(str) -2; count > 0; count--) 
     
    296406    if(file_system.f_type == PVFS_FS) 
    297407    { 
    298 #ifdef DEBUG 
    299        printf("IS PVFS_PATH\n"); 
    300 #endif 
    301        return true; 
    302     } 
    303     else if(file_system.f_type == LINUX_FS) 
    304     { 
    305 #ifdef DEBUG 
    306         printf("IS NOT PVFS_PATH\n"); 
    307 #endif 
    308         return false; 
     408        return 1; 
    309409    } 
    310410    else 
    311411    { 
    312         printf("NO A LINUX OR PVFS FILE SYSTEM!! (BAILING OUT!!!)\n"); 
    313         exit(1); 
     412        /* not PVFS assume the kernel can handle it */ 
     413        return 0; 
    314414    } 
    315415} 
     
    328428 * If non-null is passed as the directory or filename, 
    329429 * the field will be allocated and filled with the correct value 
     430 * 
     431 * A slash at the end of the path is interpreted as no filename 
     432 * and is an error.  To parse the last dir in a path, remove this 
     433 * trailing slash.  No filename with no directory is OK. 
    330434 */ 
    331435int split_pathname( const char *path, 
     436                    int dirflag, 
    332437                    char **directory, 
    333438                    char **filename) 
    334439{ 
    335     int i; 
     440    int i, slashes = 0; 
    336441    int length = strlen("pvfs2"); 
    337442 
     
    347452    } 
    348453    /* Split path into a directory and filename */ 
    349     length = strlen(path); 
    350     for (i = length - 1; i >= 0; --i) 
     454    length = strnlen(path, PVFS_NAME_MAX); 
     455    if (length == PVFS_NAME_MAX) 
     456    { 
     457        errno = ENAMETOOLONG; 
     458        return -1; 
     459    } 
     460    i = length - 1; 
     461    if (dirflag) 
     462    { 
     463        /* skip any trailing slashes */ 
     464        for(; i >= 0 && path[i] == '/'; i--) 
     465        { 
     466            slashes++; 
     467        } 
     468    } 
     469    for (; i >= 0; i--) 
    351470    { 
    352471        if (path[i] == '/') 
     
    367486        /* found no '/' path is all filename */ 
    368487        *directory = NULL; 
    369         i++; 
    370     } 
     488    } 
     489    i++; 
    371490    /* copy the filename */ 
    372     *filename = malloc(length - i + 1); 
     491    fnlen = length - i - slashes 
     492    if (fnlen == 0) 
     493    { 
     494        filename = NULL; 
     495        if (!directory) 
     496        { 
     497            errno = EISDIR; 
     498        } 
     499        else 
     500        { 
     501            errno = ENOENT; 
     502        } 
     503        return = -1; 
     504    } 
     505    /* check flag to see if there are slashes to skip */ 
     506    *filename = malloc(fnlen + 1); 
    373507    if (!*filename) 
    374508    { 
     
    381515        return -1; 
    382516    } 
    383     strncpy(*filename, path + i + 1, length - i); 
     517    strncpy(*filename, path + i, length - i); 
    384518    (*filename)[length - i] = '\0'; 
    385519    return 0; 
     520} 
     521 
     522void PINT_initrand(void) 
     523{ 
     524    static int init_called = 0; 
     525    pid_t pid; 
     526    uid_t uid; 
     527    gid_t gid; 
     528    struct timeval time; 
     529    char *oldstate; 
     530    unsigned int seed; 
     531 
     532    if (init_called) 
     533    { 
     534        return; 
     535    } 
     536    init_called = 1; 
     537    pid = getpid(); 
     538    uid = getuid(); 
     539    gid = getgid(); 
     540    gettimeofday(&time, NULL); 
     541    seed = (((pid << 16) ^ uid) ^ (gid << 8)) ^ time.tv_usec; 
     542    oldstate = initstate(seed, rstate, 256); 
     543    setstate(oldstate); 
     544} 
     545 
     546long int PINT_random(void) 
     547{ 
     548    char *oldstate; 
     549    long int rndval; 
     550 
     551    PINT_initrand(); 
     552    oldstate = setstate(rstate); 
     553    rndval = random(); 
     554    setstate(oldstate); 
     555    return rndval; 
    386556} 
    387557 
  • branches/Orange-Branch/src/client/usrint/openfile-util.h

    r8890 r8899  
    1919int split_pathname( const char *path, char **directory, char **filename); 
    2020 
    21 int pvfs_sys_init();  
     21void pvfs_sys_init(void);  
    2222 
    2323char *pvfs_qualify_path(const char *path); 
     
    5252                            PVFS_object_ref parent_ref, 
    5353                            PVFS_object_ref *ref); 
     54 
     55void PINT_initrand(void); 
     56 
     57long int PINT_random(void); 
    5458#endif 
  • branches/Orange-Branch/src/client/usrint/posix-pvfs.c

    r8890 r8899  
    4343    pvfs_descriptor *pd; 
    4444 
     45    if (!path) 
     46    { 
     47        errno = EINVAL; 
     48        return -1; 
     49    } 
    4550    va_start(ap, flags); 
    4651    if (flags & O_CREAT) 
     
    7782    PVFS_hint hints; 
    7883 
     84    if (!path) 
     85    { 
     86        errno = EINVAL; 
     87        return -1; 
     88    } 
    7989    va_start(ap, flags); 
    8090    if (flags & O_CREAT) 
     
    109119    pvfs_descriptor *dpd, *fpd; 
    110120 
     121    if (!path) 
     122    { 
     123        errno - EINVAL; 
     124        return -1; 
     125    } 
    111126    va_start(ap, flags); 
    112127    if (flags & O_CREAT) 
     
    133148    else 
    134149    { 
     150        if (dirfd < 0) 
     151        { 
     152            errno = EBADF; 
     153            return -1; 
     154        } 
    135155        dpd = pvfs_find_descriptor(dirfd); 
    136156        if (!dpd) 
     
    139159        } 
    140160        fpd = iocommon_open(path, flags, hints, mode, &dpd->pvfs_ref); 
     161        if (!fpd) 
     162        { 
     163            return -1; 
     164        } 
    141165        return fpd->fd; 
    142166    } 
     
    153177    pvfs_descriptor *pd; 
    154178 
     179    if (dirfd < 0) 
     180    { 
     181        errno = EBADF; 
     182        return -1; 
     183    } 
    155184    va_start(ap, flags); 
    156185    if (flags & O_CREAT) 
     
    214243    { 
    215244        int flags = O_RDONLY; 
     245        if (dirfd < 0) 
     246        { 
     247            errno = EBADF; 
     248            return -1; 
     249        }        
    216250        pd = pvfs_find_descriptor(dirfd); 
    217251        rc = iocommon_unlink(path, &pd->pvfs_ref); 
     
    252286    char *absoldpath, *absnewpath; 
    253287 
     288    if (!oldpath || !newpath) 
     289    { 
     290        errno = EINVAL; 
     291        return -1; 
     292    } 
    254293    if (oldpath[0] != '/') 
    255294    { 
     295        if (olddirfd < 0) 
     296        { 
     297            errno = EBADF; 
     298            return -1; 
     299        } 
    256300        olddes = pvfs_find_descriptor(olddirfd); 
    257301        absoldpath = (char *)oldpath; 
     
    264308    if (oldpath[0] != '/') 
    265309    { 
     310        if (newdirfd < 0) 
     311        { 
     312            errno = EBADF; 
     313            return -1; 
     314        } 
    266315        newdes = pvfs_find_descriptor(newdirfd); 
    267316        absnewpath = (char *)newpath; 
     
    292341    int rc; 
    293342 
     343    if (fd < 0) 
     344    { 
     345        errno = EBADF; 
     346        return -1; 
     347    } 
    294348    pvfs_descriptor *pd = pvfs_find_descriptor(fd); 
    295349    if (!pd) 
     
    336390{ 
    337391    int rc; 
     392 
     393    if (fd < 0) 
     394    { 
     395        errno = EBADF; 
     396        return -1; 
     397    } 
    338398    pvfs_descriptor *pd = pvfs_find_descriptor(fd); 
    339399    if (!pd) 
     
    460520    pvfs_descriptor* pd; 
    461521 
     522    if (fd < 0) 
     523    { 
     524        errno = EBADF; 
     525        return -1; 
     526    } 
    462527    /* Find the descriptor */ 
    463528    pd = pvfs_find_descriptor(fd); 
     
    489554    pvfs_descriptor *pd; 
    490555 
     556    if (!path) 
     557    { 
     558        errno = EINVAL; 
     559        return -1; 
     560    } 
    491561    pd = iocommon_open(path, O_WRONLY, PVFS_HINT_NULL, 0 , NULL); 
    492562    if (!pd) 
     
    514584    pvfs_descriptor *pd; 
    515585     
     586    if (fd < 0) 
     587    { 
     588        errno = EBADF; 
     589        return -1; 
     590    } 
    516591    pd = pvfs_find_descriptor(fd); 
    517592    if (!pd) 
     
    533608    pvfs_descriptor* pd; 
    534609 
     610    if (fd < 0) 
     611    { 
     612        errno = EBADF; 
     613        return -1; 
     614    } 
    535615    pd = pvfs_find_descriptor(fd); 
    536616    if (!pd) 
     
    560640#endif 
    561641 
     642    if (fd < 0) 
     643    { 
     644        errno = EBADF; 
     645        return -1; 
     646    } 
    562647    /* Find the descriptor */ 
    563648    pd = pvfs_find_descriptor(fd); 
     
    620705    pvfs_descriptor *pd; 
    621706 
     707    if (fd < 0) 
     708    { 
     709        errno = EBADF; 
     710        return -1; 
     711    } 
    622712    pd = pvfs_find_descriptor(fd); 
    623713    return iocommon_stat(pd, buf); 
     
    631721    pvfs_descriptor *pd; 
    632722 
     723    if (fd < 0) 
     724    { 
     725        errno = EBADF; 
     726        return -1; 
     727    } 
    633728    pd = pvfs_find_descriptor(fd); 
    634729    return iocommon_stat64(pd, buf); 
     
    660755        { 
    661756            flags |= O_NOFOLLOW; 
     757        } 
     758        if (fd < 0) 
     759        { 
     760            errno = EBADF; 
     761            return -1; 
    662762        } 
    663763        pd = pvfs_find_descriptor(fd); 
     
    698798        { 
    699799            flags |= O_NOFOLLOW; 
     800        } 
     801        if (fd < 0) 
     802        { 
     803            errno = EBADF; 
     804            return -1; 
    700805        } 
    701806        pd = pvfs_find_descriptor(fd); 
     
    790895    pvfs_descriptor *pd; 
    791896 
     897    if (fd < 0) 
     898    { 
     899        errno = EBADF; 
     900        return -1; 
     901    } 
    792902    pd = pvfs_find_descriptor(fd); 
    793903    return iocommon_chown(pd, owner, group); 
     
    819929        { 
    820930            flags |= O_NOFOLLOW; 
     931        } 
     932        if (fd < 0) 
     933        { 
     934            errno = EBADF; 
     935            return -1; 
    821936        } 
    822937        pd = pvfs_find_descriptor(fd); 
     
    879994    pvfs_descriptor *pd; 
    880995 
     996    if (fd < 0) 
     997    { 
     998        errno = EBADF; 
     999        return -1; 
     1000    } 
    8811001    pd = pvfs_find_descriptor(fd); 
    8821002    return iocommon_chmod(pd, mode); 
     
    9081028        { 
    9091029            flags |= O_NOFOLLOW; 
     1030        } 
     1031        if (fd < 0) 
     1032        { 
     1033            errno = EBADF; 
     1034            return -1; 
    9101035        } 
    9111036        pd = pvfs_find_descriptor(fd); 
     
    9741099    else 
    9751100    { 
     1101        if (dirfd < 0) 
     1102        { 
     1103            errno = EBADF; 
     1104            return -1; 
     1105        } 
    9761106        pd = pvfs_find_descriptor(dirfd); 
    9771107        rc = iocommon_make_directory(path, 
     
    10331163    { 
    10341164        int flags = O_RDONLY | O_NOFOLLOW; 
     1165        if (fd < 0) 
     1166        { 
     1167            errno = EBADF; 
     1168            return -1; 
     1169        } 
    10351170        pd = pvfs_find_descriptor(fd); 
    10361171        if (!pd) 
     
    10571192{ 
    10581193    pvfs_descriptor *pd; 
     1194    if (newdirfd < 0) 
     1195    { 
     1196        errno = EBADF; 
     1197        return -1; 
     1198    } 
    10591199    pd = pvfs_find_descriptor(newdirfd); 
    10601200    return iocommon_symlink(newpath, oldpath, &pd->pvfs_ref); 
     
    10901230{ 
    10911231    pvfs_descriptor *pd; 
     1232 
     1233    if (fd < 0) 
     1234    { 
     1235        errno = EBADF; 
     1236        return -1; 
     1237    } 
    10921238    pd = pvfs_find_descriptor(fd); 
    10931239    return iocommon_getdents(pd, dirp, count); 
     
    11021248{ 
    11031249    pvfs_descriptor *pd; 
     1250 
     1251    if (fd < 0) 
     1252    { 
     1253        errno = EBADF; 
     1254        return -1; 
     1255    } 
    11041256    pd = pvfs_find_descriptor(fd); 
    11051257    return iocommon_access(path, mode, flags, &pd->pvfs_ref); 
  • branches/Orange-Branch/src/client/usrint/posix.c

    r8890 r8899  
    1515#include <posix-pvfs.h> 
    1616#include <openfile-util.h> 
    17  
    18 static int pvfs_lib_init = 0;  
    19  
    20 posix_ops glibc_ops = 
    21 { 
    22     .statfs = statfs 
    23 }; 
    24  
    25 void load_glibc(void) 
    26 {  
    27     pvfs_lib_init = 1;  
    28     glibc_ops.open = dlsym(RTLD_NEXT, "open"); 
    29     glibc_ops.open64 = dlsym(RTLD_NEXT, "open64"); 
    30     glibc_ops.unlink = dlsym(RTLD_NEXT, "unlink"); 
    31     glibc_ops.close = dlsym(RTLD_NEXT, "close"); 
    32     glibc_ops.read = dlsym(RTLD_NEXT, "read"); 
    33     glibc_ops.write = dlsym(RTLD_NEXT, "write"); 
    34     glibc_ops.lseek = dlsym(RTLD_NEXT, "lseek"); 
    35     glibc_ops.lseek64 = dlsym(RTLD_NEXT, "lseek64"); 
    36     glibc_ops.pread = dlsym(RTLD_NEXT, "pread");  
    37     glibc_ops.pwrite = dlsym(RTLD_NEXT, "pwrite");  
    38     glibc_ops.readv = dlsym(RTLD_NEXT, "readv");  
    39     glibc_ops.writev = dlsym(RTLD_NEXT, "writev");  
    40 } 
    4117 
    4218/* 
     
    5430    pvfs_descriptor *pd; 
    5531     
    56     if(!pvfs_lib_init) {  
    57         load_glibc();  
    58     } 
    59  
    6032    va_start(ap, flags);  
    6133    if (flags & O_CREAT) 
     
    6941    va_end(ap);  
    7042 
    71     if(is_pvfs_path(path)) {  
    72 #ifdef DEBUG 
    73         printf("PVFS_OPEN\n");  
    74 #endif 
     43    if (is_pvfs_path(path)) 
     44    {  
    7545        return pvfs_open(path, flags, mode, hints); 
    7646    } 
    77     else { 
    78 #ifdef DEBUG 
    79         printf("GLIBC_OPEN\n");  
    80 #endif 
     47    else 
     48    { 
    8149        pd = pvfs_alloc_descriptor(&glibc_ops); 
    8250        pd->posix_fd = pd->fsops->open(path, flags, mode); 
     
    9664    PVFS_hint hints;  /* need to figure out how to set default */ 
    9765     
    98     if(!pvfs_lib_init) {  
    99         load_glibc();  
    100     } 
    101  
    10266    va_start(ap, flags);  
    10367    if (flags & O_HINTS) 
     
    12387int creat(const char *path, mode_t mode) 
    12488{  
    125     if(!pvfs_lib_init) {  
    126         load_glibc();  
    127     } 
    128  
    12989    return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode);  
    13090} 
     
    13595int creat64(const char *path, mode_t mode) 
    13696{  
    137     if(!pvfs_lib_init) {  
    138         load_glibc();  
    139     } 
    140  
    14197    return open64(path, O_CREAT|O_WRONLY|O_TRUNC, mode);  
    14298} 
     
    147103int unlink(const char *path) 
    148104{ 
    149     if (!pvfs_lib_init) { 
    150         load_glibc(); 
    151     } 
    152105    if (is_pvfs_path(path)) { 
    153 #ifdef DEBUG 
    154         pvfs_debug("unlink: calling pvfs_unlink\n"); 
    155 #endif 
    156106        return pvfs_ops.unlink(path); 
    157107    } 
    158108    else { 
    159 #ifdef DEBUG 
    160         pvfs_debug("unlink: calling glibc_ops.unlink\n"); 
    161 #endif 
    162109        return glibc_ops.unlink(path); 
    163110    } 
     
    517464{ 
    518465    return lstat64(path, buf); 
     466} 
     467 
     468int getdents(unsigned int fd, struct dirent *dirp, unsigned int count) 
     469{ 
     470    return -1; 
    519471} 
    520472 
  • branches/Orange-Branch/src/client/usrint/stdio.c

    r8890 r8899  
    3838#define DIRBUFSIZE (512*1024) 
    3939#define ASIZE 256 
     40#define MAXTRIES 16 /* arbitrary - how many tries to get a unique file name */ 
    4041 
    4142/** This function coverts from stream style mode to ssycall style flags 
     
    11001101 * mkdtemp makes a temp dir and returns an fd  
    11011102 */ 
    1102 char * mkdtemp(char *template) 
    1103 { 
    1104     char *rc = NULL; 
     1103char *mkdtemp(char *template) 
     1104{ 
    11051105    int fd; 
     1106    int len; 
     1107    int rnum; 
     1108    int try; 
     1109 
    11061110    if (!template) 
    11071111    { 
     
    11091113        return NULL; 
    11101114    } 
    1111     rc = mktemp(template); 
    1112     if (rc == NULL) 
    1113     { 
     1115    len = strlen(template); 
     1116    if (!strncmp(&template[len-6],"XXXXXX",6)) 
     1117    { 
     1118        errno = EINVAL; 
    11141119        return NULL; 
    11151120    } 
    1116     fd = mkdir(template, 0600); 
    1117     if (fd < 0) 
    1118     { 
    1119         return NULL; 
     1121    for(try = 0; try < MAXTRIES; try++) 
     1122    { 
     1123        rnum = PINT_random() % 1000000; 
     1124        sprintf(&template[len-6],"%06d", rnum); 
     1125        fd = mkdir(template, 0700); 
     1126        if (fd < 0) 
     1127        { 
     1128            if (errno == EEXIST) 
     1129            { 
     1130                continue; 
     1131            } 
     1132            return NULL; 
     1133        } 
    11201134    } 
    11211135    return template; 
     
    11271141int mkstemp(char *template) 
    11281142{ 
    1129     char *ret; 
    11301143    int fd; 
     1144    int len; 
     1145    int rnum; 
     1146    int try; 
     1147 
    11311148    if (!template) 
    11321149    { 
     
    11341151        return -1; 
    11351152    } 
    1136     ret = mktemp(template); 
    1137     if (ret == NULL) 
    1138     { 
    1139         return -1; 
    1140     } 
    1141     fd = open(template, O_RDWR|O_EXCL|O_CREAT, 0600); 
     1153    len = strlen(template); 
     1154    if (!strncmp(&template[len-6],"XXXXXX",6)) 
     1155    { 
     1156        errno = EINVAL; 
     1157        return -1; 
     1158    } 
     1159    for(try = 0; try < MAXTRIES; try++) 
     1160    { 
     1161        rnum = PINT_random() % 1000000; 
     1162        sprintf(&template[len-6],"%06d", rnum); 
     1163        fd = open(template, O_RDWR|O_EXCL|O_CREAT, 0600); 
     1164        if (fd < 0) 
     1165        { 
     1166            if (errno == EEXIST) 
     1167            { 
     1168                continue; 
     1169            } 
     1170            return -1; 
     1171        } 
     1172    } 
    11421173    return fd; 
    11431174} 
     
    12611292        int bytes_read; 
    12621293        /* read a block of dirents into the buffer */ 
    1263         bytes_read = getdents64(dir->fileno, dir->buf_base, 
    1264                                (dir->buf_end - dir->buf_base)); 
     1294        bytes_read = getdents(dir->fileno, dir->buf_base, 
     1295                             (dir->buf_end - dir->buf_base)); 
    12651296        dir->buf_act = dir->buf_base + bytes_read; 
    12661297        dir->buf_ptr = dir->buf_base; 
  • branches/Orange-Branch/src/client/usrint/usrint.h

    r8890 r8899  
    5959#define O_NOFOLLOW 0 
    6060#endif 
    61 #define max(x, y) (((x) > (y)) ? (x) : (y)) 
    6261#define true   1  
    6362#define false  0  
  • branches/Orange-Branch/src/common/misc/pint-perf-counter.c

    r8892 r8899  
    5252    {"request scheduler", PINT_PERF_REQSCHED, PINT_PERF_PRESERVE}, 
    5353    {"requests received ", PINT_PERF_REQUESTS, PINT_PERF_PRESERVE}, 
     54    {"bytes read by small_io", PINT_PERF_SMALL_READ, PINT_PERF_PRESERVE}, 
     55    {"bytes written by small_io", PINT_PERF_SMALL_WRITE, PINT_PERF_PRESERVE}, 
     56    {"bytes read by flow", PINT_PERF_FLOW_READ, PINT_PERF_PRESERVE}, 
     57    {"bytes written by flow", PINT_PERF_FLOW_WRITE, PINT_PERF_PRESERVE}, 
    5458    {NULL, 0, 0}, 
    5559}; 
     
    228232                        enum PINT_perf_ops op) 
    229233{ 
     234#if 0 
    230235    int64_t tmp; /* this is for debugging purposes */ 
     236#endif 
    231237 
    232238    if(!pc || !pc->sample || !pc->sample->value) 
     
    238244    gen_mutex_lock(&pc->mutex); 
    239245 
     246#if 0 
    240247    tmp = pc->sample->value[key]; 
     248#endif 
    241249 
    242250    if(key >= pc->key_count) 
    243251    { 
    244252        gossip_err("Error: PINT_perf_count(): invalid key.\n"); 
    245         return; 
     253        goto errorout; 
    246254    } 
    247255 
     
    265273#endif 
    266274 
     275errorout: 
    267276    gen_mutex_unlock(&pc->mutex); 
    268277    return; 
  • branches/Orange-Branch/src/io/flow/flowproto-bmi-trove/flowproto-multiqueue.c

    r8317 r8899  
    10671067                    actual_size,  
    10681068                    PINT_PERF_ADD); 
     1069    PINT_perf_count(PINT_server_pc, 
     1070                    PINT_PERF_FLOW_READ,  
     1071                    actual_size,  
     1072                    PINT_PERF_ADD); 
    10691073 
    10701074    flow_data->parent->total_transferred += actual_size; 
     
    13521356    do{ 
    13531357        q_item->parent->total_transferred += result_tmp->result.bytes; 
    1354         PINT_perf_count( 
    1355             PINT_server_pc, 
    1356             PINT_PERF_WRITE,  
    1357             result_tmp->result.bytes, 
    1358             PINT_PERF_ADD); 
     1358        PINT_perf_count( PINT_server_pc, 
     1359                         PINT_PERF_WRITE,  
     1360                         result_tmp->result.bytes, 
     1361                         PINT_PERF_ADD); 
     1362        PINT_perf_count( PINT_server_pc, 
     1363                         PINT_PERF_FLOW_WRITE,  
     1364                         result_tmp->result.bytes, 
     1365                         PINT_PERF_ADD); 
    13591366        old_result_tmp = result_tmp; 
    13601367        result_tmp = result_tmp->next; 
  • branches/Orange-Branch/src/io/trove/trove-mgmt.c

    r7959 r8899  
    8989                     TROVE_method_callback method_callback, 
    9090                     char *data_path, 
    91                                 char *meta_path, 
     91                    char *meta_path, 
    9292                     TROVE_ds_flags flags) 
    9393{ 
  • branches/Orange-Branch/src/server/small-io.sm

    r8891 r8899  
    1818#include "pint-distribution.h" 
    1919#include "pint-request.h" 
     20#include "pint-perf-counter.h" 
    2021 
    2122%% 
     
    232233        } 
    233234    } 
     235    if(s_op->req->u.small_io.io_type == PVFS_IO_READ) 
     236    { 
     237        PINT_perf_count(PINT_server_pc, 
     238                        PINT_PERF_READ, 
     239                        s_op->resp.u.small_io.result_size, 
     240                        PINT_PERF_ADD); 
     241        PINT_perf_count(PINT_server_pc, 
     242                        PINT_PERF_SMALL_READ, 
     243                        s_op->resp.u.small_io.result_size, 
     244                        PINT_PERF_ADD); 
     245    } 
     246    else 
     247    { 
     248        PINT_perf_count(PINT_server_pc, 
     249                        PINT_PERF_WRITE, 
     250                        s_op->resp.u.small_io.result_size, 
     251                        PINT_PERF_ADD); 
     252        PINT_perf_count(PINT_server_pc, 
     253                        PINT_PERF_SMALL_WRITE, 
     254                        s_op->resp.u.small_io.result_size, 
     255                        PINT_PERF_ADD); 
     256    } 
    234257 
    235258    return SM_ACTION_COMPLETE;