FreeBSD/lib/libprocstat/libprocstat.c
/*
 * kinfo flags to filestat translation.
 */
kinfo flags to filestat translation.
kinfo flags to filestat translation .
static int
kinfo_fflags2fst(int kfflags)
{
	static struct {
		int	kf_flag;
		int	fst_flag;
	} kfflags2fst[] = {
		{ KF_FLAG_APPEND, PS_FST_FFLAG_APPEND },
		{ KF_FLAG_ASYNC, PS_FST_FFLAG_ASYNC },
		{ KF_FLAG_CREAT, PS_FST_FFLAG_CREAT },
		{ KF_FLAG_DIRECT, PS_FST_FFLAG_DIRECT },
		{ KF_FLAG_EXCL, PS_FST_FFLAG_EXCL },
		{ KF_FLAG_EXEC, PS_FST_FFLAG_EXEC },
		{ KF_FLAG_EXLOCK, PS_FST_FFLAG_EXLOCK },
		{ KF_FLAG_FSYNC, PS_FST_FFLAG_SYNC },
		{ KF_FLAG_HASLOCK, PS_FST_FFLAG_HASLOCK },
		{ KF_FLAG_NOFOLLOW, PS_FST_FFLAG_NOFOLLOW },
		{ KF_FLAG_NONBLOCK, PS_FST_FFLAG_NONBLOCK },
		{ KF_FLAG_READ, PS_FST_FFLAG_READ },
		{ KF_FLAG_SHLOCK, PS_FST_FFLAG_SHLOCK },
		{ KF_FLAG_TRUNC, PS_FST_FFLAG_TRUNC },
		{ KF_FLAG_WRITE, PS_FST_FFLAG_WRITE }
	};
#define NKFFLAGS	(sizeof(kfflags2fst) / sizeof(*kfflags2fst))
	unsigned int i;
	int flags;
	flags = 0;
	for (i = 0; i < NKFFLAGS; i++)
		if ((kfflags & kfflags2fst[i].kf_flag) != 0)
			flags |= kfflags2fst[i].fst_flag;
	return (flags);
}
static int kinfo_fflags2fst ( int kfflags ) { static struct { int kf_flag ; int fst_flag ; } kfflags2fst [ ] = { { KF_FLAG_APPEND , PS_FST_FFLAG_APPEND } , { KF_FLAG_ASYNC , PS_FST_FFLAG_ASYNC } , { KF_FLAG_CREAT , PS_FST_FFLAG_CREAT } , { KF_FLAG_DIRECT , PS_FST_FFLAG_DIRECT } , { KF_FLAG_EXCL , PS_FST_FFLAG_EXCL } , { KF_FLAG_EXEC , PS_FST_FFLAG_EXEC } , { KF_FLAG_EXLOCK , PS_FST_FFLAG_EXLOCK } , { KF_FLAG_FSYNC , PS_FST_FFLAG_SYNC } , { KF_FLAG_HASLOCK , PS_FST_FFLAG_HASLOCK } , { KF_FLAG_NOFOLLOW , PS_FST_FFLAG_NOFOLLOW } , { KF_FLAG_NONBLOCK , PS_FST_FFLAG_NONBLOCK } , { KF_FLAG_READ , PS_FST_FFLAG_READ } , { KF_FLAG_SHLOCK , PS_FST_FFLAG_SHLOCK } , { KF_FLAG_TRUNC , PS_FST_FFLAG_TRUNC } , { KF_FLAG_WRITE , PS_FST_FFLAG_WRITE } } ; #define NKFFLAGS 	(sizeof(kfflags2fst) / sizeof(*kfflags2fst)) unsigned int i ; int flags ; flags = 0 ; for ( i = 0 ; i < NKFFLAGS ; i ++ ) if ( ( kfflags & kfflags2fst [ i ] . kf_flag ) != 0 ) flags |= kfflags2fst [ i ] . fst_flag ; return ( flags ) ; }
kinfo flags to filestat translation.
kinfo flags to filestat translation .