public PosixFile(string fName) { this.SnapFullPath = fName; //this.Name = this.SnapFullPath.Substring(this.SnapFullPath.LastIndexOf('/')+1); ufi = new UnixFileInfo(this.SnapFullPath); this.Name = ufi.Name; this.Kind = GetUKind(); Console.WriteLine("file " + this.SnapFullPath + ", kind=" + this.Kind.ToString()); this.ID = ufi.Inode; //this.IsSparse = false; if (this.Kind == FileType.File) // though dirs also have sizes, useless to get it { this.FileSize = ufi.Length; } //this.LastAccessedTime = ufi.LastAccessTime; this.LastModifiedTime = Utilities.Utils.GetUtcUnixTime(ufi.LastWriteTimeUtc); //ufi.LastWriteTime.ToFileTimeUtc(); this.LastMetadataModifiedTime = Utilities.Utils.GetUtcUnixTime(ufi.LastStatusChangeTimeUtc); //ufi.LastStatusChangeTime.ToFileTimeUtc(); this.CreateTime = 0; // dummy value for correctness of incrementals using filecompare this.Permissions = (uint)ufi.FileAccessPermissions; this.SpecialAttributes = (int)ufi.FileSpecialAttributes; if (this.Kind == FileType.Symlink) { UnixSymbolicLinkInfo link = new UnixSymbolicLinkInfo(this.SnapFullPath); if (link.HasContents) { this.TargetName = link.GetContents().FullName; } } this.OwnerUser = (uint)ufi.OwnerUserId; this.OwnerGroup = (uint)ufi.OwnerGroupId; BlockMetadata = new FileBlockMetadata(); }
public NTBackupFile(Alphaleonis.Win32.Filesystem.FileSystemEntryInfo fsi) { fileName = fsi.FullPath; this.Name = fsi.FileName; fseInfo = fsi; this.Kind = GetKind(fsi); /*this.FileSize = 0; * try{ * this.FileSize += GetSize (); * } * catch(Exception e){ * Logger.Append(Severity.ERROR, "Unable to get size of item "+SnapFullPath+" "+e.Message); * throw(e); * }*/ this.FileSize = fsi.FileSize; if (this.Kind == FileType.Symlink) { this.TargetName = fsi.VirtualFullPath; } if (this.Kind != FileType.Directory || this.Kind != FileType.Unsupported) { this.LastModifiedTime = Utilities.Utils.GetUtcUnixTime(fsi.LastModified); //fsi.LastModified.ToFileTimeUtc(); } else { this.LastModifiedTime = DateTime.MaxValue.ToFileTimeUtc(); } this.LastMetadataModifiedTime = 0; // dummy value for correctness of incrementals using filecompare this.CreateTime = Utilities.Utils.GetUtcUnixTime(fsi.Created); //fsi.Created.ToFileTimeUtc(); GetHandleInfos(); if (fseInfo.IsMountPoint || fseInfo.IsReparsePoint || fseInfo.IsSymbolicLink) { //this.TargetName = fseInfo.VirtualFullPath; Console.WriteLine("** Item " + fileName + " is a " + this.Kind + ", target=" + TargetName); //Console.WriteLine ("reparsepoint tag(s)="+fsi.ReparsePointTag.ToString()); } if (this.Kind == FileType.Unsupported) { Console.WriteLine("unsupported file " + fileName + " with attributes " + fseInfo.Attributes.ToString()); } this.Attributes = (int)fsi.Attributes; //wSecurity = GetSecurity(); // unneeded as we save using BackupRead(), which includes security info //ownerUser = wSecurity.GetOwner(typeof(NTAccount)).; BlockMetadata = new FileBlockMetadata(); }
/*public BFile(){ * * }*/ public FreeBSDFile(string fN, long chunkStartPos) { fileName = fN; ufi = new UnixFileInfo(fN); this.chunkStartPos = chunkStartPos; this.fileSize = ufi.Length; unixPermissions = ufi.FileAccessPermissions; fileSpecialAttributes = (int)ufi.FileSpecialAttributes; fileAttributes = 0; fileKind = GetUKind(); ownerUser = ufi.OwnerUserId; ownerGroup = ufi.OwnerGroupId; BlockMetadata = new FileBlockMetadata(); }
public UnixFile(string fileName) { this.fileName = fileName; ufi = new UnixFileInfo(fileName); this.Name = ufi.Name; this.fileSize = ufi.Length; this.Permissions = (uint)ufi.FileAccessPermissions; fileSpecialAttributes = (int)ufi.FileSpecialAttributes; fileAttributes = 0; fileKind = GetUKind(); ownerUser = (uint)ufi.OwnerUserId; ownerGroup = (uint)ufi.OwnerGroupId; BlockMetadata = new FileBlockMetadata(); this.ExtendedAttributes = new List <Tuple <string, byte[]> >(); }
public MinimalFsItem(string name) { this.fileName = name; FileInfo fi = new FileInfo(fileName); this.FileSize = fi.Length; this.Name = fi.Name; this.ID = 0; this.ParentID = 0; this.LastMetadataModifiedTime = 0; this.LastModifiedTime = fi.LastWriteTimeUtc.ToFileTimeUtc(); this.CreateTime = fi.CreationTimeUtc.ToFileTimeUtc(); //this.Kind = GetKind(fi); this.Kind = FileType.File; BlockMetadata = new FileBlockMetadata(); }
protected UnixFile(SerializationInfo info, StreamingContext context) { /* this.ID = info.GetInt64("id"); * this.ParentID = info.GetInt64("pid");*/ /*this.Attributes = info.GetInt32("attrs"); * //this.CreateTime = info.GetInt64("crtime"); * this.LastMetadataModifiedTime = info.GetInt64("ctime"); * this.LastModifiedTime = info.GetInt64("mtime");*/ /*this.Kind = (Node.FileType)info.GetValue("k", typeof(Node.FileType)); * this.FileSize = info.GetInt64("s");*/ /*this.ChunkStartPos = info.GetUInt32("csp"); * this.FileStartPos = info.GetInt64("fsp"); * this.OwnerGroup = info.GetUInt32("og"); * this.OwnerUser = info.GetUInt32("ou"); * this.Permissions = (Mono.Unix.FileAccessPermissions)info.GetValue("perm", typeof(Node.FileType)); * this.SpecialAttributes = info.GetInt32("sattr");*/ this.BlockMetadata = (FileBlockMetadata)info.GetValue("data", typeof(FileBlockMetadata)); }
public PosixFile(Dirent entry) { unixEntry = entry; // used for clone() this.SnapFullPath = entry.d_name; this.Name = this.SnapFullPath.Substring(this.SnapFullPath.LastIndexOf('/') + 1); ID = (long)entry.d_ino; this.Kind = GetKind(entry); //this.IsSparse = false; // try to get ID version (inode generation number), for easier delete/move/renames detection // EOPNOTSUP = 95 Stat entryStat; if (this.Kind != FileType.Symlink) { //Syscall.fstat(fd, out entryStat); Syscall.stat(this.SnapFullPath, out entryStat); string[] xattrs = new string[16]; Syscall.listxattr(this.SnapFullPath, out xattrs); GetXattrs(xattrs); } else { Syscall.lstat(this.SnapFullPath, out entryStat); System.Text.StringBuilder sb = new System.Text.StringBuilder(2048); Syscall.readlink(this.SnapFullPath, sb); this.TargetName = sb.ToString(); //Console.WriteLine ("symlink pointing to "+targetName); } //this.LastAccessedTime = Utils.GetDateTimeFromUnixTime(entryStat.st_atime); this.LastMetadataModifiedTime = entryStat.st_ctime; this.LastModifiedTime = entryStat.st_mtime; this.CreateTime = 0; //DateTime.MinValue.ToFileTimeUtc(); this.Permissions = (uint)entryStat.st_mode; if (this.Kind == FileType.File) // though dirs also have sizes, useless to get it { this.FileSize = entryStat.st_size; } this.OwnerUser = entryStat.st_uid; this.OwnerGroup = entryStat.st_gid; this.SpecialAttributes = 0; // TODO!!! BlockMetadata = new FileBlockMetadata(); //Syscall.close(fd); }
protected PosixFile(SerializationInfo info, StreamingContext context) { //this.Attributes = info.GetInt32("attrs"); //Console.WriteLine ("PosixFile GetObjectData() : got attrs"); //this.CreateTime = info.GetInt64("crtime"); //this.LastMetadataModifiedTime = info.GetInt64("ctime"); //Console.WriteLine ("PosixFile GetObjectData() : got crtime & ctime"); //this.LastModifiedTime = info.GetInt64("mtime"); //Console.WriteLine ("PosixFile GetObjectData() : got mtime"); /*this.Kind = (Node.FileType)info.GetValue("k", typeof(Node.FileType)); * //Console.WriteLine ("PosixFile GetObjectData() : got k"); * this.FileSize = info.GetInt64("s");*/ //Console.WriteLine ("PosixFile GetObjectData() : got s"); //this.ChunkStartPos = info.GetUInt32("csp"); //Console.WriteLine ("PosixFile GetObjectData() : got csp"); //this.FileStartPos = info.GetInt64("fsp"); //Console.WriteLine ("PosixFile GetObjectData() : got fsp"); //this.OwnerGroup = info.GetUInt32("og"); //Console.WriteLine ("PosixFile GetObjectData() : got og"); //this.OwnerUser = info.GetUInt32("ou"); //Console.WriteLine ("PosixFile GetObjectData() : got ou"); //this.Permissions = (Mono.Unix.FileAccessPermissions)info.GetValue("perm", typeof(Mono.Unix.FileAccessPermissions)); //Console.WriteLine ("PosixFile GetObjectData() : got perm"); //this.SpecialAttributes = info.GetInt32("sattr"); //Console.WriteLine ("PosixFile GetObjectData() : getting xattrs.."); try{ this.ExtendedAttributes = (List <Tuple <string, byte[]> >)info.GetValue("xattr", typeof(List <Tuple <string, byte[]> >)); }catch {} //Console.WriteLine ("PosixFile GetObjectData() : getting blockmetadata (excepted dedupinfo).."); try{ this.BlockMetadata = new FileBlockMetadata(); this.BlockMetadata.BlockMetadata = (List <IFileBlockMetadata>)info.GetValue("data", typeof(List <IFileBlockMetadata>)); }catch { } try{ this.TargetName = (string)info.GetValue("tgt", typeof(string)); }catch {} }
protected NTBackupFile(SerializationInfo info, StreamingContext context) { /*this.ID = info.GetInt64("id"); * //Console.WriteLine ("PosixFile GetObjectData() : got id"); * this.ParentID = info.GetInt64("pid");*/ //Console.WriteLine ("PosixFile GetObjectData() : got pid"); //this.Attributes = info.GetInt32("attrs"); //Console.WriteLine ("PosixFile GetObjectData() : got attrs"); //this.CreateTime = info.GetInt64("crtime"); //this.LastMetadataModifiedTime = info.GetInt64("ctime"); //Console.WriteLine ("PosixFile GetObjectData() : got crtime & ctime"); //this.LastModifiedTime = info.GetInt64("mtime"); //Console.WriteLine ("PosixFile GetObjectData() : got mtime"); //this.Kind = (Node.FileType)info.GetValue("k", typeof(Node.FileType)); //Console.WriteLine ("PosixFile GetObjectData() : got k"); //this.FileSize = info.GetInt64("s"); //Console.WriteLine ("PosixFile GetObjectData() : got s"); //this.ChunkStartPos = info.GetUInt32("csp"); //Console.WriteLine ("PosixFile GetObjectData() : got csp"); //this.FileStartPos = info.GetInt64("fsp"); //Console.WriteLine ("PosixFile GetObjectData() : got fsp"); //this.OwnerGroup = info.GetUInt32("og"); //Console.WriteLine ("PosixFile GetObjectData() : got og"); //this.OwnerUser = info.GetUInt32("ou"); //Console.WriteLine ("PosixFile GetObjectData() : got ou"); //this.Permissions = info.GetInt32("perm"); //Console.WriteLine ("PosixFile GetObjectData() : got perm"); //this.SpecialAttributes = info.GetInt32("sattr"); try{ this.TargetName = info.GetString("tgt"); }catch {} // target is null, nothing wrong with that if not a symlink/reparsepoint Console.WriteLine("PosixFile GetObjectData() : getting blockmetadata (excepted dedupinfo).."); try{ this.BlockMetadata = new FileBlockMetadata(); this.BlockMetadata.BlockMetadata = (List <IFileBlockMetadata>)info.GetValue("data", typeof(List <IFileBlockMetadata>)); }catch { } // data is null, nothing wrong with that }
public NTBackupFile() { BlockMetadata = new FileBlockMetadata(); }
public NTBackupFile(string fullName) { if (fullName == null) { throw new Exception("NTBackupFileXP(byname): NULL name"); } //Console.WriteLine ("NTBackupFile(byname): raw name="+fullName); Alphaleonis.Win32.Filesystem.FileInfo fsi = new Alphaleonis.Win32.Filesystem.FileInfo(fullName); fsi.Refresh(); fseInfo = fsi.SystemInfo; fseInfo.FullPath = fullName; this.Name = fsi.Name; fileName = fullName; GetHandleInfos(); // gets ID and sparse attribute. //this.fileSize = fileI.Length; this.FileStartPos = 0; this.ChunkStartPos = 0; this.Kind = GetKind(fseInfo); // GetSize is more precise (though not yet 100%) but slower. As we will generally work on snapshot, // don't be so obsessed with getting real size and reporting sizes changes during backup on NT. //GetSize (); this.FileSize = fseInfo.FileSize; if (this.Kind == FileType.Symlink) { this.TargetName = fsi.SystemInfo.VirtualFullPath; } if (this.Kind != FileType.Directory || this.Kind != FileType.Unsupported) { this.LastModifiedTime = Utilities.Utils.GetUtcUnixTime(fsi.LastWriteTime); // fsi.LastWriteTime.ToFileTimeUtc(); } else { this.LastModifiedTime = 0; //fsi.LastWriteTime.ToFileTimeUtc(); //DateTime.MaxValue.ToFileTimeUtc(); } this.LastMetadataModifiedTime = 0; // dummy value for correctness of incrementals using filecompare this.CreateTime = Utilities.Utils.GetUtcUnixTime(fsi.CreationTime); //fsi.CreationTime.ToFileTimeUtc(); //this.ID = Utilities.Utils.GetUnixTime(fsi.CreationTime); if (fsi.Attributes.HasFlag(Alphaleonis.Win32.Filesystem.FileAttributes.SparseFile)) { this.ChangeStatus |= DataLayoutInfos.SparseFile; } if (fseInfo.IsMountPoint || fseInfo.IsReparsePoint || fseInfo.IsSymbolicLink) { this.TargetName = fseInfo.VirtualFullPath; Console.WriteLine("** Item " + fileName + " is a " + this.Kind); Console.WriteLine("reparsepoint tag(s)=" + fsi.SystemInfo.ReparsePointTag.ToString()); } if (this.Kind == FileType.Unsupported) { Console.WriteLine("unsupported file " + fileName + " with attributes " + fseInfo.Attributes.ToString()); } this.Attributes = (int)fsi.Attributes; //wSecurity = GetSecurity(); // unneeded as we save using BackupRead(), which includes security info //ownerUser = wSecurity.GetOwner(typeof(NTAccount)).; BlockMetadata = new FileBlockMetadata(); }
public PosixFile() { BlockMetadata = new FileBlockMetadata(); }
public FreeBSDFile(string fileName) { this.fileName = fileName; //ufi = new UnixFileInfo(fileName); BlockMetadata = new FileBlockMetadata(); }