Summary description for fattr.
예제 #1
0
파일: nfsd.cs 프로젝트: zaubererty/NFS
        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);
        }
예제 #2
0
파일: nfsd.cs 프로젝트: zaubererty/NFS
        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();
            }
        }
예제 #3
0
파일: nfsd.cs 프로젝트: petebarber/NFS
        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();
            }
        }
예제 #4
0
파일: nfsd.cs 프로젝트: petebarber/NFS
        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);
        }
예제 #5
0
 static public void PackSuccess(rpcPacker packer, fattr attr)
 {
     packer.setUint32((uint)NFSStatus.NFS_OK);
     attr.Pack(packer);
 }
예제 #6
0
파일: attrstat.cs 프로젝트: petebarber/NFS
 public static void PackSuccess(rpcPacker packer, fattr attr)
 {
     packer.setUint32((uint)NFSStatus.NFS_OK);
     attr.Pack(packer);
 }