- java.lang.Object
-
- kala.compress.archivers.dump.DumpArchiveEntry
-
- All Implemented Interfaces:
ArchiveEntry
public class DumpArchiveEntry extends java.lang.Object implements ArchiveEntry
This class represents an entry in a Dump archive. It consists of the entry's header, the entry's File and any extended attributes.DumpEntries that are created from the header bytes read from an archive are instantiated with the DumpArchiveEntry( byte[] ) constructor. These entries will be used when extracting from or listing the contents of an archive. These entries have their header filled in using the header bytes. They also set the File to null, since they reference an archive entry not a file.
DumpEntries can also be constructed from nothing but a name. This allows the programmer to construct the entry by hand, for instance when only an InputStream is available for writing to the archive, and the header information is constructed from other information. In this case the header fields are set to defaults and the File is set to null.
The C structure for a Dump Entry's header is:
#define TP_BSIZE 1024 // size of each file block #define NTREC 10 // number of blocks to write at once #define HIGHDENSITYTREC 32 // number of blocks to write on high-density tapes #define TP_NINDIR (TP_BSIZE/2) // number if indirect inodes in record #define TP_NINOS (TP_NINDIR / sizeof (int32_t)) #define LBLSIZE 16 #define NAMELEN 64 #define OFS_MAGIC (int) 60011 // old format magic value #define NFS_MAGIC (int) 60012 // new format magic value #define FS_UFS2_MAGIC (int) 0x19540119 #define CHECKSUM (int) 84446 // constant used in checksum algorithm struct s_spcl { int32_t c_type; // record type (see below) int32_t c_date; // date of this dump int32_t c_ddate; // date of previous dump int32_t c_volume; // dump volume number u_int32_t c_tapea; // logical block of this record dump_ino_t c_ino; // number of inode int32_t c_magic; // magic number (see above) int32_t c_checksum; // record checksum #ifdef __linux__ struct new_bsd_inode c_dinode; #else #ifdef sunos struct new_bsd_inode c_dinode; #else struct dinode c_dinode; // ownership and mode of inode #endif #endif int32_t c_count; // number of valid c_addr entries union u_data c_data; // see above char c_label[LBLSIZE]; // dump label int32_t c_level; // level of this dump char c_filesys[NAMELEN]; // name of dumpped file system char c_dev[NAMELEN]; // name of dumpped device char c_host[NAMELEN]; // name of dumpped host int32_t c_flags; // additional information (see below) int32_t c_firstrec; // first record on volume int32_t c_ntrec; // blocksize on volume int32_t c_extattributes; // additional inode info (see below) int32_t c_spare[30]; // reserved for future uses } s_spcl; // // flag values // #define DR_NEWHEADER 0x0001 // new format tape header #define DR_NEWINODEFMT 0x0002 // new format inodes on tape #define DR_COMPRESSED 0x0080 // dump tape is compressed #define DR_METAONLY 0x0100 // only the metadata of the inode has been dumped #define DR_INODEINFO 0x0002 // [SIC] TS_END header contains c_inos information #define DR_EXTATTRIBUTES 0x8000 // // extattributes inode info // #define EXT_REGULAR 0 #define EXT_MACOSFNDRINFO 1 #define EXT_MACOSRESFORK 2 #define EXT_XATTR 3 // used for EA on tape #define EXT2_GOOD_OLD_INODE_SIZE 128 #define EXT2_XATTR_MAGIC 0xEA020000 // block EA #define EXT2_XATTR_MAGIC2 0xEA020001 // in inode EAThe fields in bold are the same for all blocks. (This permitted multiple dumps to be written to a single tape.)
The C structure for the inode (file) information is:
struct bsdtimeval { // **** alpha-*-linux is deviant __u32 tv_sec; __u32 tv_usec; }; #define NDADDR 12 #define NIADDR 3 // // This is the new (4.4) BSD inode structure // copied from the FreeBSD 2.0 <ufs/ufs/dinode.h> include file // struct new_bsd_inode { __u16 di_mode; // file type, standard UNIX permissions __s16 di_nlink; // number of hard links to file. union { __u16 oldids[2]; __u32 inumber; } di_u; u_quad_t di_size; // file size struct bsdtimeval di_atime; // time file was last accessed struct bsdtimeval di_mtime; // time file was last modified struct bsdtimeval di_ctime; // time file was created __u32 di_db[NDADDR]; __u32 di_ib[NIADDR]; __u32 di_flags; // __s32 di_blocks; // number of disk blocks __s32 di_gen; // generation number __u32 di_uid; // user id (see /etc/passwd) __u32 di_gid; // group id (see /etc/group) __s32 di_spare[2]; // unused };It is important to note that the header DOES NOT have the name of the file. It can't since hard links mean that you may have multiple file names for a single physical file. You must read the contents of the directory entries to learn the mapping(s) from file name to inode.
The C structure that indicates if a specific block is a real block that contains data or is a sparse block that is not persisted to the disk is:
#define TP_BSIZE 1024 #define TP_NINDIR (TP_BSIZE/2) union u_data { char s_addrs[TP_NINDIR]; // 1 => data; 0 => hole in inode int32_t s_inos[TP_NINOS]; // table of first inode on each volume } u_data;
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDumpArchiveEntry.PERMISSION(package private) static classDumpArchiveEntry.TapeSegmentHeaderArchive entry as stored on tape.static classDumpArchiveEntry.TYPE
-
Field Summary
Fields Modifier and Type Field Description private longatimeprivate longctimeprivate intgenerationprivate intgidprivate DumpArchiveEntry.TapeSegmentHeaderheaderThis value is available from the standard index.private intinoprivate booleanisDeletedprivate intmodeprivate longmtimeprivate java.lang.Stringnameprivate intnlinkprivate longoffsetprivate java.lang.StringoriginalNameprivate java.util.Set<DumpArchiveEntry.PERMISSION>permissionsprivate java.lang.StringsimpleNameprivate longsizeprivate DumpArchiveSummarysummaryCurrently unusedprivate DumpArchiveEntry.TYPEtypeprivate intuidprivate intvolumeThis value is available from the QFA index.-
Fields inherited from interface kala.compress.archivers.ArchiveEntry
SIZE_UNKNOWN
-
-
Constructor Summary
Constructors Modifier Constructor Description DumpArchiveEntry()Constructs a default instance.DumpArchiveEntry(java.lang.String name, java.lang.String simpleName)Constructs a new instance with only names.protectedDumpArchiveEntry(java.lang.String name, java.lang.String simpleName, int ino, DumpArchiveEntry.TYPE type)Constructs a new instance with name, inode and type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.nio.file.attribute.FileTimegetAccessTime()Returns the time the file was last accessed.java.nio.file.attribute.FileTimegetCreationTime()Gets file creation time.(package private) longgetEntrySize()Returns the size of the entry as read from the archive.intgetGeneration()Gets the generation of the file.intgetGroupId()Gets the group idintgetHeaderCount()Gets the number of records in this segment.intgetHeaderHoles()Gets the number of sparse records in this segment.DumpArchiveConstants.SEGMENT_TYPEgetHeaderType()Gets the type of the tape segment header.intgetIno()Returns the ino of the entry.java.nio.file.attribute.FileTimegetLastModifiedTime()Gets the last modified time of this entry.intgetMode()Gets the access permissions on the entry.java.lang.StringgetName()Returns the name of the entry.intgetNlink()Gets the number of hard links to the entry.longgetOffset()Gets the offset within the archive(package private) java.lang.StringgetOriginalName()Returns the unmodified name of the entry.java.util.Set<DumpArchiveEntry.PERMISSION>getPermissions()Returns the permissions on the entry.java.lang.StringgetSimpleName()Returns the path of the entry.longgetSize()Returns the size of the entry.DumpArchiveEntry.TYPEgetType()Gets the type of the entry.intgetUserId()Gets the user id.intgetVolume()Gets the tape volume where this file is located.inthashCode()booleanisBlkDev()Is this a block device?booleanisChrDev()Is this a character device?booleanisDeleted()Has this file been deleted? (On valid on incremental dumps.)booleanisDirectory()Is this a directory?booleanisFifo()Is this a fifo/pipe?booleanisFile()Is this a regular file?booleanisSocket()Is this a network device?booleanisSparseRecord(int idx)Is this a sparse record?(package private) static DumpArchiveEntryparse(byte[] buffer)Populate the dump archive entry and tape segment header with the contents of the buffer.voidsetAccessTime(java.nio.file.attribute.FileTime atime)Sets the time the file was last accessed.voidsetCreationTime(java.nio.file.attribute.FileTime ctime)Sets the file creation time.voidsetDeleted(boolean isDeleted)Sets whether this file has been deleted.voidsetGeneration(int generation)Sets the generation of the file.voidsetGroupId(int gid)Sets the group id.voidsetLastModifiedTime(java.nio.file.attribute.FileTime mtime)Sets the time the file was last modified.voidsetMode(int mode)Sets the access permissions on the entry.voidsetName(java.lang.String name)Sets the name of the entry.voidsetNlink(int nlink)Sets the number of hard links.voidsetOffset(long offset)Sets the offset within the archive.protected voidsetSimpleName(java.lang.String simpleName)Sets the path of the entry.voidsetSize(long size)Sets the size of the entry.voidsetType(DumpArchiveEntry.TYPE type)Sets the type of the entry.voidsetUserId(int uid)Sets the user id.voidsetVolume(int volume)Sets the tape volume.java.lang.StringtoString()(package private) voidupdate(byte[] buffer)Update entry with information from next tape segment header.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface kala.compress.archivers.ArchiveEntry
resolveIn
-
-
-
-
Field Detail
-
name
private java.lang.String name
-
type
private DumpArchiveEntry.TYPE type
-
mode
private int mode
-
permissions
private java.util.Set<DumpArchiveEntry.PERMISSION> permissions
-
size
private long size
-
atime
private long atime
-
mtime
private long mtime
-
uid
private int uid
-
gid
private int gid
-
summary
private final DumpArchiveSummary summary
Currently unused
-
header
private final DumpArchiveEntry.TapeSegmentHeader header
This value is available from the standard index.
-
simpleName
private java.lang.String simpleName
-
originalName
private java.lang.String originalName
-
volume
private int volume
This value is available from the QFA index.
-
offset
private long offset
-
ino
private int ino
-
nlink
private int nlink
-
ctime
private long ctime
-
generation
private int generation
-
isDeleted
private boolean isDeleted
-
-
Constructor Detail
-
DumpArchiveEntry
public DumpArchiveEntry()
Constructs a default instance.
-
DumpArchiveEntry
public DumpArchiveEntry(java.lang.String name, java.lang.String simpleName)Constructs a new instance with only names.- Parameters:
name- path namesimpleName- actual file name.
-
DumpArchiveEntry
protected DumpArchiveEntry(java.lang.String name, java.lang.String simpleName, int ino, DumpArchiveEntry.TYPE type)Constructs a new instance with name, inode and type.- Parameters:
name- the namesimpleName- the simple nameino- the inotype- the type
-
-
Method Detail
-
parse
static DumpArchiveEntry parse(byte[] buffer)
Populate the dump archive entry and tape segment header with the contents of the buffer.- Parameters:
buffer- buffer to read content from
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
getAccessTime
public java.nio.file.attribute.FileTime getAccessTime()
Returns the time the file was last accessed.- Returns:
- the access time
- Since:
- 1.27.1-0
-
getCreationTime
public java.nio.file.attribute.FileTime getCreationTime()
Gets file creation time.- Returns:
- the creation time
- Since:
- 1.27.1-0
-
getEntrySize
long getEntrySize()
Returns the size of the entry as read from the archive.
-
getGeneration
public int getGeneration()
Gets the generation of the file.- Returns:
- the generation
-
getGroupId
public int getGroupId()
Gets the group id- Returns:
- the group id
-
getHeaderCount
public int getHeaderCount()
Gets the number of records in this segment.- Returns:
- the number of records
-
getHeaderHoles
public int getHeaderHoles()
Gets the number of sparse records in this segment.- Returns:
- the number of sparse records
-
getHeaderType
public DumpArchiveConstants.SEGMENT_TYPE getHeaderType()
Gets the type of the tape segment header.- Returns:
- the segment header
-
getIno
public int getIno()
Returns the ino of the entry.- Returns:
- the ino
-
getLastModifiedTime
public java.nio.file.attribute.FileTime getLastModifiedTime()
Description copied from interface:ArchiveEntryGets the last modified time of this entry.- Specified by:
getLastModifiedTimein interfaceArchiveEntry- Returns:
- the last modified time of this entry.
-
getMode
public int getMode()
Gets the access permissions on the entry.- Returns:
- the access permissions
-
getName
public java.lang.String getName()
Returns the name of the entry.This method returns the raw name as it is stored inside of the archive.
- Specified by:
getNamein interfaceArchiveEntry- Returns:
- the name of the entry.
-
getNlink
public int getNlink()
Gets the number of hard links to the entry.- Returns:
- the number of hard links
-
getOffset
public long getOffset()
Gets the offset within the archive- Returns:
- the offset
-
getOriginalName
java.lang.String getOriginalName()
Returns the unmodified name of the entry.- Returns:
- the name of the entry.
-
getPermissions
public java.util.Set<DumpArchiveEntry.PERMISSION> getPermissions()
Returns the permissions on the entry.- Returns:
- the permissions
-
getSimpleName
public java.lang.String getSimpleName()
Returns the path of the entry.- Returns:
- the path of the entry.
-
getSize
public long getSize()
Returns the size of the entry.- Specified by:
getSizein interfaceArchiveEntry- Returns:
- the size
-
getType
public DumpArchiveEntry.TYPE getType()
Gets the type of the entry.- Returns:
- the type
-
getUserId
public int getUserId()
Gets the user id.- Returns:
- the user id
-
getVolume
public int getVolume()
Gets the tape volume where this file is located.- Returns:
- the volume
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
isBlkDev
public boolean isBlkDev()
Is this a block device?- Returns:
- whether this is a block device
-
isChrDev
public boolean isChrDev()
Is this a character device?- Returns:
- whether this is a character device
-
isDeleted
public boolean isDeleted()
Has this file been deleted? (On valid on incremental dumps.)- Returns:
- whether the file has been deleted
-
isDirectory
public boolean isDirectory()
Is this a directory?- Specified by:
isDirectoryin interfaceArchiveEntry- Returns:
- whether this is a directory
-
isFifo
public boolean isFifo()
Is this a fifo/pipe?- Returns:
- whether this is a fifo
-
isFile
public boolean isFile()
Is this a regular file?- Returns:
- whether this is a regular file
-
isSocket
public boolean isSocket()
Is this a network device?- Returns:
- whether this is a socket
-
isSparseRecord
public boolean isSparseRecord(int idx)
Is this a sparse record?- Parameters:
idx- index of the record to check- Returns:
- whether this is a sparse record
-
setAccessTime
public void setAccessTime(java.nio.file.attribute.FileTime atime)
Sets the time the file was last accessed.- Parameters:
atime- the access time- Since:
- 1.27.1-0
-
setCreationTime
public void setCreationTime(java.nio.file.attribute.FileTime ctime)
Sets the file creation time.- Parameters:
ctime- the creation time- Since:
- 1.27.1-0
-
setDeleted
public void setDeleted(boolean isDeleted)
Sets whether this file has been deleted.- Parameters:
isDeleted- whether the file has been deleted
-
setGeneration
public void setGeneration(int generation)
Sets the generation of the file.- Parameters:
generation- the generation
-
setGroupId
public void setGroupId(int gid)
Sets the group id.- Parameters:
gid- the group id
-
setLastModifiedTime
public void setLastModifiedTime(java.nio.file.attribute.FileTime mtime)
Sets the time the file was last modified.- Parameters:
mtime- the last modified time- Since:
- 1.27.1-0
-
setMode
public void setMode(int mode)
Sets the access permissions on the entry.- Parameters:
mode- the access permissions
-
setName
public final void setName(java.lang.String name)
Sets the name of the entry.- Parameters:
name- the name
-
setNlink
public void setNlink(int nlink)
Sets the number of hard links.- Parameters:
nlink- the number of hard links
-
setOffset
public void setOffset(long offset)
Sets the offset within the archive.- Parameters:
offset- the offset
-
setSimpleName
protected void setSimpleName(java.lang.String simpleName)
Sets the path of the entry.- Parameters:
simpleName- the simple name
-
setSize
public void setSize(long size)
Sets the size of the entry.- Parameters:
size- the size
-
setType
public void setType(DumpArchiveEntry.TYPE type)
Sets the type of the entry.- Parameters:
type- the type
-
setUserId
public void setUserId(int uid)
Sets the user id.- Parameters:
uid- the user id
-
setVolume
public void setVolume(int volume)
Sets the tape volume.- Parameters:
volume- the volume
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
update
void update(byte[] buffer)
Update entry with information from next tape segment header.
-
-