Summary description for sattr.
Example #1
0
        private void SymLink(rpcCracker cracker, rpcPacker packer)
        {
            diropargs args = new diropargs(cracker);
            string    path = cracker.get_String();
            sattr     attr = new sattr(cracker);

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

            Console.WriteLine("Symlink: {0}->{1}", createPath, path);

            fhandle fh;

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

            try
            {
                FileStream symlink = new FileStream(createPath, FileMode.CreateNew, FileAccess.Write);

                try
                {
                    UTF8Encoding pathUTF8 = new UTF8Encoding();

                    byte[] buf = pathUTF8.GetBytes(path);

                    symlink.Write(buf, 0, buf.Length);

                    packer.setUint32((uint)NFSStatus.NFS_OK);
                }
                finally
                {
                    symlink.Close();
                }
            }
            catch (IOException)
            {
                if (new FileInfo(createPath).Exists == true)
                {
                    throw new NFSStatusException(NFSStatus.NFSERR_EXIST);
                }
                else
                {
                    throw;
                }
            }
        }
Example #2
0
        private void SetAttr(rpcCracker cracker, rpcPacker packer)
        {
            fhandle fh         = new fhandle(cracker);
            sattr   attributes = new sattr(cracker);

            FileEntry file = FileTable.LookupFileEntry(fh);

            if (file == null)
            {
                Console.WriteLine("Invalid file handle:{0}", fh.Index);
                throw new NFSStatusException(NFSStatus.NFSERR_STALE);
            }

            // TODO: Actually do something with the attributes.
            if (attributes.Size == 0)
            {
                try
                {
                    FileStream fs = new FileStream(file.Name, FileMode.Truncate, FileAccess.Write);
                    fs.Close();
                }
                catch (System.IO.FileNotFoundException)
                {
                    FileTable.Remove(fh);
                    throw;
                }
            }

            if ((int)attributes.Mode != -1)
            {
                FileInfo info = new FileInfo(FileTable.LookupFileEntry(fh).Name);

                if ((attributes.Mode & (uint)fattr.modes.WOWN) == (uint)fattr.modes.WOWN)
                {
                    info.Attributes = info.Attributes & ~FileAttributes.ReadOnly;
                }
                else
                {
                    info.Attributes = info.Attributes | FileAttributes.ReadOnly;
                }
            }

            attrstat.PackSuccess(packer, new fattr(fh));
        }
Example #3
0
        private void SymLink(rpcCracker cracker, rpcPacker packer)
        {
            diropargs	args	= new diropargs(cracker);
            string		path	= cracker.get_String();
            sattr		attr	= new sattr(cracker);

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

            Console.WriteLine("Symlink: {0}->{1}", createPath, path);

            fhandle fh;

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

            try
            {
                FileStream symlink = new FileStream(createPath, FileMode.CreateNew, FileAccess.Write);

                try
                {
                    UTF8Encoding pathUTF8 = new UTF8Encoding();

                    byte[] buf = pathUTF8.GetBytes(path);

                    symlink.Write(buf, 0, buf.Length);

                    packer.setUint32((uint)NFSStatus.NFS_OK);
                }
                finally
                {
                    symlink.Close();
                }
            }
            catch(IOException)
            {
                if (new FileInfo(createPath).Exists == true)
                    throw new NFSStatusException(NFSStatus.NFSERR_EXIST);
                else
                    throw;
            }
        }
Example #4
0
        private void SetAttr(rpcCracker cracker, rpcPacker packer)
        {
            fhandle	fh			= new fhandle(cracker);
            sattr	attributes	= new sattr(cracker);

            FileEntry file = FileTable.LookupFileEntry(fh);

            if (file == null)
            {
                Console.WriteLine("Invalid file handle:{0}", fh.Index);
                throw new NFSStatusException(NFSStatus.NFSERR_STALE);
            }

            // TODO: Actually do something with the attributes.
            if (attributes.Size == 0)
            {
                try
                {
                    FileStream fs = new FileStream(file.Name, FileMode.Truncate, FileAccess.Write);
                    fs.Close();
                }
                catch (System.IO.FileNotFoundException)
                {
                    FileTable.Remove(fh);
                    throw;
                }
            }

            if ((int)attributes.Mode != -1)
            {
                FileInfo info = new FileInfo(FileTable.LookupFileEntry(fh).Name);

                if ((attributes.Mode & (uint)fattr.modes.WOWN) == (uint)fattr.modes.WOWN)
                    info.Attributes = info.Attributes & ~FileAttributes.ReadOnly;
                else
                    info.Attributes = info.Attributes | FileAttributes.ReadOnly;
            }

            attrstat.PackSuccess(packer, new fattr(fh));
        }
Example #5
0
 public createargs(rpcCracker cracker)
 {
     where      = new diropargs(cracker);
     attributes = new sattr(cracker);
 }
Example #6
0
 public createargs(rpcCracker cracker)
 {
     where		= new diropargs(cracker);
     attributes	= new sattr(cracker);
 }