Ejemplo n.º 1
0
        private int AddFdList(Thread current, FixedSizeBitVector fdlist, short event_type)
        {
            var proc = current.Parent;

            for (int fd = fdlist.FindNextOne(-1); fd > 0; fd = fdlist.FindNextOne(fd))
            {
                //Arch.Console.Write("AddFdList:");
                //Arch.Console.Write(fd);
                //Arch.Console.Write(" ev-");
                //Arch.Console.Write(event_type);
                //Arch.Console.WriteLine();

                var file = proc.LookupFile(fd);
                if (file == null)
                {
                    return(-ErrorCode.EBADF);
                }

                if (file.inode.LinuxFd < 0)
                {
                    return(-ErrorCode.EINVAL);
                }

                Add(file.inode.LinuxFd, fd, event_type);
            }
            return(0);
        }
Ejemplo n.º 2
0
        internal int AddUserFdList(Thread current, UserPtr fdlist, int maxfds, short event_type)
        {
            if (fdlist == UserPtr.Zero)
            {
                return(0);
            }

            var buf = new byte[(maxfds + 7) / 8];

            if (fdlist.Read(current, buf) != 0)
            {
                return(-ErrorCode.EFAULT);
            }

            var vec = new FixedSizeBitVector(maxfds, buf);

            var ret = AddFdList(current, vec, event_type);

            return(ret);
        }
Ejemplo n.º 3
0
        internal int TranslateToUserFdlist(Thread current, ByteBufferRef buf, int poll_ret, int maxfds, UserPtr userPtr, short event_type)
        {
            Contract.Requires(poll_ret * pollfd.Size < buf.Length);

            if (userPtr == UserPtr.Zero)
            {
                return(0);
            }

            var res = 0;
            var len = (maxfds + 7) / 8;
            var vec = new FixedSizeBitVector(maxfds);

            for (int i = 0; i < poll_ret; i++)
            {
                var poll_struct = pollfd.Deserialize(buf, i * pollfd.Size);
                var linux_fd    = poll_struct.fd;
                var node        = Lookup(linux_fd);
                if (node == null)
                {
                    return(-ErrorCode.EBADF);
                }

                if ((poll_struct.revents & event_type & node.event_type) != 0)
                {
                    vec.Set(node.expressos_fd);
                    ++res;
                }
            }

            if (userPtr.Write(current, vec.Buffer) != 0)
            {
                return(-ErrorCode.EFAULT);
            }

            return(res);
        }