/* v9fs_uflags2omode- convert posix open flags to plan 9 mode bits @uflags: flags to convert @extended: if .u extensions are active  */
int v9fs_uflags2omode(int uflags, int extended)
/* v9fs_uflags2omode- convert posix open flags to plan 9 mode bits @uflags: flags to convert @extended: if .u extensions are active  */
int v9fs_uflags2omode(int uflags, int extended)
{
	int ret;
	ret = 0;
	switch (uflags&3) {
	default:
	case O_RDONLY:
		ret = P9_OREAD;
		break;
	case O_WRONLY:
		ret = P9_OWRITE;
		break;
	case O_RDWR:
		ret = P9_ORDWR;
		break;
	}
	if (uflags & O_TRUNC)
		ret |= P9_OTRUNC;
	if (extended) {
		if (uflags & O_EXCL)
			ret |= P9_OEXCL;
		if (uflags & O_APPEND)
			ret |= P9_OAPPEND;
	}
	return ret;
}