Snarf.Nfs.FileSystem.FileHandle.Emit C# (CSharp) Method

Emit() public method

public Emit ( NfsPacket &packet ) : System.Boolean
packet NfsPacket
return System.Boolean
        public Boolean Emit(ref NfsPacket packet)
        {
            packet.SetUInt(root);
            packet.SetUInt(handle);
            packet.SetUInt(@readonly);

            // The rest of the words of the handle should be 0.  Since there are 32 bytes in a handle,
            // there are 8 words and the above consumed 3 of them, so there are 5 left.
            for (int i = 0; i < 5; i++) {
                packet.SetUInt(0);
            }

            return true;
        }

Usage Example

Exemplo n.º 1
0
        public virtual NfsPacket Create(uint xid, NfsPacket packet)
        {
            try {
                FileHandle dirFH   = new FileHandle(packet);
                string     entry   = packet.GetString();
                string     dirName = GetNameFromHandle(dirFH.Handle, xid);
                string     path    = Path.Combine(dirName, entry);

                // make the file

                if (File.Exists(path))
                {
                    throw new NFSException(xid, (uint)NfsReply.ERR_EXIST);
                }

                using (var file = File.Create(path)) { }

                // make a new handle for this file
                FileHandle fh     = new FileHandle();
                long       handle = HandleManager.Current.GetHandle(path);
                fh.Set(dirFH.Root, (uint)handle, dirFH.ReadOnly);

                // get the attributes of this new file
                NfsFileAttributes fa = new NfsFileAttributes();
                fa.Load(path);

                // create the reply packet
                NfsPacket reply = new NfsPacket(128);
                reply.AddReplyHeader(xid);
                reply.SetUInt((uint)NfsReply.OK);
                fh.Emit(ref reply);
                fa.Emit(ref reply);
                return(reply);
            }
            catch (FileNotFoundException) {
                throw new NFSException(xid, (uint)NfsReply.ERR_IO);
            }
            catch (IOException) {
                throw new NFSException(xid, (uint)NfsReply.ERR_IO);
            }
            catch (System.Security.SecurityException) {
                throw new NFSException(xid, (uint)NfsReply.ERR_PERM);
            }
        }
All Usage Examples Of Snarf.Nfs.FileSystem.FileHandle::Emit