Exemplo n.º 1
0
        public static PfsDinode32 ReadFromStream(Stream s)
        {
            var di = new PfsDinode32
            {
                Mode           = (InodeMode)s.ReadUInt16LE(),
                Nlink          = s.ReadUInt16LE(),
                Flags          = (InodeFlags)s.ReadUInt32LE(),
                Size           = s.ReadInt64LE(),
                SizeCompressed = s.ReadInt64LE(),
                Time1_sec      = s.ReadInt64LE(),
                Time2_sec      = s.ReadInt64LE(),
                Time3_sec      = s.ReadInt64LE(),
                Time4_sec      = s.ReadInt64LE(),
                Time1_nsec     = s.ReadUInt32LE(),
                Time2_nsec     = s.ReadUInt32LE(),
                Time3_nsec     = s.ReadUInt32LE(),
                Time4_nsec     = s.ReadUInt32LE(),
                Uid            = s.ReadUInt32LE(),
                Gid            = s.ReadUInt32LE(),
                Unk1           = s.ReadUInt64LE(),
                Unk2           = s.ReadUInt64LE(),
                Blocks         = s.ReadUInt32LE()
            };

            for (var i = 0; i < 12; i++)
            {
                di.db[i] = s.ReadInt32LE();
            }
            for (var i = 0; i < 5; i++)
            {
                di.ib[i] = s.ReadInt32LE();
            }
            return(di);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds inodes for each dir.
 /// </summary>
 void addDirInodes()
 {
     inodes.Add(root.ino);
     foreach (var dir in allDirs)
     {
         var ino = new PfsDinode32
         {
             Mode   = InodeMode.dir | InodeMode.rwx,
             Number = (uint)inodes.Count,
             Blocks = 1,
             Size   = 65536
         };
         dir.ino = ino;
         dir.Dirents.Add(new PfsDirent {
             Name = ".", InodeNumber = ino.Number, Type = 4
         });
         dir.Dirents.Add(new PfsDirent {
             Name = "..", InodeNumber = dir.Parent.ino.Number, Type = 5
         });
         dirents.Add(dir.Dirents);
         var dirent = new PfsDirent {
             Name = dir.name, InodeNumber = (uint)inodes.Count, Type = 3
         };
         dir.Parent.Dirents.Add(dirent);
         dir.Parent.ino.Nlink++;
         inodes.Add(ino);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds inodes for each file.
 /// </summary>
 void addFileInodes()
 {
     foreach (var file in allFiles)
     {
         var ino = new PfsDinode32
         {
             Mode           = InodeMode.file | InodeMode.rwx,
             Size           = file.Size,
             SizeCompressed = file.Size,
             Number         = (uint)inodes.Count,
             Blocks         = (uint)CeilDiv(file.Size, hdr.BlockSize)
         };
         file.ino = ino;
         var dirent = new PfsDirent {
             Name = file.name, Type = 2, InodeNumber = (uint)inodes.Count
         };
         file.Parent.Dirents.Add(dirent);
         inodes.Add(ino);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates inodes and dirents for superroot, flat_path_table, and uroot.
        /// Also, creates the root node for the FS tree.
        /// </summary>
        void SetupRootStructure()
        {
            inodes.Add(super_root_ino = new PfsDinode32
            {
                Mode  = InodeMode.dir | InodeMode.rx_only, Blocks = 1, Size = 65536, SizeCompressed = 65536, Nlink = 1, Number = 0,
                Flags = InodeFlags.@internal
            });
            inodes.Add(fpt_ino = new PfsDinode32
            {
                Mode = InodeMode.file | InodeMode.rwx, Blocks = 1, Number = 1, Flags = InodeFlags.@internal
            });
            var uroot_ino = new PfsDinode32 {
                Mode = InodeMode.dir | InodeMode.rwx, Number = 2, Size = 65536, SizeCompressed = 65536, Blocks = 1
            };

            super_root_dirents = new List <PfsDirent>
            {
                new PfsDirent {
                    InodeNumber = 1, Name = "flat_path_table", Type = 2
                },
                new PfsDirent {
                    InodeNumber = 2, Name = "uroot", Type = 3
                }
            };

            root = new FSDir
            {
                name    = "uroot",
                ino     = uroot_ino,
                Dirents = new List <PfsDirent>
                {
                    new PfsDirent {
                        Name = ".", Type = 4, InodeNumber = 2
                    },
                    new PfsDirent {
                        Name = "..", Type = 5, InodeNumber = 2
                    }
                }
            };
        }