xref: /titanic_41/usr/src/lib/libast/common/features/fs (revision 7a286c471efbab8562f7655a82931904703fffe0)
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
132mem	mnttab.mt_dev,mnttab.mt_filsys,mnttab.mt_fstyp sys/types.h mnttab.h
133mem	mntent.mnt_opts,w_mntent.mnt_opts,mnttab.mnt_opts sys/types.h stdio.h mntent.h sys/mntent.h
134mem	mntent.mnt_opts,mnttab.mnt_opts sys/types.h mnttab.h sys/mnttab.h
135mem	stat.st_blocks,stat.st_blksize,stat.st_rdev sys/types.h sys/stat.h
136mem	statfs.f_files,statfs.f_bavail sys/types.h - sys/statfs.h - sys/vfs.h - sys/param.h sys/mount.h
137mem	statvfs.f_basetype,statvfs.f_frsize sys/types.h sys/statvfs.h
138
139ary	f_reserved7 sys/types.h sys/statvfs.h note{ statvfs.f_reserved7 can double for statvfs.f_basetype }end compile{
140	int f(vp)struct statvfs* vp;{return vp->f_reserved7[0] = 1;}
141}end
142
143hdr	mntent,mnttab
144lib	getmntent,getmntinfo,mntctl,mntopen,mntread,mntclose,setmntent
145lib	w_getmntent
146lib	statfs,statvfs
147sys	fs_types,mntent,mnttab,mount,statfs,statvfs,vfs,vmount
148
149lib	statfs4 sys/types.h - sys/statfs.h - sys/vfs.h - sys/mount.h compile{
150	int f()
151	{
152		struct statfs fs;
153		return statfs("/",&fs,sizeof(fs),0);
154	}
155}end
156
157lib	getmntinfo_statvfs note{ getmntinfo uses statvfs -- since when? }end compile{
158	#include <sys/types.h>
159	#include <sys/mount.h>
160	int
161	gmi(struct statvfs* fs)
162	{
163		fs->f_flag = 0;
164		return getmntinfo(fs, 0);
165	}
166}end
167
168cat{
169	#if _sys_statvfs
170	#include <sys/statvfs.h>
171	#if !_mem_statvfs_f_basetype
172	#if _ary_f_reserved7
173	#define f_basetype	f_reserved7
174	#endif
175	#endif
176	#else
177	#define _mem_f_basetype_statvfs	1
178	#define _mem_f_frsize_statvfs	1
179	struct statvfs
180	{
181	unsigned long	f_bsize;	/* fundamental file system block size */
182	unsigned long	f_frsize;	/* fragment size */
183	unsigned long	f_blocks;	/* total # of blocks of f_frsize on fs */
184	unsigned long	f_bfree;	/* total # of free blocks of f_frsize */
185	unsigned long	f_bavail;	/* # of free blocks avail to non-superuser */
186	unsigned long	f_files;	/* total # of file nodes (inodes) */
187	unsigned long	f_ffree;	/* total # of free file nodes */
188	unsigned long	f_favail;	/* # of free nodes avail to non-superuser */
189	unsigned long	f_fsid;		/* file system id (dev for now) */
190	char		f_basetype[16]; /* target fs type name, null-terminated */
191	unsigned long	f_flag;		/* bit-mask of flags */
192	unsigned long	f_namemax;	/* maximum file name length */
193	char		f_fstr[32];	/* filesystem-specific string */
194	unsigned long	f_filler[16];	/* reserved for future expansion */
195	};
196	extern int	fstatvfs(int, struct statvfs*);
197	extern int	statvfs(const char*, struct statvfs*);
198	#endif
199	#if _typ_off64_t
200	#undef	off_t
201	#define off_t	off64_t
202	#endif
203	#if _lib_statvfs64 && !defined(statvfs)
204	#define statvfs		statvfs64
205	#if !defined(__USE_LARGEFILE64)
206	extern int		statvfs64(const char*, struct statvfs64*);
207	#endif
208	#endif
209	#if _lib_fstatvfs64 && !defined(fstatvfs)
210	#define fstatvfs	fstatvfs64
211	#if !defined(__USE_LARGEFILE64)
212	extern int		fstatvfs64(int, struct statvfs64*);
213	#endif
214	#endif
215}end
216
217str	st_fstype sys/types.h sys/stat.h note{ stat.st_fstype is a string }end compile{
218	int f(st)struct stat* st;{return st->st_fstype[0];}
219}end
220
221int	st_fstype sys/types.h sys/stat.h note{ stat.st_fstype is an int }end compile{
222	int f(st)struct stat* st;{return st->st_fstype = 1;}
223}end
224
225int	st_spare1 sys/types.h sys/stat.h note{ stat.st_spare1 is an int }end compile{
226	int f(st)struct stat* st;{return st->st_spare1 = 1;}
227}end
228
229ary	st_spare4 sys/types.h sys/stat.h note{ stat.st_spare4 is an array }end compile{
230	int f(st)struct stat* st;{return st->st_spare4[0] = 1;}
231}end
232
233ary	st_pad4 sys/types.h sys/stat.h note{ stat.st_pad4 is an array }end compile{
234	int f(st)struct stat* st;{return st->st_pad4[0] = 1;}
235}end
236