8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / ucblib / libucb / port / gen / statfs.c
bloba53e34e2758a4eb1eddb9fd156fb659d6296870f
1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2 /* All Rights Reserved */
5 /*
6 * Copyright (c) 1985 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
9 */
12 * Copyright (c) 1988-1997, by Sun Microsystems, Inc.
13 * All Rights reserved.
16 #pragma ident "%Z%%M% %I% %E% SMI"
18 /*LINTLIBRARY*/
20 #include <sys/types.h>
21 #include <errno.h>
22 #include <sys/statvfs.h>
23 #include <sys/vfs.h>
25 #if !defined(_LP64)
26 static void
27 cnvtvfs64(struct statfs64 *buf, struct statvfs64 *vbuf)
29 buf->f_type = 0;
30 buf->f_bsize = vbuf->f_frsize;
31 buf->f_blocks = vbuf->f_blocks;
32 buf->f_bfree = vbuf->f_bfree;
33 buf->f_bavail = vbuf->f_bavail;
34 buf->f_files = vbuf->f_files;
35 buf->f_ffree = vbuf->f_ffree;
36 buf->f_fsid.val[0] = vbuf->f_fsid;
37 buf->f_fsid.val[1] = 0;
40 int
41 statfs64(char *path, struct statfs64 *buf)
43 int ret;
44 struct statvfs64 vbuf;
46 if ((long)buf == -1L) {
47 errno = EFAULT;
48 return (-1);
51 if ((ret = statvfs64(path, &vbuf)) != -1)
52 cnvtvfs64(buf, &vbuf);
53 return (ret);
56 int
57 fstatfs64(int fd, struct statfs64 *buf)
59 int ret;
60 struct statvfs64 vbuf;
62 if ((ret = fstatvfs64(fd, &vbuf)) != -1)
63 cnvtvfs64(buf, &vbuf);
64 return (ret);
66 #endif
68 static void
69 cnvtvfs(struct statfs *buf, struct statvfs *vbuf)
71 buf->f_type = 0;
72 buf->f_bsize = vbuf->f_frsize;
73 buf->f_blocks = vbuf->f_blocks;
74 buf->f_bfree = vbuf->f_bfree;
75 buf->f_bavail = vbuf->f_bavail;
76 buf->f_files = vbuf->f_files;
77 buf->f_ffree = vbuf->f_ffree;
78 buf->f_fsid.val[0] = vbuf->f_fsid;
79 buf->f_fsid.val[1] = 0;
82 int
83 statfs(char *path, struct statfs *buf)
85 int ret;
86 struct statvfs vbuf;
88 if ((long)buf == -1L) {
89 errno = EFAULT;
90 return (-1);
93 if ((ret = statvfs(path, &vbuf)) != -1)
94 cnvtvfs(buf, &vbuf);
95 return (ret);
99 int
100 fstatfs(int fd, struct statfs *buf)
102 int ret;
103 struct statvfs vbuf;
105 if ((ret = fstatvfs(fd, &vbuf)) != -1)
106 cnvtvfs(buf, &vbuf);
107 return (ret);