Example #1
0
        /// <summary>
        /// Initialize PipeFS
        /// </summary>
        /// <param name="nodes">The nodes array for read and write end</param>
        /// <param name="size">The size of the Fifo</param>
        public static unsafe ErrorCode Create(Node[] nodes, int size)
        {
            // Two sided pipe
            Node readEnd  = new Node();
            Node writeEnd = new Node();

            Fifo         fifo   = new Fifo(size, true);
            PipeFSCookie cookie = new PipeFSCookie();

            cookie.Fifo = fifo;

            // Configure
            readEnd.Cookie   = cookie;
            readEnd.GetSize  = getSizeImpl;
            readEnd.Read     = readImpl;
            readEnd.Close    = closeImpl;
            writeEnd.Cookie  = cookie;
            writeEnd.GetSize = getSizeImpl;
            writeEnd.Write   = writeImpl;
            writeEnd.Close   = closeImpl;

            // Should be already opened before entering the program again
            VFS.Open(readEnd, (int)FileMode.O_RDONLY);
            VFS.Open(writeEnd, (int)FileMode.O_WRONLY);

            // 0 is read end, 1 is write end
            nodes[0] = readEnd;
            nodes[1] = writeEnd;

            return(ErrorCode.SUCCESS);
        }
Example #2
0
        /// <summary>
        /// Creates the stat structure
        /// </summary>
        /// <param name="st"></param>
        public unsafe void Stat(Stat *st)
        {
            st->st_dev  = 0;
            st->st_rdev = 0;
            st->st_ino  = 0;
            st->st_size = VFS.GetSize(this);

            st->st_mode = 0;
            st->st_uid  = 0;
            st->st_gid  = 0;

            st->st_atime = 0;
            st->st_mtime = 0;
            st->st_ctime = 0;

            st->st_nlink   = 1;
            st->st_blksize = 0;
            st->st_blkcnt  = 0;
        }