summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-11-15 19:19:56 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-11-15 19:19:56 +0000
commit3843a539f3c3ff183976487c26f9c10c6592f889 (patch)
tree336a22816f2e97b47ea64e9bfd86b198b7f44e04 /lib
parent5ed8ade2e8750d7fcf6b0d0a143fc3cdef387b97 (diff)
ftok() takes int id; xpg
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/ftok.39
-rw-r--r--lib/libc/gen/ftok.c10
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/libc/gen/ftok.3 b/lib/libc/gen/ftok.3
index 8c90f7ffc3d..c9305fba1c1 100644
--- a/lib/libc/gen/ftok.3
+++ b/lib/libc/gen/ftok.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ftok.3,v 1.3 1996/10/02 13:51:34 michaels Exp $
+.\" $OpenBSD: ftok.3,v 1.4 1998/11/15 19:19:55 deraadt Exp $
.\"
.\" Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
.\" All rights reserved.
@@ -35,7 +35,7 @@
.Fd #include <sys/types.h>
.Fd #include <sys/ipc.h>
.Ft key_t
-.Fn ftok "const char *path" "char id" ;
+.Fn ftok "const char *path" "int id" ;
.Sh DESCRIPTION
The
.Fn ftok
@@ -55,10 +55,13 @@ must specify an existing file that is accessible to the calling process
or the call will fail. Also, note that links to files will return the
same key, given the same
.Fa id .
+Only the 8 least significant bits of
+.Fa id
+are used in the key generation; the rest of the bits are ignored.
.Sh RETURN VALUES
The
.Fn ftok
-function will return -1 if
+function will return (key_t)-1 if
.Fa path
does not exist or if it cannot be accessed by the calling process.
.Sh SEE ALSO
diff --git a/lib/libc/gen/ftok.c b/lib/libc/gen/ftok.c
index 42013e8e916..8ded096a8d4 100644
--- a/lib/libc/gen/ftok.c
+++ b/lib/libc/gen/ftok.c
@@ -26,7 +26,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: ftok.c,v 1.4 1997/07/25 20:30:02 mickey Exp $";
+static char *rcsid = "$OpenBSD: ftok.c,v 1.5 1998/11/15 19:19:55 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -34,13 +34,9 @@ static char *rcsid = "$OpenBSD: ftok.c,v 1.4 1997/07/25 20:30:02 mickey Exp $";
#include <sys/ipc.h>
key_t
-#ifdef __STDC__
-ftok(const char *path, char id)
-#else
ftok(path, id)
const char *path;
- char id;
-#endif
+ int id;
{
struct stat st;
@@ -48,5 +44,5 @@ ftok(path, id)
return (key_t)-1;
return (key_t)
- (id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff));
+ ((id & 0xff) << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff));
}