예제 #1
0
파일: Ext2fsFuse.cs 프로젝트: CoryBR/Ext2VB
    protected override Errno OnReadDirectory(string directory, Mono.Fuse.OpenedPathInfo info, out System.Collections.Generic.IEnumerable<Mono.Fuse.DirectoryEntry> paths)
    {
        //Console.WriteLine("OnReadDirectory:" + directory);
        //Console.WriteLine("Handle: " + info.Handle);
        //Console.WriteLine("OpenFlags: " + info.OpenFlags);
        //Console.WriteLine("OpenAccess: " + info.OpenAccess);

        Ext2fsLib.Ext2FS.Inode inode1 = new Ext2fsLib.Ext2FS.Inode();
        Ext2fsLib.Ext2FS.Errors err = Ext2fs.GetPathInode(directory, ref inode1);
        if (err == Ext2fsLib.Ext2FS.Errors.NotFound)
        {
            paths = null;
            return Errno.ENOENT;
        }
        Ext2fsLib.Ext2FS.DirectoryEntry[] dir = Ext2fs.ListDirectory(inode1);
        //Dim d As Mono.Fuse.DirectoryEntry
        //Ext2fsLib.Ext2FS.DirectoryEntry dir1;
        List<Mono.Fuse.DirectoryEntry> d = new List<Mono.Fuse.DirectoryEntry>();
        foreach (Ext2fsLib.Ext2FS.DirectoryEntry dir1 in dir)
        {
            Mono.Fuse.DirectoryEntry d1 = new Mono.Fuse.DirectoryEntry(dir1.name);
            //Mono.Unix.Native.Stat stat1 = new Mono.Unix.Native.Stat();
            d.Add(d1);
            //Console.WriteLine(d1.Name);
        }
        paths = d;
        return 0;
    }
예제 #2
0
파일: Ext2fsFuse.cs 프로젝트: CoryBR/Ext2VB
 protected override Errno OnReadHandle(string file, Mono.Fuse.OpenedPathInfo info, byte[] buf, long offset, out int byteswritten)
 {
     Console.WriteLine("OnReadHandle: " + file);
     //Console.WriteLine("Handle: " + info.Handle);
     //Console.WriteLine("OpenFlags: " + info.OpenFlags);
     //Console.WriteLine("OpenAccess: " + info.OpenAccess);
     //Console.WriteLine("Read Offset: " + offset);
     Console.WriteLine("Read Length: " + buf.Length);
     byteswritten = 0;
     Ext2fsLib.Ext2FS.Inode inode1 = new Ext2fsLib.Ext2FS.Inode();
     Ext2fsLib.Ext2FS.Errors err = Ext2fs.GetPathInode(file,ref inode1);
     if (err == Ext2fsLib.Ext2FS.Errors.NotFound)
     {
         Console.WriteLine("Not Found");
         return Errno.ENOENT;
     }
     byteswritten = Ext2fs.ReadFileBytes(inode1, offset, ref buf);
     Console.WriteLine("Bytes Written: " + byteswritten);
     return 0;
 }
예제 #3
0
파일: Ext2fsFuse.cs 프로젝트: CoryBR/Ext2VB
    protected override Errno OnGetPathStatus(string path, out Stat stBuf)
    {
        try
        {
            //Console.WriteLine("OnGetPathStatus: " + path);
            stBuf = new Stat();
            //Console.WriteLine("stBuf Created");
            Ext2fsLib.Ext2FS.Inode inode1;
            inode1 = new Ext2fsLib.Ext2FS.Inode();
            //Console.WriteLine("Created inode1");
            Ext2fsLib.Ext2FS.Errors err;
            //Console.WriteLine("Created err");
            err = Ext2fs.GetPathInode(path,ref inode1);
          //Console.WriteLine("Got inode1");

          if (err == Ext2fsLib.Ext2FS.Errors.NotFound)
          {
              //Console.WriteLine("Not Found");
              return Errno.ENOENT;
          }
            //Console.WriteLine("InodeNum: " + inode1.inode_num);
            int x = inode1.i_mode;
            //Console.WriteLine(x);
            string x3 = (string)x.ToString("X");
            //Console.WriteLine(x3);
            string x2 = (string)x3[0].ToString();
            //Console.WriteLine(x3);
            //string FileMode = inode1.i_mode
            //Console.WriteLine(x2);
            switch (x2)
            {
                case "4":
                    stBuf.st_mode = NativeConvert.FromUnixPermissionString("dr-xr-xr-x");
                    break;
                case "8":
                    stBuf.st_mode = NativeConvert.FromUnixPermissionString("-r-xr-xr-x");
                    break;
                default:
                    stBuf.st_mode = NativeConvert.FromUnixPermissionString("----------");
                    break;
            }
            //Console.WriteLine("Inode Mode " + inode1.i_mode);
            stBuf.st_nlink = inode1.i_links_count;
            //Console.WriteLine("Permissions: " + NativeConvert.ToUnixPermissionString(stBuf.st_mode));
            //Console.WriteLine(stBuf.st_mode);
            stBuf.st_size = inode1.i_size;
            stBuf.st_atime = inode1.i_atime;
            stBuf.st_ctime = inode1.i_ctime;
            stBuf.st_mtime = inode1.i_mtime;
            stBuf.st_ino = inode1.inode_num;
            //Console.WriteLine("Nlink: " + stBuf.st_nlink);
            //stBuf.st_ino = inode1.inode_num;
            //stBuf.st_blksize = Ext2fs.Superblock.internal_block_size;
            //stBuf.st_blocks = inode1.i_blocks;
            return 0;
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.InnerException);
            Console.WriteLine(ex.StackTrace);
            Console.WriteLine(ex.TargetSite);
            stBuf = new Stat();
            return Errno.ENOENT;
        }
    }