diff --git a/lib/libc/compat/include/fstypes.h b/lib/libc/compat/include/fstypes.h index 5f5b588b728b..3aaab189d2ef 100644 --- a/lib/libc/compat/include/fstypes.h +++ b/lib/libc/compat/include/fstypes.h @@ -1,4 +1,4 @@ -/* $NetBSD: fstypes.h,v 1.1 2006/07/31 16:34:42 martin Exp $ */ +/* $NetBSD: fstypes.h,v 1.2 2006/08/04 16:30:22 yamt Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -52,7 +52,6 @@ struct compat_30_fhandle { struct compat_30_fid fh_fid; }; -#define FHANDLE30_SIZE(fh) (offsetof(struct compat_30_fhandle, fh_fid) \ - + (fh)->fh_fid.fid30_len) +#define FHANDLE30_SIZE sizeof(struct compat_30_fhandle) /* 28 */ #endif /* _COMPAT_FSTYPES_H_ */ diff --git a/lib/libc/compat/sys/compat___fhstat30.c b/lib/libc/compat/sys/compat___fhstat30.c index 6c06eca539bd..9db1b09794ce 100644 --- a/lib/libc/compat/sys/compat___fhstat30.c +++ b/lib/libc/compat/sys/compat___fhstat30.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat___fhstat30.c,v 1.1 2006/07/31 16:34:42 martin Exp $ */ +/* $NetBSD: compat___fhstat30.c,v 1.2 2006/08/04 16:30:22 yamt Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___fhstat30.c,v 1.1 2006/07/31 16:34:42 martin Exp $"); +__RCSID("$NetBSD: compat___fhstat30.c,v 1.2 2006/08/04 16:30:22 yamt Exp $"); #endif /* LIBC_SCCS and not lint */ #define __LIBC12_SOURCE__ @@ -60,5 +60,5 @@ int __fhstat40(const void *fhp, size_t fh_size, struct stat *sb); int __fhstat30(const struct compat_30_fhandle *fhp, struct stat *sb) { - return __fhstat40(fhp, FHANDLE30_SIZE(fhp), sb); + return __fhstat40(fhp, FHANDLE30_SIZE, sb); } diff --git a/lib/libc/compat/sys/compat_fhopen.c b/lib/libc/compat/sys/compat_fhopen.c index e7a63997358f..afefe9667699 100644 --- a/lib/libc/compat/sys/compat_fhopen.c +++ b/lib/libc/compat/sys/compat_fhopen.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat_fhopen.c,v 1.1 2006/07/31 16:34:42 martin Exp $ */ +/* $NetBSD: compat_fhopen.c,v 1.2 2006/08/04 16:30:22 yamt Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_fhopen.c,v 1.1 2006/07/31 16:34:42 martin Exp $"); +__RCSID("$NetBSD: compat_fhopen.c,v 1.2 2006/08/04 16:30:22 yamt Exp $"); #endif /* LIBC_SCCS and not lint */ #define __LIBC12_SOURCE__ @@ -61,5 +61,5 @@ int fhopen(struct compat_30_fhandle *, int); int fhopen(struct compat_30_fhandle *fhp, int flags) { - return __fhopen40(fhp, FHANDLE30_SIZE(fhp), flags); + return __fhopen40(fhp, FHANDLE30_SIZE, flags); } diff --git a/lib/libc/compat/sys/compat_fhstatvfs.c b/lib/libc/compat/sys/compat_fhstatvfs.c index 7c8244d5fe6f..25979c0c5f32 100644 --- a/lib/libc/compat/sys/compat_fhstatvfs.c +++ b/lib/libc/compat/sys/compat_fhstatvfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat_fhstatvfs.c,v 1.1 2006/07/31 16:34:42 martin Exp $ */ +/* $NetBSD: compat_fhstatvfs.c,v 1.2 2006/08/04 16:30:22 yamt Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_fhstatvfs.c,v 1.1 2006/07/31 16:34:42 martin Exp $"); +__RCSID("$NetBSD: compat_fhstatvfs.c,v 1.2 2006/08/04 16:30:22 yamt Exp $"); #endif /* LIBC_SCCS and not lint */ #define __LIBC12_SOURCE__ @@ -65,5 +65,5 @@ int __fhstatvfs140(const void *fhp, size_t fh_size, struct statvfs *buf, int _fhstatvfs(const struct compat_30_fhandle *fhp, struct statvfs *buf) { - return __fhstatvfs140(fhp, FHANDLE30_SIZE(fhp), buf, ST_WAIT); + return __fhstatvfs140(fhp, FHANDLE30_SIZE, buf, ST_WAIT); } diff --git a/lib/libc/compat/sys/compat_fhstatvfs1.c b/lib/libc/compat/sys/compat_fhstatvfs1.c index 656c9bb88884..2c48b89771b4 100644 --- a/lib/libc/compat/sys/compat_fhstatvfs1.c +++ b/lib/libc/compat/sys/compat_fhstatvfs1.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat_fhstatvfs1.c,v 1.1 2006/07/31 16:34:42 martin Exp $ */ +/* $NetBSD: compat_fhstatvfs1.c,v 1.2 2006/08/04 16:30:22 yamt Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_fhstatvfs1.c,v 1.1 2006/07/31 16:34:42 martin Exp $"); +__RCSID("$NetBSD: compat_fhstatvfs1.c,v 1.2 2006/08/04 16:30:22 yamt Exp $"); #endif /* LIBC_SCCS and not lint */ #define __LIBC12_SOURCE__ @@ -62,5 +62,5 @@ int __fhstatvfs140(const void *fhp, size_t fh_size, struct statvfs *buf, int fhstatvfs1(const struct compat_30_fhandle *fhp, struct statvfs *buf, int flags) { - return __fhstatvfs140(fhp, FHANDLE30_SIZE(fhp), buf, flags); + return __fhstatvfs140(fhp, FHANDLE30_SIZE, buf, flags); } diff --git a/lib/libc/compat/sys/compat_getfh.c b/lib/libc/compat/sys/compat_getfh.c index e99ebcca0667..ebcae1259356 100644 --- a/lib/libc/compat/sys/compat_getfh.c +++ b/lib/libc/compat/sys/compat_getfh.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat_getfh.c,v 1.4 2006/07/31 16:34:42 martin Exp $ */ +/* $NetBSD: compat_getfh.c,v 1.5 2006/08/04 16:30:22 yamt Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_getfh.c,v 1.4 2006/07/31 16:34:42 martin Exp $"); +__RCSID("$NetBSD: compat_getfh.c,v 1.5 2006/08/04 16:30:22 yamt Exp $"); #endif /* LIBC_SCCS and not lint */ #define __LIBC12_SOURCE__ @@ -48,6 +48,8 @@ __RCSID("$NetBSD: compat_getfh.c,v 1.4 2006/07/31 16:34:42 martin Exp $"); #include #include +#include + __warn_references(getfh, "warning: reference to compatibility getfh(); include to generate correct reference") @@ -62,6 +64,15 @@ int getfh(const char *path, struct compat_30_fhandle *fhp) { size_t fh_size = sizeof(*fhp); + int ret; - return __getfh30(path, (void*)fhp, &fh_size); + ret = __getfh30(path, (void*)fhp, &fh_size); + if (ret != 0) { + return ret; + } + if (fh_size != FHANDLE30_SIZE) { + errno = EINVAL; + return -1; + } + return 0; } diff --git a/lib/libc/compat/sys/compat_statfs.c b/lib/libc/compat/sys/compat_statfs.c index 175ff389ee52..73f120d8752c 100644 --- a/lib/libc/compat/sys/compat_statfs.c +++ b/lib/libc/compat/sys/compat_statfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat_statfs.c,v 1.2 2006/07/31 16:34:42 martin Exp $ */ +/* $NetBSD: compat_statfs.c,v 1.3 2006/08/04 16:30:22 yamt Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_statfs.c,v 1.2 2006/07/31 16:34:42 martin Exp $"); +__RCSID("$NetBSD: compat_statfs.c,v 1.3 2006/08/04 16:30:22 yamt Exp $"); #endif /* LIBC_SCCS and not lint */ #define __LIBC12_SOURCE__ @@ -164,7 +164,7 @@ fhstatfs(const struct compat_30_fhandle *fh, struct statfs12 *ost) struct statvfs nst; int ret; - if ((ret = __fhstatvfs140(fh, FHANDLE30_SIZE(fh), &nst, ST_WAIT)) == -1) + if ((ret = __fhstatvfs140(fh, FHANDLE30_SIZE, &nst, ST_WAIT)) == -1) return ret; vfs2fs(ost, &nst); return ret;