ftok pathname vs. filename

608 views Asked by At
key_t ftok(const char *pathname, int proj_id);

What if I use a filename for the first parameter instead of pathname? For example, my program is in the following directory /afs/edu/id/group/a/ftok_test.c

In this case, if I use

int key = ftok(/afs/edu/id/group/a/ftok_test.c, 1);
int key = ftok(/afs/edu/id/group/a, 1);

What is the difference these two?

1

There are 1 answers

0
John Zwinck On

The documentation says:

The application shall ensure that the path argument is the pathname of an existing file that the process is able to stat().

So your second example is ill-formed, because it refers to a directory.