Example #1
0
        public fattr(fhandle fh)
        {
            FileEntry file = FileTable.LookupFileEntry(fh);

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

            FileInfo fileInfo = new FileInfo(file.Name);

            if (fileInfo.Exists == false)
            {
                if (new DirectoryInfo(file.Name).Exists == false)
                {
                    throw new System.IO.FileNotFoundException();
                }
            }

            if ((fileInfo.Attributes & FileAttributes.Directory) != 0)
            {
                type      = ftype.NFDIR;
                mode     |= (uint)modes.DIR;
                size      = 4096;
                blocksize = 4096;
                blocks    = 8;
                atime     = new timeval(fileInfo.LastAccessTime);
                mtime     = new timeval(fileInfo.LastWriteTime);
            }
            else
            {
                if (fileInfo.Extension == ".sl")
                {
                    type |= ftype.NFLNK;
                    mode  = (uint)modes.LNK;
                }
                else
                {
                    type  = ftype.NFREG;
                    mode |= (uint)modes.REG;
                }

                size   = (uint)fileInfo.Length;
                blocks = (size / 4096) + (4096 - (size % 4096));
                atime  = new timeval(fileInfo.LastAccessTime);
                mtime  = new timeval(fileInfo.LastWriteTime);
            }

            if ((fileInfo.Attributes & FileAttributes.ReadOnly) == 0)
            {
                mode |= (uint)modes.WOWN;
            }

            fileid = fh.Index;

            //Console.WriteLine("fattr name:{0}, fileid:{1}, attrs:{2}, readonly:{3}", file.Name, fileid, fileInfo.Attributes, (fileInfo.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly);
        }
Example #2
0
 public void Insert_Ftype(string name,string describe,string maker)
 {
     ftype fty = new ftype();
     fty.fty_name = name;
     fty.fty_describe = describe;
     fty.fty_maker = maker;
     DateTime da = new DateTime();
     fty.fty_madetime = da;
     fty.fty_changetime = da;
     db.ftype.InsertOnSubmit(fty);
 }
Example #3
0
        public fattr(fhandle fh)
        {
            FileEntry file = FileTable.LookupFileEntry(fh);

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

            FileInfo fileInfo = new FileInfo(file.Name);

            if (fileInfo.Exists == false)
                if (new DirectoryInfo(file.Name).Exists == false)
                    throw new System.IO.FileNotFoundException();

            if ((fileInfo.Attributes & FileAttributes.Directory) != 0)
            {
                type = ftype.NFDIR;
                mode |= (uint)modes.DIR;
                size = 4096;
                blocksize = 4096;
                blocks = 8;
                atime = new timeval(fileInfo.LastAccessTime);
                mtime = new timeval(fileInfo.LastWriteTime);
            }
            else
            {
                if (fileInfo.Extension == ".sl")
                {
                    type |= ftype.NFLNK;
                    mode = (uint)modes.LNK;
                }
                else
                {
                    type = ftype.NFREG;
                    mode |= (uint)modes.REG;
                }

                size	= (uint)fileInfo.Length;
                blocks	= (size / 4096) + (4096 - (size % 4096));
                atime	= new timeval(fileInfo.LastAccessTime);
                mtime	= new timeval(fileInfo.LastWriteTime);
            }

            if ((fileInfo.Attributes & FileAttributes.ReadOnly) == 0)
                mode |= (uint)modes.WOWN;

            fileid = fh.Index;

            //Console.WriteLine("fattr name:{0}, fileid:{1}, attrs:{2}, readonly:{3}", file.Name, fileid, fileInfo.Attributes, (fileInfo.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly);
        }
Example #4
0
        /******************************
        ** 作者: LiuGuanPing
        ** 变更时间: 2011-12-20
        ******************************/
        #region ###新增因子类型
        public void Insert_Ftype(string name, string describe, string maker)
        {
            ftype fty = new ftype();

            fty.fty_name     = name;
            fty.fty_describe = describe;
            fty.fty_maker    = maker;
            DateTime da = new DateTime();

            fty.fty_madetime   = da;
            fty.fty_changetime = da;
            db.ftype.InsertOnSubmit(fty);
        }