diff options
-rw-r--r-- | lib/libc/gen/ftok.3 | 9 | ||||
-rw-r--r-- | lib/libc/gen/ftok.c | 10 | ||||
-rw-r--r-- | sys/sys/ipc.h | 4 |
3 files changed, 11 insertions, 12 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)); } diff --git a/sys/sys/ipc.h b/sys/sys/ipc.h index 20a5b644db3..45b2b0cfbc5 100644 --- a/sys/sys/ipc.h +++ b/sys/sys/ipc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ipc.h,v 1.5 1998/06/11 21:13:21 deraadt Exp $ */ +/* $OpenBSD: ipc.h,v 1.6 1998/11/15 19:19:53 deraadt Exp $ */ /* $NetBSD: ipc.h,v 1.15 1996/02/09 18:25:12 christos Exp $ */ /* @@ -105,7 +105,7 @@ void ipc_o2n __P((struct oipc_perm *, struct ipc_perm *)); #include <sys/cdefs.h> __BEGIN_DECLS -key_t ftok __P((const char *, char)); +key_t ftok __P((const char *, int)); __END_DECLS #endif #endif /* !_SYS_IPC_H_ */ |