~ubuntu-branches/ubuntu/vivid/mpich/vivid-proposed

« back to all changes in this revision

Viewing changes to src/mpi/romio/adio/common/shfp_fname.c

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-04-01 20:24:20 UTC
  • mfrom: (5.2.4 sid)
  • Revision ID: package-import@ubuntu.com-20140401202420-t5ey1ia2klt5dkq3
Tags: 3.1-4
* [c3e3398] Disable test_primitives, which is unreliable on some platforms.
            (Closes: #743047)
* [265a699] Add minimal autotest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
#include "adio.h"
9
9
 
 
10
#ifdef HAVE_UNISTD_H
 
11
#include <unistd.h>
 
12
#endif
 
13
#ifdef HAVE_SYS_TYPES_H
 
14
#include <sys/types.h>
 
15
#endif
 
16
 
10
17
/* The following function selects the name of the file to be used to 
11
18
   store the shared file pointer. The shared-file-pointer file is a 
12
19
   hidden file in the same directory as the real file being accessed.
19
26
void ADIOI_Shfp_fname(ADIO_File fd, int rank)
20
27
{
21
28
    double tm;
22
 
    int i, len;
 
29
    int i;
 
30
    int len;
23
31
    char *slash, *ptr, tmp[128];
 
32
    int pid = 0;
24
33
 
25
34
    fd->shared_fp_fname = (char *) ADIOI_Malloc(256);
26
35
 
31
40
        tm = tm - (double) i;
32
41
        tm *= 1000000.0;
33
42
        i = (int) tm;
 
43
        pid = (int)getpid();
34
44
        
35
45
        ADIOI_Strncpy(fd->shared_fp_fname, fd->filename, 256);
36
46
        
51
61
            slash = strrchr(fd->shared_fp_fname, '/');
52
62
#endif
53
63
            ADIOI_Strncpy(slash + 1, ".", 2);
54
 
            len = 256 - (slash+2 - fd->shared_fp_fname);
 
64
            /* ok to cast: file names bounded by PATH_MAX and NAME_MAX */
 
65
            len = (int) (256 - (slash+2 - fd->shared_fp_fname));
55
66
            ADIOI_Strncpy(slash + 2, ptr + 1, len);
56
67
        }
57
68
            
58
 
        ADIOI_Snprintf(tmp, 128, ".shfp.%d", i);
 
69
        ADIOI_Snprintf(tmp, 128, ".shfp.%d.%d", pid, i);
59
70
        ADIOI_Strnapp(fd->shared_fp_fname, tmp, 256);
60
71
        
61
72
        len = (int)strlen(fd->shared_fp_fname);