xref: /titanic_41/usr/src/lib/libast/common/features/fs (revision dfbb3a42fe4d6d7c50b9f750f514f8c7b66e4ed9)
1set	prototyped
2lib	_fxstat,__fxstat,_lxstat,__lxstat,_xmknod,__xmknod,_xstat,__xstat,lstat,mknod,sync sys/types.h sys/stat.h
3lib	_fxstat64,__fxstat64,_lxstat64,__lxstat64,_xstat64,__xstat64 -D_LARGEFILE64_SOURCE sys/types.h sys/stat.h
4mac	fstat,lstat,stat,mknod sys/types.h sys/stat.h
5
6lcl	xstat -D_LARGEFILE64_SOURCE link{
7	#include <sys/types.h>
8	#include <sys/stat.h>
9	struct stat64 { int xxx; }; /* disable if stat64 available */
10	#if _STD_
11	extern int stat(const char* path, struct stat* st)
12	#else
13	int stat(path, st)
14	char*		path;
15	struct stat*	st;
16	#endif
17	{
18	#if _lib___xstat
19		return __xstat(_STAT_VER, path, st);
20	#else
21		return _xstat(_STAT_VER, path, st);
22	#endif
23	}
24	int
25	main()
26	{
27		struct stat	st;
28		return stat(".",&st) < 0;
29	}
30}end
31
32lcl	xstat64 -D_LARGEFILE64_SOURCE link{
33	#include <sys/types.h>
34	#include <sys/stat.h>
35	#if _STD_
36	extern int stat64(const char* path, struct stat64* st)
37	#else
38	int stat64(path, st)
39	char*		path;
40	#endif
41	{
42	#if _lib___xstat64
43		return __xstat64(_STAT_VER, path, st);
44	#else
45		return _xstat64(_STAT_VER, path, st);
46	#endif
47	}
48	int
49	main()
50	{
51		struct stat64	st;
52		return stat64(".",&st) < 0;
53	}
54}end
55
56header	sys/stat.h
57header	sys/mkdev.h
58
59extern	chmod		int	(const char*, mode_t)
60extern	fstat		int	(int, struct stat*)
61extern	lstat		int	(const char*, struct stat*)
62extern	mkdir		int	(const char*, mode_t)
63extern	mkfifo		int	(const char*, mode_t)
64extern	mknod		int	(const char*, mode_t, dev_t)
65extern	stat		int	(const char*, struct stat*)
66extern	mkfifo		mode_t	(mode_t)
67
68define	FS_default	"ufs"
69
70macro{
71	#include <sys/types.h>
72	#include <sys/stat.h>
73	#ifndef major
74	#include <sys/param.h>
75	#ifndef major
76	#include <sys/sysmacros.h>
77	#endif
78	<<"#if defined(__STDPP__directive) && defined(__STDPP__initial)">>
79	<<"__STDPP__directive pragma pp:initial">>
80	<<"#endif">>
81	<<"#ifndef major">>
82	#ifdef major
83	<<"#define major(x)">> major((x))
84	#else
85	#ifndef L_BITSMAJOR
86	#define L_BITSMAJOR 8
87	#endif
88	#ifndef L_BITSMINOR
89	#define L_BITSMINOR 8
90	#endif
91	#ifndef L_MAXMAJ
92	#define L_MAXMAJ ((1<<L_BITSMAJOR)-1)
93	#endif
94	#ifndef L_MAXMIN
95	#define L_MAXMIN ((1<<L_BITSMINOR)-1)
96	#endif
97	<<"#define major(x)">> ((int)(((unsigned)(x)>>L_BITSMINOR)&L_MAXMAJ))
98	#endif
99	<<"#endif">>
100	<<"#ifndef minor">>
101	#ifdef minor
102	<<"#define minor(x)">> minor((x))
103	#else
104	<<"#define minor(x)">> ((int)((x)&L_MAXMIN))
105	#endif
106	<<"#endif">>
107	<<"#ifndef makedev">>
108	#ifdef makedev
109	<<"#define makedev(x,y)">> makedev((x),(y))
110	#else
111	<<"#define makedev(x,y)">> ((dev_t)((((x)&0377)<<8)|((y)&0377)))
112	#endif
113	<<"#endif">>
114	#endif
115	<<"#if defined(__STDPP__directive) && defined(__STDPP__initial)">>
116	<<"__STDPP__directive pragma pp:noinitial">>
117	<<"#endif">>
118}end fail{
119	cat <<!
120	#ifndef major
121	#define major(x)	((int)(((unsigned)(x)>>8)&0377))
122	#endif
123	#ifndef minor
124	#define minor(x)	((int)((x)&0377))
125	#endif
126	#ifndef makedev
127	#define makedev(x,y)	((dev_t)((((x)&0377)<<8)|((y)&0377)))
128	#endif
129	!
130}end
131
132hdr	mntent,mnttab stdio.h
133sys	mntent,mnttab stdio.h
134sys	fs_types,mount,statfs,statvfs,vfs,vmount
135
136mem	mnttab.mt_dev,mnttab.mt_filsys,mnttab.mt_fstyp sys/types.h mnttab.h
137mem	mntent.mnt_opts,w_mntent.mnt_opts,mnttab.mnt_opts sys/types.h stdio.h mntent.h sys/mntent.h
138mem	mntent.mnt_opts,mnttab.mnt_opts stdio.h sys/types.h mnttab.h sys/mnttab.h
139mem	stat.st_blocks,stat.st_blksize,stat.st_rdev sys/types.h sys/stat.h
140mem	statfs.f_files,statfs.f_bavail sys/types.h - sys/statfs.h - sys/vfs.h - sys/param.h sys/mount.h
141mem	statvfs.f_basetype,statvfs.f_frsize sys/types.h sys/statvfs.h
142
143ary	f_reserved7 sys/types.h sys/statvfs.h note{ statvfs.f_reserved7 can double for statvfs.f_basetype }end compile{
144	int f(vp)struct statvfs* vp;{return vp->f_reserved7[0] = 1;}
145}end
146
147lib	getmntent,getmntinfo,mntctl,mntopen,mntread,mntclose,setmntent
148lib	w_getmntent
149lib	statfs,statvfs
150
151lib	statfs4 sys/types.h - sys/statfs.h - sys/vfs.h - sys/mount.h compile{
152	int f()
153	{
154		struct statfs fs;
155		return statfs("/",&fs,sizeof(fs),0);
156	}
157}end
158
159lib	getmntinfo_statvfs note{ getmntinfo uses statvfs -- since when? }end compile{
160	#include <sys/types.h>
161	#include <sys/mount.h>
162	int
163	gmi(struct statvfs* fs)
164	{
165		fs->f_flag = 0;
166		return getmntinfo(fs, 0);
167	}
168}end
169
170cat{
171	#if _sys_statvfs
172	#include <sys/statvfs.h>
173	#if !_mem_statvfs_f_basetype
174	#if _ary_f_reserved7
175	#define f_basetype	f_reserved7
176	#endif
177	#endif
178	#else
179	#define _mem_f_basetype_statvfs	1
180	#define _mem_f_frsize_statvfs	1
181	struct statvfs
182	{
183	unsigned long	f_bsize;	/* fundamental file system block size */
184	unsigned long	f_frsize;	/* fragment size */
185	unsigned long	f_blocks;	/* total # of blocks of f_frsize on fs */
186	unsigned long	f_bfree;	/* total # of free blocks of f_frsize */
187	unsigned long	f_bavail;	/* # of free blocks avail to non-superuser */
188	unsigned long	f_files;	/* total # of file nodes (inodes) */
189	unsigned long	f_ffree;	/* total # of free file nodes */
190	unsigned long	f_favail;	/* # of free nodes avail to non-superuser */
191	unsigned long	f_fsid;		/* file system id (dev for now) */
192	char		f_basetype[16]; /* target fs type name, null-terminated */
193	unsigned long	f_flag;		/* bit-mask of flags */
194	unsigned long	f_namemax;	/* maximum file name length */
195	char		f_fstr[32];	/* filesystem-specific string */
196	unsigned long	f_filler[16];	/* reserved for future expansion */
197	};
198	extern int	fstatvfs(int, struct statvfs*);
199	extern int	statvfs(const char*, struct statvfs*);
200	#endif
201	#if _typ_off64_t
202	#undef	off_t
203	#define off_t	off64_t
204	#endif
205	#if _lib_statvfs64 && !defined(statvfs)
206	#define statvfs		statvfs64
207	#if !defined(__USE_LARGEFILE64)
208	extern int		statvfs64(const char*, struct statvfs64*);
209	#endif
210	#endif
211	#if _lib_fstatvfs64 && !defined(fstatvfs)
212	#define fstatvfs	fstatvfs64
213	#if !defined(__USE_LARGEFILE64)
214	extern int		fstatvfs64(int, struct statvfs64*);
215	#endif
216	#endif
217}end
218
219str	st_fstype sys/types.h sys/stat.h note{ stat.st_fstype is a string }end compile{
220	int f(st)struct stat* st;{return st->st_fstype[0];}
221}end
222
223int	st_fstype sys/types.h sys/stat.h note{ stat.st_fstype is an int }end compile{
224	int f(st)struct stat* st;{return st->st_fstype = 1;}
225}end
226
227int	st_spare1 sys/types.h sys/stat.h note{ stat.st_spare1 is an int }end compile{
228	int f(st)struct stat* st;{return st->st_spare1 = 1;}
229}end
230
231ary	st_spare4 sys/types.h sys/stat.h note{ stat.st_spare4 is an array }end compile{
232	int f(st)struct stat* st;{return st->st_spare4[0] = 1;}
233}end
234
235ary	st_pad4 sys/types.h sys/stat.h note{ stat.st_pad4 is an array }end compile{
236	int f(st)struct stat* st;{return st->st_pad4[0] = 1;}
237}end
238