ntfsclone --metadata also saves at least the first 8 KiB of the $LogFile
(Logical change 1.365)edge.strict_endians
parent
04c554b927
commit
61ea0f59d8
|
@ -7,6 +7,8 @@ xx/xx/2004 - 1.9.2-WIP
|
||||||
always available. (Yuval)
|
always available. (Yuval)
|
||||||
- Add conditional include of sys/param.h in endians.h which provides
|
- Add conditional include of sys/param.h in endians.h which provides
|
||||||
endianness support on Cygwin. (Yuval)
|
endianness support on Cygwin. (Yuval)
|
||||||
|
- ntfsclone --metadata also saves at least the first 8 KiB of the
|
||||||
|
$LogFile (Szaka)
|
||||||
|
|
||||||
05/04/2004 - 1.9.1 - Make mkntfs create bootable volumes and fixes/updates.
|
05/04/2004 - 1.9.1 - Make mkntfs create bootable volumes and fixes/updates.
|
||||||
- Update with SuSE 9.1 beta 1 versions of GNU build system.
|
- Update with SuSE 9.1 beta 1 versions of GNU build system.
|
||||||
|
|
|
@ -77,13 +77,12 @@ struct progress_bar {
|
||||||
float unit;
|
float unit;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __ntfs_walk_clusters_ctx {
|
typedef struct {
|
||||||
ntfs_inode *ni; /* inode being processed */
|
ntfs_inode *ni; /* inode being processed */
|
||||||
ntfs_attr_search_ctx *ctx; /* inode attribute being processed */
|
ntfs_attr_search_ctx *ctx; /* inode attribute being processed */
|
||||||
s64 inuse; /* number of clusters in use */
|
s64 inuse; /* number of clusters in use */
|
||||||
};
|
} ntfs_walk_clusters_ctx;
|
||||||
|
|
||||||
typedef struct __ntfs_walk_clusters_ctx ntfs_walk_clusters_ctx;
|
|
||||||
typedef int (ntfs_walk_op)(ntfs_inode *ni, void *data);
|
typedef int (ntfs_walk_op)(ntfs_inode *ni, void *data);
|
||||||
|
|
||||||
struct ntfs_walk_cluster {
|
struct ntfs_walk_cluster {
|
||||||
|
@ -349,18 +348,29 @@ static s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
|
||||||
return bm_bsize;
|
return bm_bsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_critical_metadata(ntfs_walk_clusters_ctx *image)
|
static s64 is_critical_metadata(ntfs_walk_clusters_ctx *image, runlist *rl)
|
||||||
{
|
{
|
||||||
s64 inode;
|
s64 inode = image->ni->mft_no;
|
||||||
|
|
||||||
inode = image->ni->mft_no;
|
|
||||||
|
|
||||||
if (inode <= LAST_METADATA_INODE)
|
if (inode <= LAST_METADATA_INODE) {
|
||||||
if (inode != FILE_LogFile)
|
if (inode != FILE_LogFile)
|
||||||
return 1;
|
return rl->length;
|
||||||
|
|
||||||
|
if (image->ctx->attr->type == AT_DATA) {
|
||||||
|
/* Save at least the first 8 KiB of FILE_LogFile */
|
||||||
|
s64 s = (s64)8192 - rl->vcn * vol->cluster_size;
|
||||||
|
if (s > 0) {
|
||||||
|
s = rounded_up_division(s, vol->cluster_size);
|
||||||
|
if (rl->length < s)
|
||||||
|
s = rl->length;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (image->ctx->attr->type != AT_DATA)
|
if (image->ctx->attr->type != AT_DATA)
|
||||||
return 1;
|
return rl->length;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -425,18 +435,18 @@ static void lseek_to_cluster(s64 lcn)
|
||||||
|
|
||||||
static void dump_clusters(ntfs_walk_clusters_ctx *image, runlist *rl)
|
static void dump_clusters(ntfs_walk_clusters_ctx *image, runlist *rl)
|
||||||
{
|
{
|
||||||
int i;
|
s64 i, len; /* number of clusters to copy */
|
||||||
|
|
||||||
if (opt.std_out)
|
if (opt.std_out || !opt.metadata_only)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!opt.metadata_only || !is_critical_metadata(image))
|
if (!(len = is_critical_metadata(image, rl)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lseek_to_cluster(rl->lcn);
|
lseek_to_cluster(rl->lcn);
|
||||||
|
|
||||||
/* FIXME: this could give pretty suboptimal performance */
|
/* FIXME: this could give pretty suboptimal performance */
|
||||||
for (i = 0; i < rl->length; i++)
|
for (i = 0; i < len; i++)
|
||||||
copy_cluster();
|
copy_cluster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue