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