1*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
3*7c478bd9Sstevel@tonic-gate 
4*7c478bd9Sstevel@tonic-gate 
5*7c478bd9Sstevel@tonic-gate /*
6*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1985 Regents of the University of California.
7*7c478bd9Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
8*7c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
9*7c478bd9Sstevel@tonic-gate  */
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate /*
12*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1988-1997, by Sun Microsystems, Inc.
13*7c478bd9Sstevel@tonic-gate  * All Rights reserved.
14*7c478bd9Sstevel@tonic-gate  */
15*7c478bd9Sstevel@tonic-gate 
16*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
17*7c478bd9Sstevel@tonic-gate 
18*7c478bd9Sstevel@tonic-gate /*LINTLIBRARY*/
19*7c478bd9Sstevel@tonic-gate 
20*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
21*7c478bd9Sstevel@tonic-gate #include <errno.h>
22*7c478bd9Sstevel@tonic-gate #include <sys/statvfs.h>
23*7c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate #if !defined(_LP64)
26*7c478bd9Sstevel@tonic-gate static void
cnvtvfs64(struct statfs64 * buf,struct statvfs64 * vbuf)27*7c478bd9Sstevel@tonic-gate cnvtvfs64(struct statfs64 *buf, struct statvfs64 *vbuf)
28*7c478bd9Sstevel@tonic-gate {
29*7c478bd9Sstevel@tonic-gate 	buf->f_type = 0;
30*7c478bd9Sstevel@tonic-gate 	buf->f_bsize = vbuf->f_frsize;
31*7c478bd9Sstevel@tonic-gate 	buf->f_blocks = vbuf->f_blocks;
32*7c478bd9Sstevel@tonic-gate 	buf->f_bfree = vbuf->f_bfree;
33*7c478bd9Sstevel@tonic-gate 	buf->f_bavail = vbuf->f_bavail;
34*7c478bd9Sstevel@tonic-gate 	buf->f_files = vbuf->f_files;
35*7c478bd9Sstevel@tonic-gate 	buf->f_ffree = vbuf->f_ffree;
36*7c478bd9Sstevel@tonic-gate 	buf->f_fsid.val[0] = vbuf->f_fsid;
37*7c478bd9Sstevel@tonic-gate 	buf->f_fsid.val[1] = 0;
38*7c478bd9Sstevel@tonic-gate }
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate int
statfs64(char * path,struct statfs64 * buf)41*7c478bd9Sstevel@tonic-gate statfs64(char *path, struct statfs64 *buf)
42*7c478bd9Sstevel@tonic-gate {
43*7c478bd9Sstevel@tonic-gate 	int ret;
44*7c478bd9Sstevel@tonic-gate 	struct statvfs64 vbuf;
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate 	if ((long)buf == -1L) {
47*7c478bd9Sstevel@tonic-gate 		errno = EFAULT;
48*7c478bd9Sstevel@tonic-gate 		return (-1);
49*7c478bd9Sstevel@tonic-gate 	}
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate 	if ((ret = statvfs64(path, &vbuf)) != -1)
52*7c478bd9Sstevel@tonic-gate 		cnvtvfs64(buf, &vbuf);
53*7c478bd9Sstevel@tonic-gate 	return (ret);
54*7c478bd9Sstevel@tonic-gate }
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate int
fstatfs64(int fd,struct statfs64 * buf)57*7c478bd9Sstevel@tonic-gate fstatfs64(int fd, struct statfs64 *buf)
58*7c478bd9Sstevel@tonic-gate {
59*7c478bd9Sstevel@tonic-gate 	int ret;
60*7c478bd9Sstevel@tonic-gate 	struct statvfs64 vbuf;
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate 	if ((ret = fstatvfs64(fd, &vbuf)) != -1)
63*7c478bd9Sstevel@tonic-gate 		cnvtvfs64(buf, &vbuf);
64*7c478bd9Sstevel@tonic-gate 	return (ret);
65*7c478bd9Sstevel@tonic-gate }
66*7c478bd9Sstevel@tonic-gate #endif
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate static void
cnvtvfs(struct statfs * buf,struct statvfs * vbuf)69*7c478bd9Sstevel@tonic-gate cnvtvfs(struct statfs *buf, struct statvfs *vbuf)
70*7c478bd9Sstevel@tonic-gate {
71*7c478bd9Sstevel@tonic-gate 	buf->f_type = 0;
72*7c478bd9Sstevel@tonic-gate 	buf->f_bsize = vbuf->f_frsize;
73*7c478bd9Sstevel@tonic-gate 	buf->f_blocks = vbuf->f_blocks;
74*7c478bd9Sstevel@tonic-gate 	buf->f_bfree = vbuf->f_bfree;
75*7c478bd9Sstevel@tonic-gate 	buf->f_bavail = vbuf->f_bavail;
76*7c478bd9Sstevel@tonic-gate 	buf->f_files = vbuf->f_files;
77*7c478bd9Sstevel@tonic-gate 	buf->f_ffree = vbuf->f_ffree;
78*7c478bd9Sstevel@tonic-gate 	buf->f_fsid.val[0] = vbuf->f_fsid;
79*7c478bd9Sstevel@tonic-gate 	buf->f_fsid.val[1] = 0;
80*7c478bd9Sstevel@tonic-gate }
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate int
statfs(char * path,struct statfs * buf)83*7c478bd9Sstevel@tonic-gate statfs(char *path, struct statfs *buf)
84*7c478bd9Sstevel@tonic-gate {
85*7c478bd9Sstevel@tonic-gate 	int ret;
86*7c478bd9Sstevel@tonic-gate 	struct statvfs vbuf;
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate 	if ((long)buf == -1L) {
89*7c478bd9Sstevel@tonic-gate 		errno = EFAULT;
90*7c478bd9Sstevel@tonic-gate 		return (-1);
91*7c478bd9Sstevel@tonic-gate 	}
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate 	if ((ret = statvfs(path, &vbuf)) != -1)
94*7c478bd9Sstevel@tonic-gate 		cnvtvfs(buf, &vbuf);
95*7c478bd9Sstevel@tonic-gate 	return (ret);
96*7c478bd9Sstevel@tonic-gate }
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate int
fstatfs(int fd,struct statfs * buf)100*7c478bd9Sstevel@tonic-gate fstatfs(int fd, struct statfs *buf)
101*7c478bd9Sstevel@tonic-gate {
102*7c478bd9Sstevel@tonic-gate 	int ret;
103*7c478bd9Sstevel@tonic-gate 	struct statvfs vbuf;
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate 	if ((ret = fstatvfs(fd, &vbuf)) != -1)
106*7c478bd9Sstevel@tonic-gate 		cnvtvfs(buf, &vbuf);
107*7c478bd9Sstevel@tonic-gate 	return (ret);
108*7c478bd9Sstevel@tonic-gate }
109