Summary description for fattr.
Exemple #1
0
        private void CreateFileOrDirectory(rpcCracker cracker, rpcPacker packer, bool createFile)
        {
            createargs args = new createargs(cracker);

            String createPath = FileTable.LookupFileEntry(args.Where.DirHandle).Name + @"\" + args.Where.FileName;

            Console.WriteLine("Create: {0}", createPath);

            fhandle fh;

            if ((fh = FileTable.LookupFileHandle(createPath)) == null)
            {
                fh = FileTable.Add(new FileEntry(createPath));
            }

            if (createFile == true)
            {
                new FileInfo(createPath).Create().Close();
            }
            else
            {
                new DirectoryInfo(createPath).Create();
            }

            fattr attr = new fattr(fh);

            if (attr.IsFile() != createFile)
            {
                throw new System.Exception();
            }

            diropres.PackSuccess(packer, fh, attr);
        }
Exemple #2
0
        private void Read(rpcCracker cracker, rpcPacker packer)
        {
            fhandle fh         = new fhandle(cracker);
            uint    offset     = cracker.get_uint32();
            uint    count      = cracker.get_uint32();
            uint    totalCount = cracker.get_uint32();

            FileStream fs;

            try
            {
                fs = new FileStream(FileTable.LookupFileEntry(fh).Name, FileMode.Open, FileAccess.Read);
            }
            catch (System.IO.FileNotFoundException)
            {
                FileTable.Remove(fh);
                throw;
            }

            try
            {
                fs.Position = offset;

                Byte[] buf = new Byte[count];

                int bytesRead = fs.Read(buf, 0, (int)count);

                fattr attr = new fattr(fh);

                if (attr.IsFile() == false)
                {
                    throw new NFSStatusException(NFSStatus.NFSERR_ISDIR);
                }

                packer.setUint32((uint)NFSStatus.NFS_OK);
                attr.Pack(packer);
                packer.setData(buf, bytesRead);
            }
            finally
            {
                fs.Close();
            }
        }
Exemple #3
0
        private void Read(rpcCracker cracker, rpcPacker packer)
        {
            fhandle fh			= new fhandle(cracker);
            uint	offset		= cracker.get_uint32();
            uint	count		= cracker.get_uint32();
            uint	totalCount	= cracker.get_uint32();

            FileStream fs;

            try
            {
                fs = new FileStream(FileTable.LookupFileEntry(fh).Name, FileMode.Open, FileAccess.Read);
            }
            catch (System.IO.FileNotFoundException)
            {
                FileTable.Remove(fh);
                throw;
            }

            try
            {
                fs.Position = offset;

                Byte[] buf = new Byte[count];

                int bytesRead = fs.Read(buf, 0, (int)count);

                fattr attr = new fattr(fh);

                if (attr.IsFile() == false) throw new NFSStatusException(NFSStatus.NFSERR_ISDIR);

                packer.setUint32((uint)NFSStatus.NFS_OK);
                attr.Pack(packer);
                packer.setData(buf, bytesRead);
            }
            finally
            {
                fs.Close();
            }
        }
Exemple #4
0
        private void CreateFileOrDirectory(rpcCracker cracker, rpcPacker packer, bool createFile)
        {
            createargs args = new createargs(cracker);

            String createPath = FileTable.LookupFileEntry(args.Where.DirHandle).Name + @"\" + args.Where.FileName;

            Console.WriteLine("Create: {0}", createPath);

            fhandle fh;

            if ((fh = FileTable.LookupFileHandle(createPath)) == null)
                fh = FileTable.Add(new FileEntry(createPath));

            if (createFile == true)
                new FileInfo(createPath).Create().Close();
            else
                new DirectoryInfo(createPath).Create();

            fattr attr = new fattr(fh);

            if (attr.IsFile() != createFile)
                throw new System.Exception();

            diropres.PackSuccess(packer, fh, attr);
        }
Exemple #5
0
 static public void PackSuccess(rpcPacker packer, fattr attr)
 {
     packer.setUint32((uint)NFSStatus.NFS_OK);
     attr.Pack(packer);
 }
Exemple #6
0
 public static void PackSuccess(rpcPacker packer, fattr attr)
 {
     packer.setUint32((uint)NFSStatus.NFS_OK);
     attr.Pack(packer);
 }