Changeset 9147

Show
Ignore:
Timestamp:
12/07/11 16:05:27 (18 months ago)
Author:
k
Message:

mtab/fstab file handling:

- Fix segfault that could be triggered by commenting out lines in tab files
- Allow tab and space as tabfile delimiters (previously only allowed space)
- Support the case in which a fuse mount exists but does not have a static tab entry.

Location:
trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/apps/fuse/pvfs2fuse.c

    r8684 r9147  
    12181218                 config = pvfs2fuse.mntent.pvfs_config_servers[0]; 
    12191219 
    1220           snprintf( name, 200, "-ofsname=pvfs2fuse#%s", config ); 
     1220          snprintf( name, 200, "-ofsname=pvfs2fuse#%s/%s", config, pvfs2fuse.mntent.pvfs_fs_name ); 
    12211221          fuse_opt_insert_arg( &args, 1, name ); 
    12221222#if (__FreeBSD__ >= 10) 
  • trunk/src/common/misc/pvfs2-util.c

    r9143 r9147  
    157157    free(mntent->pvfs_config_servers); 
    158158    free(mntent->pvfs_fs_name); 
     159    mntent->pvfs_fs_name = NULL; 
    159160    free(mntent); 
    160161    return; 
     
    507508                       !(strncmp(PINT_FSTAB_NAME(tmp_ent), "#", 1))) 
    508509                    { 
    509                         /* this entry is a comment */ 
    510510                        PINT_fstab_entry_destroy(tmp_ent); 
    511511                        continue; 
     
    541541    /* allocate array of entries */ 
    542542    current_tab = &s_stat_tab_array[s_stat_tab_count]; 
     543 
    543544    current_tab->mntent_array = (struct PVFS_sys_mntent *)malloc( 
    544545        (tmp_mntent_count * sizeof(struct PVFS_sys_mntent))); 
     546 
    545547    if (!current_tab->mntent_array) 
    546548    { 
     
    563565    while ((tmp_ent = PINT_fstab_next_entry(mnt_fp))) 
    564566    { 
    565         if (strcmp(PINT_FSTAB_TYPE(tmp_ent), "pvfs2") == 0) 
     567       if(!(PINT_FSTAB_NAME(tmp_ent)) || !(strncmp(PINT_FSTAB_NAME(tmp_ent), "#", 1))) 
     568       { 
     569           PINT_fstab_entry_destroy(tmp_ent); 
     570           continue; 
     571        } 
     572 
     573        if ((PINT_FSTAB_TYPE(tmp_ent) != NULL) && (strncmp(PINT_FSTAB_TYPE(tmp_ent), "pvfs2", 5) == 0)) 
    566574        { 
    567575            struct PVFS_sys_mntent *me = &current_tab->mntent_array[i]; 
    568576            char *cp; 
    569577            int cur_server; 
    570  
     578            char *rewrite_pointer; 
     579 
     580            /* Entries in mtab may be prefixed by a process name and '#' */ 
     581            /* If detected, remove prefix.  */ 
     582            for(rewrite_pointer=cp=PINT_FSTAB_NAME(tmp_ent); *cp; cp++,rewrite_pointer++) { 
     583                if (*cp == '#') { 
     584                    rewrite_pointer = PINT_FSTAB_NAME(tmp_ent) - 1; 
     585                    continue; 
     586                } 
     587                if (rewrite_pointer == cp) continue; 
     588                *rewrite_pointer = *cp; 
     589            } 
     590            *rewrite_pointer = '\0'; 
     591                
    571592            /* Enable integrity checks by default */ 
    572593            me->integrity_check = 1; 
     
    601622            /* parse server list and make sure fsname is same */ 
    602623            cp = PINT_FSTAB_NAME(tmp_ent); 
     624 
    603625            cur_server = 0; 
    604626            for (;;) 
     
    20452067 
    20462068    /* get the path string */ 
    2047     nexttok = strtok_r(linestr, " ", &strtok_ctx); 
     2069    nexttok = strtok_r(linestr, " \t", &strtok_ctx); 
    20482070    if(!nexttok) 
    20492071    { 
     
    20552077    /* get the mount point */ 
    20562078 
    2057     nexttok = strtok_r(NULL, " ", &strtok_ctx); 
     2079    nexttok = strtok_r(NULL, " \t", &strtok_ctx); 
    20582080    if(!nexttok) 
    20592081    { 
     
    20632085 
    20642086    /* get the fs type */ 
    2065     nexttok = strtok_r(NULL, " ", &strtok_ctx); 
     2087    nexttok = strtok_r(NULL, " \t", &strtok_ctx); 
    20662088    if(!nexttok) 
    20672089    { 
     
    20712093 
    20722094    /* get the mount opts */ 
    2073     nexttok = strtok_r(NULL, " ", &strtok_ctx); 
     2095    nexttok = strtok_r(NULL, " \t", &strtok_ctx); 
    20742096    if(!nexttok) 
    20752097    {