FreeBSD/lib/libprocstat/libprocstat.c
/*
 * Descriptor flags to filestat translation.
 */
Descriptor flags to filestat translation.
Descriptor flags to filestat translation .
static int
to_filestat_flags(int flags)
{
	static struct {
		int flag;
		int fst_flag;
	} fstflags[] = {
		{ FREAD, PS_FST_FFLAG_READ },
		{ FWRITE, PS_FST_FFLAG_WRITE },
		{ O_APPEND, PS_FST_FFLAG_APPEND },
		{ O_ASYNC, PS_FST_FFLAG_ASYNC },
		{ O_CREAT, PS_FST_FFLAG_CREAT },
		{ O_DIRECT, PS_FST_FFLAG_DIRECT },
		{ O_EXCL, PS_FST_FFLAG_EXCL },
		{ O_EXEC, PS_FST_FFLAG_EXEC },
		{ O_EXLOCK, PS_FST_FFLAG_EXLOCK },
		{ O_NOFOLLOW, PS_FST_FFLAG_NOFOLLOW },
		{ O_NONBLOCK, PS_FST_FFLAG_NONBLOCK },
		{ O_SHLOCK, PS_FST_FFLAG_SHLOCK },
		{ O_SYNC, PS_FST_FFLAG_SYNC },
		{ O_TRUNC, PS_FST_FFLAG_TRUNC }
	};
#define NFSTFLAGS	(sizeof(fstflags) / sizeof(*fstflags))
	int fst_flags;
	unsigned int i;
	fst_flags = 0;
	for (i = 0; i < NFSTFLAGS; i++)
		if (flags & fstflags[i].flag)
			fst_flags |= fstflags[i].fst_flag;
	return (fst_flags);
}
static int to_filestat_flags ( int flags ) { static struct { int flag ; int fst_flag ; } fstflags [ ] = { { FREAD , PS_FST_FFLAG_READ } , { FWRITE , PS_FST_FFLAG_WRITE } , { O_APPEND , PS_FST_FFLAG_APPEND } , { O_ASYNC , PS_FST_FFLAG_ASYNC } , { O_CREAT , PS_FST_FFLAG_CREAT } , { O_DIRECT , PS_FST_FFLAG_DIRECT } , { O_EXCL , PS_FST_FFLAG_EXCL } , { O_EXEC , PS_FST_FFLAG_EXEC } , { O_EXLOCK , PS_FST_FFLAG_EXLOCK } , { O_NOFOLLOW , PS_FST_FFLAG_NOFOLLOW } , { O_NONBLOCK , PS_FST_FFLAG_NONBLOCK } , { O_SHLOCK , PS_FST_FFLAG_SHLOCK } , { O_SYNC , PS_FST_FFLAG_SYNC } , { O_TRUNC , PS_FST_FFLAG_TRUNC } } ; #define NFSTFLAGS 	(sizeof(fstflags) / sizeof(*fstflags)) int fst_flags ; unsigned int i ; fst_flags = 0 ; for ( i = 0 ; i < NFSTFLAGS ; i ++ ) if ( flags & fstflags [ i ] . flag ) fst_flags |= fstflags [ i ] . fst_flag ; return ( fst_flags ) ; }
Descriptor flags to filestat translation.
Descriptor flags to filestat translation .