@Override
	public synchronized EmuUnixFile<T> open(String pathname, Set<OpenFlag> flags, EmuUnixUser user,
			int mode) throws EmuIOException {
		EmuUnixFile<T> file =
			flags.contains(OpenFlag.O_CREAT) ? createOrGetFile(pathname, mode) : getFile(pathname);

		if (file == null) {
			throw new EmuIOException("File not found: " + pathname);
		}
		if (flags.contains(OpenFlag.O_RDONLY) || flags.contains(OpenFlag.O_RDWR)) {
			file.checkReadable(user);
		}
		if (flags.contains(OpenFlag.O_WRONLY) || flags.contains(OpenFlag.O_RDWR)) {
			file.checkWritable(user);
			if (flags.contains(OpenFlag.O_TRUNC)) {
				file.truncate();
			}
		}
		return file;
	}
An abstract emulated file system, exported to an emulated user-space program

@param <T> the type of values stored in the file system
Ghidra/Features/SystemEmulation/src/main/java/ghidra/pcode/emu/unix/AbstractEmuUnixFileSystem.java