3 --- /dev/null 2005-12-29 14:18:54.000000000 +0000
4 +++ libxfs/netbsd.c 2005-12-29 14:22:31.000000000 +0000
7 + * Copyright (c) 2003 Silicon Graphics, Inc. All Rights Reserved.
10 + * This program is free software; you can redistribute it and/or modify it
11 + * under the terms of version 2 of the GNU General Public License as
12 + * published by the Free Software Foundation.
14 + * This program is distributed in the hope that it would be useful, but
15 + * WITHOUT ANY WARRANTY; without even the implied warranty of
16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 + * Further, this software is distributed without any warranty that it is
19 + * free of the rightful claim of any third person regarding infringement
20 + * or the like. Any license provided herein, whether implied or
21 + * otherwise, applies only to this software file. Patent licenses, if
22 + * any, provided herein do not apply to combinations of this program with
23 + * other software, or any other product whatsoever.
25 + * You should have received a copy of the GNU General Public License along
26 + * with this program; if not, write the Free Software Foundation, Inc., 59
27 + * Temple Place - Suite 330, Boston MA 02111-1307, USA.
29 + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
30 + * Mountain View, CA 94043, or:
32 + * http://www.sgi.com
34 + * For further information regarding this notice, see:
36 + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 +#include <xfs/libxfs.h>
40 +#include <sys/types.h>
41 +#include <sys/param.h>
42 +#include <sys/stat.h>
43 +#include <sys/disk.h>
44 +#include <sys/mount.h>
45 +#include <sys/ioctl.h>
47 +extern char *progname;
50 +platform_check_ismounted(char *name, char *block, struct stat64 *s, int verbose)
54 +#if (defined(__NetBSD__) && (__NetBSD_Version__ >= 299000900))
55 + struct statvfs *fsinfo;
57 + struct statfs *fsinfo;
61 + if (stat(block, &st) < 0)
66 + /* Remember, FreeBSD can now mount char devices! -- adrian */
67 + if (((st.st_mode & S_IFMT) != S_IFBLK) &&
68 + ((st.st_mode & S_IFMT) != S_IFCHR))
71 + if ((cnt = getmntinfo(&fsinfo, MNT_NOWAIT)) == 0) {
73 + _("%s: %s possibly contains a mounted filesystem\n"),
78 + for (i = 0; i < cnt; i++) {
79 + if (strcmp (name, fsinfo[i].f_mntfromname) != 0)
84 + _("%s: %s contains a mounted filesystem\n"),
93 +platform_check_iswritable(char *name, char *block, struct stat64 *s, int fatal)
96 +#if (defined(__NetBSD__) && (__NetBSD_Version__ >= 299000900))
97 + struct statvfs *fsinfo;
99 + struct statfs *fsinfo;
102 + if ((cnt = getmntinfo(&fsinfo, MNT_NOWAIT)) == 0) {
103 + fprintf(stderr, _("%s: %s contains a possibly writable, "
104 + "mounted filesystem\n"), progname, name);
108 + for (i = 0; i < cnt; i++) {
109 + if (strcmp (name, fsinfo[i].f_mntfromname) != 0)
112 + if (fsinfo[i].f_flag &= MNT_RDONLY)
117 + fprintf(stderr, _("%s: %s contains a mounted and writable "
118 + "filesystem\n"), progname, name);
125 +platform_set_blocksize(int fd, char *path, int blocksize)
131 +platform_flush_device(int fd, dev_t device)
137 +platform_findsizes(char *path, int fd, long long *sz, int *bsz)
143 + if (fstat(fd, &st) < 0) {
144 + fprintf(stderr, _("%s: "
145 + "cannot stat the device file \"%s\": %s\n"),
146 + progname, path, strerror(errno));
150 + if ((st.st_mode & S_IFMT) == S_IFREG) {
151 + *sz = (long long)(st.st_size >> 9);
156 + if ((st.st_mode & S_IFMT) != S_IFCHR) {
157 + fprintf(stderr, _("%s: "
158 + "Not a device or file: \"%s\"n"),
163 + if ((size = st.st_size) == 0) {
164 + fprintf(stderr, _("%s: "
165 + "zero size: \"%s\"n"),
170 + if ((ssize = st.st_blksize) == 0) {
171 + fprintf(stderr, _("%s: "
172 + "zero block size \"%s\": %s\n"),
173 + progname, path, strerror(errno));
177 + *sz = (long long) (size / ssize);