Skip to content

Commit 01b2939

Browse files
committed
handle symlink
1 parent 24c4a6f commit 01b2939

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

ImageStreamIO.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ ImageStreamIO_check_image_inode(IMAGE* image)
868868

869869
// - Return success or failure if inode matches or not, respectively
870870
return image->md->inode == file_stat.st_ino ? IMAGESTREAMIO_SUCCESS
871-
: IMAGESTREAMIO_INODE;
871+
: IMAGESTREAMIO_INODE;
872872
}
873873

874874

@@ -917,7 +917,7 @@ errno_t ImageStreamIO_image_sizing(IMAGE *image, uint8_t* map)
917917
"invalid size of third axis");
918918
return IMAGESTREAMIO_INVALIDARG;
919919
}
920-
// N.B. no break, fall through to previous axis
920+
// N.B. no break, fall through to previous axis
921921
case 2:
922922
if (image->md->size[1] < 1)
923923
{
@@ -926,7 +926,7 @@ errno_t ImageStreamIO_image_sizing(IMAGE *image, uint8_t* map)
926926
"invalid size of second axis");
927927
return IMAGESTREAMIO_INVALIDARG;
928928
}
929-
// N.B. no break, fall through to previous axis
929+
// N.B. no break, fall through to previous axis
930930
case 1:
931931
if (image->md->size[0] < 1)
932932
{
@@ -1266,13 +1266,15 @@ errno_t ImageStreamIO_createIm_gpu(
12661266

12671267
image->md = (IMAGE_METADATA*) map;
12681268
errno_t ierrno = ImageStreamIO_image_sizing_from_scratch(
1269-
image, name, naxis, size, datatype
1270-
, location, shared, NBsem, NBkw
1271-
, imagetype, CBsize, map
1269+
image, name, naxis, size, datatype
1270+
, location, shared, NBsem, NBkw
1271+
, imagetype, CBsize, map
12721272
);
12731273
if (ierrno != IMAGESTREAMIO_SUCCESS)
12741274
{
1275-
if (shared != 1) { free(map); }
1275+
if (shared != 1) {
1276+
free(map);
1277+
}
12761278
return ierrno;
12771279
}
12781280

@@ -1361,16 +1363,20 @@ errno_t ImageStreamIO_createIm_gpu(
13611363
////////////////////////////////////////////////////////////////
13621364
image->md = (IMAGE_METADATA *)map;
13631365
ierrno = ImageStreamIO_image_sizing_from_scratch(
1364-
image, name, naxis, size, datatype
1365-
, location, shared, NBsem, NBkw
1366-
, imagetype, CBsize, map
1366+
image, name, naxis, size, datatype
1367+
, location, shared, NBsem, NBkw
1368+
, imagetype, CBsize, map
13671369
);
1368-
if (ierrno != IMAGESTREAMIO_SUCCESS) { return ierrno; }
1370+
if (ierrno != IMAGESTREAMIO_SUCCESS) {
1371+
return ierrno;
1372+
}
13691373

13701374
// - Store the inode of the shmim flle into image->md->inode
13711375
// - On error, shmim will have been closed; return
13721376
ierrno = ImageStreamIO_store_image_inode(image);
1373-
if (ierrno != IMAGESTREAMIO_SUCCESS) { return ierrno; }
1377+
if (ierrno != IMAGESTREAMIO_SUCCESS) {
1378+
return ierrno;
1379+
}
13741380

13751381
image->md->creatorPID = getpid();
13761382
image->md->ownerPID = 0; // default value, indicates unset
@@ -1683,6 +1689,11 @@ errno_t ImageStreamIO_read_sharedmem_image_toIMAGE(
16831689
return IMAGESTREAMIO_FILEOPEN;
16841690
}
16851691

1692+
// copy name to image name
1693+
// if symlink, image->name is the link name and image->md->name is the target
1694+
strncpy(image->name, name, STRINGMAXLEN_IMAGE_NAME - 1);
1695+
image->name[STRINGMAXLEN_IMAGE_NAME-1] = '\0';
1696+
16861697
// Check the shmim version
16871698
if (strcmp(image->md->version, IMAGESTRUCT_VERSION))
16881699
{
@@ -1815,7 +1826,7 @@ long ImageStreamIO_sempost(
18151826

18161827
if (index > image->md->sem - 1)
18171828
printf("ERROR: image %s semaphore # %ld does not exist\n"
1818-
, image->md->name, index);
1829+
, image->md->name, index);
18191830
else
18201831
{
18211832
int semval;

0 commit comments

Comments
 (0)