def open(self, name, flags, preferred_fd=None):
        """
        Open a symbolic file. Basically open(2).

        :param name:            Path of the symbolic file, as a string or bytes.
        :type name:             string or bytes
        :param flags:           File operation flags, a bitfield of constants from open(2), as an AST
        :param preferred_fd:    Assign this fd if it's not already claimed.
        :return:                The file descriptor number allocated (maps through posix.get_fd to a SimFileDescriptor)
                                or None if the open fails.

        ``mode`` from open(2) is unsupported at present.
        """

        if len(name) == 0:
            return None
        if type(name) is str:
            name = name.encode()

        # FIXME: HACK
        if self.uid != 0 and name.startswith(b'/var/run'):
            return None

        # TODO: speed this up (editor's note: ...really? this is fine)
        fd = None
        if preferred_fd is not None and preferred_fd not in self.fd:
            fd = preferred_fd
        else:
            fd = self._pick_fd()

        flags = self.state.solver.eval(flags)
        writing = (flags & Flags.O_ACCMODE) in (Flags.O_RDWR, Flags.O_WRONLY)

        simfile = self.state.fs.get(name)
        if simfile is None:
            ident = SimFile.make_ident(name)
            if not writing:
                if options.ALL_FILES_EXIST not in self.state.options:
                    return None
                l.warning("Trying to open unknown file %s - created a symbolic file since ALL_FILES_EXIST is set", name)
                simfile = SimFile(name, ident=ident, size=self.state.solver.BVS('filesize_%s' % ident, self.state.arch.bits, key=('file', ident, 'filesize'), eternal=True))
            else:
                simfile = SimFile(name, ident=ident)
            if not self.state.fs.insert(name, simfile):
                return None

        simfd = SimFileDescriptor(simfile, flags)
        simfd.set_state(self.state)
        self.fd[fd] = simfd
        return fd
Open a symbolic file. Basically open(2).

        :param name:            Path of the symbolic file, as a string or bytes.
        :type name:             string or bytes
        :param flags:           File operation flags, a bitfield of constants from open(2), as an AST
        :param preferred_fd:    Assign this fd if it's not already claimed.
        :return:                The file descriptor number allocated (maps through posix.get_fd to a SimFileDescriptor)
                                or None if the open fails.

        ``mode`` from open(2) is unsupported at present.