예제 #1
0
파일: IClient.cs 프로젝트: mailwl/Ryujinx
        // Write(u32 fd, buffer<i8, 0x21, 0> message) -> (i32 ret, u32 bsd_errno)
        public ResultCode Write(ServiceCtx context)
        {
            int fd = context.RequestData.ReadInt32();

            (ulong sendPosition, ulong sendSize) = context.Request.GetBufferType0x21();

            ReadOnlySpan <byte> sendBuffer = context.Memory.GetSpan(sendPosition, (int)sendSize);

            LinuxError      errno  = LinuxError.EBADF;
            IFileDescriptor file   = _context.RetrieveFileDescriptor(fd);
            int             result = -1;

            if (file != null)
            {
                errno = file.Write(out result, sendBuffer);

                if (errno == LinuxError.SUCCESS)
                {
                    SetResultErrno(file, result);
                }
            }

            return(WriteBsdResult(context, result, errno));
        }