0

I'm trying to put physical file on IFS.

So trying to open file just to guarantee its presence on source.

This is how I do it:

errno=0;                                                          
if ( ((pf = _Ropen(pfname, "rr, nullcap=Y")) == NULL) || (errno!=0) )
{
   printf("\nError:  Cannot open file %s\n",pfname);
   //...
}

However, the file not gets opened with pf = SPP:*NULL result

That won't be the issue, but I can't also view errno. The eval errno gives Syntax error occurred. without any clue what has happened.

I'm still able to view contents of pfname: it looks like 'MYLIB/MYFILE'

Absolute path was also tried: '/QSYS.LIB/MYLIB.LIB/MYFILE.FILE', without any difference - same error persists.

IBM IFS explorer clearly shows contents of MYLIB and there is a MYFILE inside this lib.

UPD

I've added some debug logging just to extcact error description or error code:

numbytes = sprintf( (char *)NULL, "%s", strerror(errno) );

ret = (char *)malloc( ( numbytes + 1 ) * sizeof( char ) );

sprintf( ret, "%s", strerror(errno) );     

And the result of ret is SPP:*NULL.

Any ideas to try?

im_infamous
  • 972
  • 1
  • 17
  • 29
  • Maybe in the printf() you can try `printf("\nError: Cannot open file %s with errno %d\n", pfname, errno);` – mao Feb 13 '18 at 14:12
  • Maybe read [this answer](https://stackoverflow.com/a/10388547/2296441) to figure out the debugging issues you are having. – jmarkmurphy Feb 14 '18 at 14:54

1 Answers1

1

It turned out to be super simple - null byte was missing so _Ropen can not really access the file thus no error to be passed as well.

To handle this the argument of null-terminated byte array needs to be passed from caller. In case of rpg solution looks like 'MYFILE/MYLIB' + X'00'

im_infamous
  • 972
  • 1
  • 17
  • 29