stat() returning 3025 (ENOENT) error - and never anything else - IBM AS400

This is a discussion on stat() returning 3025 (ENOENT) error - and never anything else - IBM AS400 ; I can only only assume it's my source, but I am tearing my hair out trying to find where! here's my code: 0139.00 D* 0140.00 Dstat64 PR 10I 0 EXTPROC('stat64') 0141.00 D FS#PRM1 * 0142.00 D FS#PRM2 * 0143.00 D* ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: stat() returning 3025 (ENOENT) error - and never anything else

  1. stat() returning 3025 (ENOENT) error - and never anything else

    I can only only assume it's my source, but I am tearing my hair out
    trying to find where!

    here's my code:
    0139.00 D*
    0140.00 Dstat64 PR 10I 0 EXTPROC('stat64')
    0141.00 D FS#PRM1 *
    0142.00 D FS#PRM2 *
    0143.00 D*
    0144.00 DFS#STUFF DS
    0145.00 D FS#PATH 100A
    0146.00 D FS#BUF 512A
    0147.00 D FS#RTN 10I 0
    0148.00 D pFS#PATH * INZ(%ADDR(FS#PATH))
    0149.00 D pFS#BUF * INZ(%ADDR(FS#BUF))
    0150.00 D*
    0151.00 D*

    .. . . . . . . . . .

    C EVAL FS#PATH = %TRIMR(CL#DIR) + X'00'
    C EVAL pFS#PATH = %ADDR(FS#PATH)
    C EVAL pFS#BUF = %ADDR(FS#BUF)
    C EVAL FS#RTN = stat64(pFS#PATHFS#BUF)
    C FS#RTN CABEQ 0 FS$SIZE
    C EVAL pErrNbr = errno
    C MOVEL(P) 'STAT_ERROR' CL#STS
    C EVAL CL#MSG = 'Error ' + %CHAR(GE#ERR) +
    C ' on stat64() API'
    C EVAL CL#API = 'stat64()'
    C EXSR ERRNO$TEXT
    C GOTO FS$FINI

    I've tried stat() and stat64().

    I've tried setting the pointers with INZ keyword in D-spec and %ADDR
    function in C-spec (and apparently doing both in this code snippet!).

    From manual, I read that 3025 can be returned because my path string
    is empty, which I have to assume is most likely what is going on, BUT
    MY PATH STRING IS NOT EMPTY.

    Thanks in advance for any help you can provide. Meanwhile, I'll be
    trying to code my old buddy Qp0lGetAttr,
    Jack

    PS, By the way, I'm trying to get the size of an IFS file.


    ..

  2. Re: stat() returning 3025 (ENOENT) error - and never anything else

    jliesner@gmail.com wrote:
    >
    > <>
    >
    > From manual, I read that 3025 can be returned because my path string
    > is empty, which I have to assume is most likely what is going on, BUT
    > MY PATH STRING IS NOT EMPTY.
    >
    > Thanks in advance for any help you can provide. Meanwhile, I'll be
    > trying to code my old buddy Qp0lGetAttr, Jack
    >
    > PS, By the way, I'm trying to get the size of an IFS file.


    As I recall errno 3025 [token ENOENT] identifies that the specified
    path or directory does not exist. I believe that if the input for the
    stat() request does not give a full path, then it will use the given
    path name as a /relative path/ which is effectively just appended to the
    /current path/ name of the requester. This may be the issue.?

    FWiW: Prototype, structures, and a code example with "root +":
    http://archive.midrange.com/rpg400-l.../msg00689.html
    http://archive.midrange.com/rpg400-l.../msg00241.html
    http://www.opensource400.org/callc.html /* per above link */
    http://archive.midrange.com/rpg400-l.../msg00448.html

    Regards, Chuck

  3. Re: stat() returning 3025 (ENOENT) error - and never anything else

    Jack,

    C requires parameters passed by value. Since your prototype uses "pass by reference", the stat()
    function does not get the path you think it gets.

    Please add the "value" keywords like as shown below and hopefully it will work:

    *
    * 0/-1 = stat()--Get File Information include
    D stat...
    D PR 10I 0 extproc('stat') = int
    D i_pPath * value options(*string) = *path
    D i_pStat * value = *buf

    Thomas.


    jliesner@gmail.com schrieb:
    > I can only only assume it's my source, but I am tearing my hair out
    > trying to find where!
    >
    > here's my code:
    > 0139.00 D*
    > 0140.00 Dstat64 PR 10I 0 EXTPROC('stat64')
    > 0141.00 D FS#PRM1 *
    > 0142.00 D FS#PRM2 *
    > 0143.00 D*
    > 0144.00 DFS#STUFF DS
    > 0145.00 D FS#PATH 100A
    > 0146.00 D FS#BUF 512A
    > 0147.00 D FS#RTN 10I 0
    > 0148.00 D pFS#PATH * INZ(%ADDR(FS#PATH))
    > 0149.00 D pFS#BUF * INZ(%ADDR(FS#BUF))
    > 0150.00 D*
    > 0151.00 D*
    >
    > . . . . . . . . . .
    >
    > C EVAL FS#PATH = %TRIMR(CL#DIR) + X'00'
    > C EVAL pFS#PATH = %ADDR(FS#PATH)
    > C EVAL pFS#BUF = %ADDR(FS#BUF)
    > C EVAL FS#RTN = stat64(pFS#PATHFS#BUF)
    > C FS#RTN CABEQ 0 FS$SIZE
    > C EVAL pErrNbr = errno
    > C MOVEL(P) 'STAT_ERROR' CL#STS
    > C EVAL CL#MSG = 'Error ' + %CHAR(GE#ERR) +
    > C ' on stat64() API'
    > C EVAL CL#API = 'stat64()'
    > C EXSR ERRNO$TEXT
    > C GOTO FS$FINI
    >
    > I've tried stat() and stat64().
    >
    > I've tried setting the pointers with INZ keyword in D-spec and %ADDR
    > function in C-spec (and apparently doing both in this code snippet!).
    >
    > From manual, I read that 3025 can be returned because my path string
    > is empty, which I have to assume is most likely what is going on, BUT
    > MY PATH STRING IS NOT EMPTY.
    >
    > Thanks in advance for any help you can provide. Meanwhile, I'll be
    > trying to code my old buddy Qp0lGetAttr,
    > Jack
    >
    > PS, By the way, I'm trying to get the size of an IFS file.
    >
    >
    > .


  4. Re: stat() returning 3025 (ENOENT) error - and never anything else

    Other considerations when getting ENOENT on stat() or stat64() if already
    provided suggestions are not the solution to your problem.

    - As far as finding the object, there should be no difference between stat()
    and stat64(), but if you are trying to get information for objects that are
    very large, I would use stat64().

    - The path is expected in job CCSID. If the path is not provided in job
    CCSID, names may not match, which would cause an object in the path to not
    be found. If you want to specify the CCSID of the path, try QlgStat64().

    - ENOENT may be returned if any object in the path is not found. For
    example, if I try stat64("/dir1/dir2/dir3/dir4", &statbuf). If dir2 doesn't
    exist, then ENOENT will be returned.

    - As Chuck mentioned, if you are specifying a relative path, for example
    "dir2/dir3/dir4", make sure the current directory for the job is set
    corectly. Note that if an absolute path is specified, one that starts with
    /, then the setting of the current directory will not affect finding the
    object.

    --
    Margaret Fenlon
    Integrated File System and Servers - IBM i
    mfenlon@us.eye-bee-m.com (spam trick)
    (opinions stated are not necessarily those of my employer)

    wrote in message
    news:b0aa8446-39a6-4724-8384-dbad6d865a4f@k13g2000hse.googlegroups.com...
    >I can only only assume it's my source, but I am tearing my hair out
    > trying to find where!
    >
    > here's my code:
    > 0139.00 D*
    > 0140.00 Dstat64 PR 10I 0 EXTPROC('stat64')
    > 0141.00 D FS#PRM1 *
    > 0142.00 D FS#PRM2 *
    > 0143.00 D*
    > 0144.00 DFS#STUFF DS
    > 0145.00 D FS#PATH 100A
    > 0146.00 D FS#BUF 512A
    > 0147.00 D FS#RTN 10I 0
    > 0148.00 D pFS#PATH * INZ(%ADDR(FS#PATH))
    > 0149.00 D pFS#BUF * INZ(%ADDR(FS#BUF))
    > 0150.00 D*
    > 0151.00 D*
    >
    > . . . . . . . . . .
    >
    > C EVAL FS#PATH = %TRIMR(CL#DIR) + X'00'
    > C EVAL pFS#PATH = %ADDR(FS#PATH)
    > C EVAL pFS#BUF = %ADDR(FS#BUF)
    > C EVAL FS#RTN = stat64(pFS#PATHFS#BUF)
    > C FS#RTN CABEQ 0 FS$SIZE
    > C EVAL pErrNbr = errno
    > C MOVEL(P) 'STAT_ERROR' CL#STS
    > C EVAL CL#MSG = 'Error ' + %CHAR(GE#ERR) +
    > C ' on stat64() API'
    > C EVAL CL#API = 'stat64()'
    > C EXSR ERRNO$TEXT
    > C GOTO FS$FINI
    >
    > I've tried stat() and stat64().
    >
    > I've tried setting the pointers with INZ keyword in D-spec and %ADDR
    > function in C-spec (and apparently doing both in this code snippet!).
    >
    > From manual, I read that 3025 can be returned because my path string
    > is empty, which I have to assume is most likely what is going on, BUT
    > MY PATH STRING IS NOT EMPTY.
    >
    > Thanks in advance for any help you can provide. Meanwhile, I'll be
    > trying to code my old buddy Qp0lGetAttr,
    > Jack
    >
    > PS, By the way, I'm trying to get the size of an IFS file.
    >
    >
    > .




  5. Re: stat() returning 3025 (ENOENT) error - and never anything else

    Thanks Thomas. Your help and knowledge are once again very
    appreciated. And thanks to all for helping. Thomas got it. stat()
    never saw my path string, until I passed the pointer by value.

    If you don't mind adding a little more, can you point me to
    documentation that would show the translation of the C language data
    types to those more familiar to an RPG programmer. I can find the the
    file size easy enough in the stat() ouptut buffer (character 21
    decimal), and its a 4 byte binary, but, for example, it's noted as a
    data type off_t in the Unix API manual. What's up with that?

    I list some of the 'data types' for the stat() output buffer, as shown
    in the Unix API manual, below. I'd would think the _t defines the
    size and type of the field, but clearly all these data types with _t
    are not the same. Where might I find the sys/stat.h header file,
    maybe it would help.

    mode_t
    ino_t
    nlink_t
    uid_t
    off_t
    time_t
    time_t
    dev_t
    unsigned long
    qp01_objtype_t
    unsigned short
    dev_t
    nlink32_t
    dev64_t
    char
    unsigned


    Thanks,
    Jack Liesner


  6. Re: stat() returning 3025 (ENOENT) error - and never anything else

    I believe you are looking for QSYSINC/H.STAT for which the invocation
    DSPPFM QSYSINC/H STAT is one method to view the text;
    /QSYS.LIB/QSYSINC.LIB/H.FILE/STAT.MBR would be its root file naming.

    Regards, Chuck

    jliesner@gmail.com wrote:
    > Thanks Thomas. Your help and knowledge are once again very
    > appreciated. And thanks to all for helping. Thomas got it. stat()
    > never saw my path string, until I passed the pointer by value.
    >
    > If you don't mind adding a little more, can you point me to
    > documentation that would show the translation of the C language data
    > types to those more familiar to an RPG programmer. I can find the the
    > file size easy enough in the stat() ouptut buffer (character 21
    > decimal), and its a 4 byte binary, but, for example, it's noted as a
    > data type off_t in the Unix API manual. What's up with that?
    >
    > I list some of the 'data types' for the stat() output buffer, as shown
    > in the Unix API manual, below. I'd would think the _t defines the
    > size and type of the field, but clearly all these data types with _t
    > are not the same. Where might I find the sys/stat.h header file,
    > maybe it would help.
    >
    > mode_t
    > ino_t
    > nlink_t
    > uid_t
    > off_t
    > time_t
    > time_t
    > dev_t
    > unsigned long
    > qp01_objtype_t
    > unsigned short
    > dev_t
    > nlink32_t
    > dev64_t
    > char
    > unsigned


  7. Re: stat() returning 3025 (ENOENT) error - and never anything else

    Jack,

    You are welcome.

    A long time ago Barbara Morris published a nice description of how to convert C prototypes to RPG.
    Unfortunately it is no longer available. But, good luck, you can still get it from the
    "WayBackMaschine", the Internet archive at http://web.archive.org.

    Let you take back to "http://www.opensource400.org/callc.html" or follow that link:

    http://web.archive.org/web/200712220...org/callc.html

    I also wrote an article for Common Germany. But it is written in German and that is not what you want,
    I guess.

    Hope that helps.

    Regards,

    Thomas.

    jliesner@gmail.com schrieb:
    > Thanks Thomas. Your help and knowledge are once again very
    > appreciated. And thanks to all for helping. Thomas got it. stat()
    > never saw my path string, until I passed the pointer by value.
    >
    > If you don't mind adding a little more, can you point me to
    > documentation that would show the translation of the C language data
    > types to those more familiar to an RPG programmer. I can find the the
    > file size easy enough in the stat() ouptut buffer (character 21
    > decimal), and its a 4 byte binary, but, for example, it's noted as a
    > data type off_t in the Unix API manual. What's up with that?
    >
    > I list some of the 'data types' for the stat() output buffer, as shown
    > in the Unix API manual, below. I'd would think the _t defines the
    > size and type of the field, but clearly all these data types with _t
    > are not the same. Where might I find the sys/stat.h header file,
    > maybe it would help.
    >
    > mode_t
    > ino_t
    > nlink_t
    > uid_t
    > off_t
    > time_t
    > time_t
    > dev_t
    > unsigned long
    > qp01_objtype_t
    > unsigned short
    > dev_t
    > nlink32_t
    > dev64_t
    > char
    > unsigned
    >
    >
    > Thanks,
    > Jack Liesner
    >


  8. Re: stat() returning 3025 (ENOENT) error - and never anything else

    Jack,

    > types to those more familiar to an RPG programmer. I can find the the
    > file size easy enough in the stat() ouptut buffer (character 21
    > decimal), and its a 4 byte binary, but, for example, it's noted as a
    > data type off_t in the Unix API manual. What's up with that?


    I usually start with the C documentation for example:

    Syntax

    #include

    int stat64(const char *path, struct stat64 *buf);

    Service Program Name: QP0LLIB1

    Default Public Authority: *USE

    The "#include" tells me that the prototype of stat64() is in 'stat.h'. Most (probably all) prototypes
    are in different files in library QSYSINC. In this case it is QSYSINC/H(stat). I then have a look at
    'stat.h'. You often have to check further include files that are referenced there.

    If you do not yet have library QSYSINC on your Systemi, you can install it from menu LICPGM. Select
    option 11 -- Install Licensed Programs -- and install 57xxSS1 option 13.

    Regards,

    Thomas.


    jliesner@gmail.com schrieb:
    > Thanks Thomas. Your help and knowledge are once again very
    > appreciated. And thanks to all for helping. Thomas got it. stat()
    > never saw my path string, until I passed the pointer by value.
    >
    > If you don't mind adding a little more, can you point me to
    > documentation that would show the translation of the C language data
    > types to those more familiar to an RPG programmer. I can find the the
    > file size easy enough in the stat() ouptut buffer (character 21
    > decimal), and its a 4 byte binary, but, for example, it's noted as a
    > data type off_t in the Unix API manual. What's up with that?
    >
    > I list some of the 'data types' for the stat() output buffer, as shown
    > in the Unix API manual, below. I'd would think the _t defines the
    > size and type of the field, but clearly all these data types with _t
    > are not the same. Where might I find the sys/stat.h header file,
    > maybe it would help.
    >
    > mode_t
    > ino_t
    > nlink_t
    > uid_t
    > off_t
    > time_t
    > time_t
    > dev_t
    > unsigned long
    > qp01_objtype_t
    > unsigned short
    > dev_t
    > nlink32_t
    > dev64_t
    > char
    > unsigned
    >
    >
    > Thanks,
    > Jack Liesner
    >


+ Reply to Thread