Module Name: src Committed By: sborrill Date: Mon Oct 5 11:46:22 UTC 2009
Modified Files: src/include [netbsd-5]: util.h src/lib/libutil [netbsd-5]: opendisk.c Log Message: Pull up the following revisions(s) (requested by pooka in ticket #1047): include/util.h: revision 1.52 lib/libutil/opendisk.c: revision 1.11 Add opendisk1(), which functions like opendisk(), but takes a function pointer to the routine to be used for open(). To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.49.12.1 src/include/util.h cvs rdiff -u -r1.10 -r1.10.6.1 src/lib/libutil/opendisk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/include/util.h diff -u src/include/util.h:1.49 src/include/util.h:1.49.12.1 --- src/include/util.h:1.49 Fri Dec 14 16:36:19 2007 +++ src/include/util.h Mon Oct 5 11:46:21 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: util.h,v 1.49 2007/12/14 16:36:19 christos Exp $ */ +/* $NetBSD: util.h,v 1.49.12.1 2009/10/05 11:46:21 sborrill Exp $ */ /*- * Copyright (c) 1995 @@ -80,6 +80,8 @@ void logwtmp(const char *, const char *, const char *); void logwtmpx(const char *, const char *, const char *, int, int); int opendisk(const char *, int, char *, size_t, int); +int opendisk1(const char *, int, char *, size_t, int, + int (*)(const char *, int, mode_t)); int openpty(int *, int *, char *, struct termios *, struct winsize *); time_t parsedate(const char *, const time_t *, const int *); Index: src/lib/libutil/opendisk.c diff -u src/lib/libutil/opendisk.c:1.10 src/lib/libutil/opendisk.c:1.10.6.1 --- src/lib/libutil/opendisk.c:1.10 Mon Apr 28 20:23:03 2008 +++ src/lib/libutil/opendisk.c Mon Oct 5 11:46:21 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: opendisk.c,v 1.10 2008/04/28 20:23:03 martin Exp $ */ +/* $NetBSD: opendisk.c,v 1.10.6.1 2009/10/05 11:46:21 sborrill Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: opendisk.c,v 1.10 2008/04/28 20:23:03 martin Exp $"); +__RCSID("$NetBSD: opendisk.c,v 1.10.6.1 2009/10/05 11:46:21 sborrill Exp $"); #endif #include <sys/param.h> @@ -44,8 +44,9 @@ #include <stdio.h> #include <string.h> -int -opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked) +static int +__opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked, + int (*ofn)(const char *, int, mode_t)) { int f, rawpart; @@ -64,12 +65,12 @@ if (rawpart < 0) return (-1); /* sysctl(3) in getrawpartition sets errno */ - f = open(buf, flags); + f = ofn(buf, flags, 0); if (f != -1 || errno != ENOENT) return (f); snprintf(buf, buflen, "%s%c", path, 'a' + rawpart); - f = open(buf, flags); + f = ofn(buf, flags, 0); if (f != -1 || errno != ENOENT) return (f); @@ -77,12 +78,27 @@ return (-1); snprintf(buf, buflen, "%s%s%s", _PATH_DEV, iscooked ? "" : "r", path); - f = open(buf, flags); + f = ofn(buf, flags, 0); if (f != -1 || errno != ENOENT) return (f); snprintf(buf, buflen, "%s%s%s%c", _PATH_DEV, iscooked ? "" : "r", path, 'a' + rawpart); - f = open(buf, flags); + f = ofn(buf, flags, 0); return (f); } + +int +opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked) +{ + + return __opendisk(path, flags, buf, buflen, iscooked, (void *)open); +} + +int +opendisk1(const char *path, int flags, char *buf, size_t buflen, int iscooked, + int (*ofn)(const char *, int, mode_t)) +{ + + return __opendisk(path, flags, buf, buflen, iscooked, ofn); +}