Changes by: flatcap
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2642/ntfsprogs
Modified Files:
mkntfs.c ntfscat.c ntfsclone.c ntfscluster.c ntfscluster.h
ntfscp.c ntfsdump_logfile.c ntfsfix.c ntfsinfo.c ntfsmove.c
ntfsresize.c ntfsrm.c ntfsrm.h ntfstruncate.c ntfsundelete.c
ntfswipe.c sd.c
Log Message:
Tidy whitespace: trailing space; <space><tab> at the beginning of lines
Fix warnings about sign differences
Fix warnings about unused parameters
Tidy a few functions that didn't have { on a new line
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/mkntfs.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -p -r1.57 -r1.58
--- mkntfs.c 6 Jun 2005 14:29:47 -0000 1.57
+++ mkntfs.c 19 Jun 2005 21:09:41 -0000 1.58
@@ -135,8 +135,7 @@ switch if you want to be able to build t
extern const unsigned char attrdef_ntfs12_array[2400];
extern const unsigned char boot_array[3429];
-extern void init_system_file_sd(int sys_file_no, char **sd_val,
- int *sd_val_len);
+extern void init_system_file_sd(int sys_file_no, u8 **sd_val, int *sd_val_len);
extern void init_upcase_table(ntfschar *uc, u32 uc_len);
/* Page size on ia32. Can change to 8192 on Alpha. */
@@ -145,13 +144,13 @@ extern void init_upcase_table(ntfschar *
const char *EXEC_NAME = "mkntfs";
/* Need these global so mkntfs_exit can access them. */
-char *buf = NULL;
-char *buf2 = NULL;
+u8 *buf = NULL;
+u8 *buf2 = NULL;
int buf2_size = 0;
int mft_bitmap_size, mft_bitmap_byte_size;
-unsigned char *mft_bitmap = NULL;
+u8 *mft_bitmap = NULL;
int lcn_bitmap_byte_size;
-unsigned char *lcn_bitmap = NULL;
+u8 *lcn_bitmap = NULL;
runlist *rl_mft = NULL, *rl_mft_bmp = NULL, *rl_mftmirr = NULL;
runlist *rl_logfile = NULL, *rl_boot = NULL, *rl_bad = NULL, *rl_index;
INDEX_ALLOCATION *index_block = NULL;
@@ -174,7 +173,7 @@ struct {
long long logfile_lcn; /* lcn of $LogFile, $DATA. */
int logfile_size; /* in bytes, determined from
volume_size. */
- int mft_zone_multiplier; /* -z, value from 1 to 4. Default is
+ int mft_zone_multiplier; /* -z, value from 1 to 4. Default is
1. */
long long mft_zone_end; /* Determined from volume_size and
mft_zone_multiplier, in clusters. */
@@ -251,7 +250,7 @@ GEN_PRINTF(Qprintf, stdout, &opts.quiet,
/**
* err_exit - error output and terminate; ignores quiet (-q)
*/
-static void err_exit(const char *fmt, ...)
+static void err_exit(const char *fmt, ...)
__attribute__((noreturn))
__attribute__((format(printf, 1, 2)));
static void err_exit(const char *fmt, ...)
@@ -520,7 +519,7 @@ static __inline__ long long mkntfs_write
* Note: Might not return.
*/
static s64 ntfs_rlwrite(struct ntfs_device *dev, const runlist *rl,
- const char *val, const s64 val_len, s64 *inited_size)
+ const u8 *val, const s64 val_len, s64 *inited_size)
{
s64 bytes_written, total, length, delta;
int retry, i;
@@ -1191,7 +1190,7 @@ err_end:
static int insert_positioned_attr_in_mft_record(MFT_RECORD *m,
const ATTR_TYPES type, const char *name, u32 name_len,
const IGNORE_CASE_BOOL ic, const ATTR_FLAGS flags,
- const runlist *rl, const char *val, const s64 val_len)
+ const runlist *rl, const u8 *val, const s64 val_len)
{
ntfs_attr_search_ctx *ctx;
ATTR_RECORD *a;
@@ -1376,7 +1375,7 @@ err_out:
static int insert_non_resident_attr_in_mft_record(MFT_RECORD *m,
const ATTR_TYPES type, const char *name, u32 name_len,
const IGNORE_CASE_BOOL ic, const ATTR_FLAGS flags,
- const char *val, const s64 val_len)
+ const u8 *val, const s64 val_len)
{
ntfs_attr_search_ctx *ctx;
ATTR_RECORD *a;
@@ -1568,7 +1567,7 @@ static int insert_resident_attr_in_mft_r
const ATTR_TYPES type, const char *name, u32 name_len,
const IGNORE_CASE_BOOL ic, const ATTR_FLAGS flags,
const RESIDENT_ATTR_FLAGS res_flags,
- const char *val, const u32 val_len)
+ const u8 *val, const u32 val_len)
{
ntfs_attr_search_ctx *ctx;
ATTR_RECORD *a;
@@ -1698,7 +1697,7 @@ static int add_attr_std_info(MFT_RECORD
}
/* NTFS 1.2: size of si = 48, NTFS 3.0: size of si = 72 */
err = insert_resident_attr_in_mft_record(m, AT_STANDARD_INFORMATION,
- NULL, 0, 0, 0, 0, (char*)&si,
+ NULL, 0, 0, 0, 0, (u8*)&si,
vol->major_ver < 3 ? 48 : 72);
if (err < 0)
Eprintf("add_attr_std_info failed: %s\n", strerror(-err));
@@ -1778,7 +1777,7 @@ static int add_attr_file_name(MFT_RECORD
fn->file_name_length = i;
fn_size = sizeof(FILE_NAME_ATTR) + i * sizeof(ntfschar);
i = insert_resident_attr_in_mft_record(m, AT_FILE_NAME, NULL, 0, 0,
- 0, RESIDENT_ATTR_IS_INDEXED, (char*)fn, fn_size);
+ 0, RESIDENT_ATTR_IS_INDEXED, (u8*)fn, fn_size);
free(fn);
if (i < 0)
Eprintf("add_attr_file_name failed: %s\n", strerror(-i));
@@ -1792,7 +1791,7 @@ static int add_attr_file_name(MFT_RECORD
*
* Return 0 on success or -errno on error.
*/
-static int add_attr_sd(MFT_RECORD *m, const char *sd, const s64 sd_len)
+static int add_attr_sd(MFT_RECORD *m, const u8 *sd, const s64 sd_len)
{
int err;
@@ -1817,7 +1816,7 @@ static int add_attr_sd(MFT_RECORD *m, co
*/
static int add_attr_data(MFT_RECORD *m, const char *name, const u32 name_len,
const IGNORE_CASE_BOOL ic, const ATTR_FLAGS flags,
- const char *val, const s64 val_len)
+ const u8 *val, const s64 val_len)
{
int err;
@@ -1857,7 +1856,7 @@ static int add_attr_data(MFT_RECORD *m,
static int add_attr_data_positioned(MFT_RECORD *m, const char *name,
const u32 name_len, const IGNORE_CASE_BOOL ic,
const ATTR_FLAGS flags, const runlist *rl,
- const char *val, const s64 val_len)
+ const u8 *val, const s64 val_len)
{
int err;
@@ -1904,7 +1903,7 @@ static int add_attr_vol_name(MFT_RECORD
len = 0;
}
i = insert_resident_attr_in_mft_record(m, AT_VOLUME_NAME, NULL, 0, 0,
- 0, 0, (char*)uname, len);
+ 0, 0, (u8*)uname, len);
if (uname)
free(uname);
if (i < 0)
@@ -1927,7 +1926,7 @@ static int add_attr_vol_info(MFT_RECORD
vi.minor_ver = minor_ver;
vi.flags = flags & VOLUME_FLAGS_MASK;
err = insert_resident_attr_in_mft_record(m, AT_VOLUME_INFORMATION, NULL,
- 0, 0, 0, 0, (char*)&vi, sizeof(vi));
+ 0, 0, 0, 0, (u8*)&vi, sizeof(vi));
if (err < 0)
Eprintf("add_attr_vol_info failed: %s\n", strerror(-err));
return err;
@@ -2006,7 +2005,7 @@ static int add_attr_index_root(MFT_RECOR
e->flags = INDEX_ENTRY_END;
e->reserved = cpu_to_le16(0);
err = insert_resident_attr_in_mft_record(m, AT_INDEX_ROOT, name,
- name_len, ic, 0, 0, (char*)r, val_len);
+ name_len, ic, 0, 0, (u8*)r, val_len);
free(r);
if (err < 0)
Eprintf("add_attr_index_root failed: %s\n", strerror(-err));
@@ -2019,7 +2018,7 @@ static int add_attr_index_root(MFT_RECOR
*/
static int add_attr_index_alloc(MFT_RECORD *m, const char *name,
const u32 name_len, const IGNORE_CASE_BOOL ic,
- const char *index_alloc_val, const u32 index_alloc_val_len)
+ const u8 *index_alloc_val, const u32 index_alloc_val_len)
{
int err;
@@ -2036,7 +2035,7 @@ static int add_attr_index_alloc(MFT_RECO
* Return 0 on success or -errno on error.
*/
static int add_attr_bitmap(MFT_RECORD *m, const char *name, const u32 name_len,
- const IGNORE_CASE_BOOL ic, const char *bitmap,
+ const IGNORE_CASE_BOOL ic, const u8 *bitmap,
const u32 bitmap_len)
{
int err;
@@ -2065,7 +2064,7 @@ static int add_attr_bitmap(MFT_RECORD *m
*/
static int add_attr_bitmap_positioned(MFT_RECORD *m, const char *name,
const u32 name_len, const IGNORE_CASE_BOOL ic,
- const runlist *rl, const char *bitmap, const u32 bitmap_len)
+ const runlist *rl, const u8 *bitmap, const u32 bitmap_len)
{
int err;
@@ -2095,7 +2094,7 @@ static int upgrade_to_large_index(MFT_RE
INDEX_ENTRY *re;
INDEX_ALLOCATION *ia_val = NULL;
ntfschar *uname;
- char bmp[8];
+ u8 bmp[8];
char *re_start, *re_end;
int i, err, index_block_size;
@@ -2147,7 +2146,7 @@ static int upgrade_to_large_index(MFT_RE
memset(bmp, 0, sizeof(bmp));
ntfs_bit_set(bmp, 0ULL, 1);
/* Bitmap has to be at least 8 bytes in size. */
- err = add_attr_bitmap(m, name, name_len, ic, (char*)&bmp, sizeof(bmp));
+ err = add_attr_bitmap(m, name, name_len, ic, bmp, sizeof(bmp));
if (err)
goto err_out;
ia_val = calloc(1, index_block_size);
@@ -2224,7 +2223,7 @@ static int upgrade_to_large_index(MFT_RE
"upgrade_to_large_index.\n");
goto err_out;
}
- err = add_attr_index_alloc(m, name, name_len, ic, (char*)ia_val,
+ err = add_attr_index_alloc(m, name, name_len, ic, (u8*)ia_val,
index_block_size);
ntfs_mst_post_write_fixup((NTFS_RECORD*)ia_val);
if (err) {
@@ -2491,7 +2490,7 @@ static int create_hardlink(INDEX_BLOCK *
m_file->link_count = cpu_to_le16(i + 1);
/* Add the file_name to @m_file. */
i = insert_resident_attr_in_mft_record(m_file, AT_FILE_NAME, NULL, 0, 0,
- 0, RESIDENT_ATTR_IS_INDEXED, (char*)fn, fn_size);
+ 0, RESIDENT_ATTR_IS_INDEXED, (u8*)fn, fn_size);
if (i < 0) {
Eprintf("create_hardlink failed adding file name attribute: "
"%s\n", strerror(-i));
@@ -2883,7 +2882,7 @@ static void mkntfs_override_phys_params(
static void mkntfs_initialize_bitmaps(void)
{
int i, j;
-
+
/* Determine lcn bitmap byte size and allocate it. */
lcn_bitmap_byte_size = (opts.nr_clusters + 7) >> 3;
/* Needs to be multiple of 8 bytes. */
@@ -2949,7 +2948,7 @@ static void mkntfs_initialize_bitmaps(vo
static void mkntfs_initialize_rl_mft(void)
{
int i, j;
-
+
/* If user didn't specify the mft lcn, determine it now. */
if (!opts.mft_lcn) {
/*
@@ -3224,7 +3223,7 @@ static void mkntfs_fill_device_with_zero
static void create_file_volume(MFT_RECORD *m, MFT_REF root_ref, VOLUME_FLAGS fl)
{
int i, err;
- char *sd;
+ u8 *sd;
Vprintf("Creating $Volume (mft record 3)\n");
m = (MFT_RECORD*)(buf + 3 * vol->mft_record_size);
@@ -3256,7 +3255,7 @@ static void create_file_volume(MFT_RECOR
*
* Return 0 on success or 1 if it couldn't be created.
*/
-static int create_backup_boot_sector(char *buff, int size)
+static int create_backup_boot_sector(u8 *buff, int size)
{
ssize_t bw;
int _e = errno;
@@ -3304,7 +3303,7 @@ static void mkntfs_create_root_structure
MFT_RECORD *m;
MFT_REF root_ref;
int i, j, err;
- char *sd;
+ u8 *sd;
VOLUME_FLAGS volume_flags = 0;
Qprintf("Creating NTFS volume structures.\n");
@@ -3473,7 +3472,7 @@ static void mkntfs_create_root_structure
buf2_size = 36000;
else
buf2_size = opts.attr_defs_len;
- buf2 = (char*)calloc(1, buf2_size);
+ buf2 = calloc(1, buf2_size);
if (!buf2)
err_exit("Failed to allocate internal buffer: %s\n",
strerror(errno));
@@ -3598,7 +3597,7 @@ static void mkntfs_create_root_structure
}
if (err < 0)
err_exit("Couldn't create $Boot: %s\n", strerror(-err));
-
+
if (create_backup_boot_sector(buf2, i) != 0) {
/*
* Pre-2.6 kernels couldn't access the last sector
@@ -3651,7 +3650,7 @@ static void mkntfs_create_root_structure
//dump_mft_record(m);
Vprintf("Creating $UpCase (mft record 0xa)\n");
m = (MFT_RECORD*)(buf + 0xa * vol->mft_record_size);
- err = add_attr_data(m, NULL, 0, 0, 0, (char*)vol->upcase,
+ err = add_attr_data(m, NULL, 0, 0, 0, (u8*)vol->upcase,
vol->upcase_len << 1);
if (!err)
err = create_hardlink(index_block, root_ref, m,
@@ -3790,7 +3789,7 @@ int main(int argc, char **argv)
if (err)
err_exit("ntfs_mst_pre_write_fixup() failed while syncing "
"root directory index block.\n");
- lw = ntfs_rlwrite(vol->dev, rl_index, (char*)index_block, i, NULL);
+ lw = ntfs_rlwrite(vol->dev, rl_index, (u8*)index_block, i, NULL);
if (lw != i)
err_exit("Error writing $INDEX_ALLOCATION.\n");
/* No more changes to @index_block below here so no need for fixup: */
Index: ntfscat.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfscat.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -p -r1.14 -r1.15
--- ntfscat.c 12 Jun 2005 18:12:56 -0000 1.14
+++ ntfscat.c 19 Jun 2005 21:09:41 -0000 1.15
@@ -215,7 +215,7 @@ static int cat (ntfs_volume *vol __attri
int namelen __attribute__((unused)))
{
/* increase 1024 only if you fix partial writes below */
- const int bufsize = 1024;
+ const int bufsize = 1024;
char *buffer;
ntfs_attr *attr;
s64 bytes_read, written;
@@ -279,25 +279,25 @@ int main (int argc, char *argv[])
vol = utils_mount_volume (opts.device, MS_RDONLY, opts.force);
if (!vol) {
- perror("ERROR: couldn't mount volume");
+ perror("ERROR: couldn't mount volume");
return 1;
}
- if (opts.inode != -1)
- inode = ntfs_inode_open (vol, opts.inode);
- else
- inode = ntfs_pathname_to_inode (vol, NULL, opts.file);
+ if (opts.inode != -1)
+ inode = ntfs_inode_open (vol, opts.inode);
+ else
+ inode = ntfs_pathname_to_inode (vol, NULL, opts.file);
if (!inode) {
- perror("ERROR: Couldn't open inode");
+ perror("ERROR: Couldn't open inode");
return 1;
}
- attr = AT_DATA;
- if (opts.attr != (ATTR_TYPES)-1)
- attr = opts.attr;
-
- result = cat (vol, inode, attr, NULL, 0);
+ attr = AT_DATA;
+ if (opts.attr != (ATTR_TYPES)-1)
+ attr = opts.attr;
+
+ result = cat (vol, inode, attr, NULL, 0);
ntfs_inode_close (inode);
ntfs_umount (vol, FALSE);
Index: ntfsclone.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsclone.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -p -r1.44 -r1.45
--- ntfsclone.c 12 Jun 2005 14:35:57 -0000 1.44
+++ ntfsclone.c 19 Jun 2005 21:09:41 -0000 1.45
@@ -60,7 +60,7 @@ struct {
int force;
int overwrite;
int std_out;
- int blkdev_out; /* output file is block device */
+ int blkdev_out; /* output file is block device */
int metadata_only;
int ignore_fs_check;
int rescue;
@@ -300,7 +300,7 @@ static void parse_options(int argc, char
usage();
}
}
-
+
if (opt.output == NULL) {
err_printf("You must specify an output file.\n");
usage();
@@ -321,7 +321,7 @@ static void parse_options(int argc, char
if (opt.metadata_only && opt.restore_image)
err_exit("Restoring only metadata from an image is not "
"supported!\n");
-
+
if (opt.metadata_only && opt.std_out)
err_exit("Cloning only metadata to stdout isn't supported!\n");
@@ -332,13 +332,13 @@ static void parse_options(int argc, char
if (opt.save_image && opt.restore_image)
err_exit("Saving and restoring an image at the same time "
"is not supported!\n");
-
+
if (!opt.std_out) {
struct stat st;
-
+
if (stat(opt.output, &st) == -1) {
if (errno != ENOENT)
- perr_exit("Couldn't access '%s'", opt.output);
+ perr_exit("Couldn't access '%s'", opt.output);
} else {
if (!opt.overwrite)
err_exit("Output file '%s' already exists.\n"
@@ -352,16 +352,16 @@ static void parse_options(int argc, char
"block device isn't supported!\n");
}
}
- }
-
+ }
+
msg_out = stdout;
-
+
/* FIXME: this is a workaround for loosing debug info if stdout != stderr
and for the uncontrollable verbose messages in libntfs. Ughhh. */
if (opt.std_out)
msg_out = stderr;
else if (opt.debug)
- stderr = stdout;
+ stderr = stdout;
else
if (!(stderr = fopen("/dev/null", "rw")))
perr_exit("Couldn't open /dev/null");
@@ -413,7 +413,7 @@ static s64 is_critical_metadata(ntfs_wal
s64 inode = image->ni->mft_no;
if (inode <= LAST_METADATA_INODE) {
-
+
/* Don't save bad sectors (both $Bad and unnamed are ignored */
if (inode == FILE_BadClus && image->ctx->attr->type == AT_DATA)
return 0;
@@ -434,7 +434,7 @@ static s64 is_critical_metadata(ntfs_wal
return 0;
}
}
-
+
if (image->ctx->attr->type != AT_DATA)
return rl->length;
@@ -446,7 +446,7 @@ static int io_all(void *fd, void *buf, i
{
int i;
struct ntfs_device *dev = fd;
-
+
while (count > 0) {
if (do_write)
i = write(*(int *)fd, buf, count);
@@ -494,7 +494,7 @@ static void copy_cluster(int rescue, off
/* vol is NULL if opt.restore_image is set */
u32 csize = image_hdr.cluster_size;
void *fd = (void *)&fd_in;
-
+
if (!opt.restore_image) {
csize = vol->cluster_size;
fd = vol->dev;
@@ -516,7 +516,7 @@ static void copy_cluster(int rescue, off
if (write_all(&fd_out, &cmd, sizeof(cmd)) == -1)
perr_exit("write_all");
}
-
+
if (write_all(&fd_out, buff, csize) == -1) {
int err = errno;
perr_printf("Write failed");
@@ -532,9 +532,9 @@ static void copy_cluster(int rescue, off
static void lseek_to_cluster(s64 lcn)
{
off_t pos;
-
+
pos = (off_t)(lcn * vol->cluster_size);
-
+
if (vol->dev->d_ops->seek(vol->dev, pos, SEEK_SET) == (off_t)-1)
perr_exit("lseek input");
@@ -552,7 +552,7 @@ static void image_skip_clusters(s64 coun
buff[0] = 0;
memcpy(buff + 1, &count, sizeof(count));
-
+
if (write_all(&fd_out, buff, sizeof(buff)) == -1)
perr_exit("write_all");
}
@@ -561,15 +561,15 @@ static void image_skip_clusters(s64 coun
static void dump_clusters(ntfs_walk_clusters_ctx *image, runlist *rl)
{
s64 i, len; /* number of clusters to copy */
-
+
if (opt.std_out || !opt.metadata_only)
return;
-
+
if (!(len = is_critical_metadata(image, rl)))
return;
-
+
lseek_to_cluster(rl->lcn);
-
+
/* FIXME: this could give pretty suboptimal performance */
for (i = 0; i < len; i++)
copy_cluster(opt.rescue, rl->lcn + i);
@@ -597,19 +597,19 @@ static void clone_ntfs(u64 nr_clusters)
if (write_all(&fd_out, &image_hdr, sizeof(image_hdr)) == -1)
perr_exit("write_all");
}
-
+
for (last_cl = cl = 0; cl < (u64)vol->nr_clusters; cl++) {
-
+
if (ntfs_bit_get(lcn_bitmap.bm, cl)) {
progress_update(&progress, ++p_counter);
lseek_to_cluster(cl);
image_skip_clusters(cl - last_cl - 1);
-
+
copy_cluster(opt.rescue, cl);
last_cl = cl;
continue;
}
-
+
if (opt.std_out && !opt.save_image) {
progress_update(&progress, ++p_counter);
if (write_all(&fd_out, buf, csize) == -1)
@@ -624,7 +624,7 @@ static void write_empty_clusters(s32 csi
{
s64 i;
char buff[NTFS_MAX_CLUSTER_SIZE];
-
+
memset(buff, 0, csize);
for (i = 0; i < count; i++) {
@@ -689,14 +689,14 @@ do { \
static void wipe_timestamps(ntfs_walk_clusters_ctx *image)
{
ATTR_RECORD *a = image->ctx->attr;
-
+
if (image->ni->mft_no <= LAST_METADATA_INODE)
return;
- if (a->type == AT_FILE_NAME)
+ if (a->type == AT_FILE_NAME)
WIPE_TIMESTAMPS(FILE_NAME_ATTR, a);
- else if (a->type == AT_STANDARD_INFORMATION)
+ else if (a->type == AT_STANDARD_INFORMATION)
WIPE_TIMESTAMPS(STANDARD_INFORMATION, a);
}
@@ -709,27 +709,27 @@ static void wipe_resident_data(ntfs_walk
a = image->ctx->attr;
p = (u8*)a + le16_to_cpu(a->value_offset);
-
+
if (image->ni->mft_no <= LAST_METADATA_INODE)
return;
-
+
if (a->type != AT_DATA)
return;
-
+
for (i = 0; i < le32_to_cpu(a->value_length); i++) {
if (p[i]) {
p[i] = 0;
n++;
- }
- }
-
+ }
+ }
+
wiped_resident_data += n;
}
static void clone_logfile_parts(ntfs_walk_clusters_ctx *image, runlist *rl)
{
s64 offset = 0, lcn, vcn;
-
+
while (1) {
vcn = offset / image->ni->vol->cluster_size;
@@ -781,10 +781,10 @@ static void walk_runs(struct ntfs_walk_c
"%llx length %llx\n", ctx->ntfs_ino->mft_no,
(unsigned int)le32_to_cpu(a->type), lcn,
lcn_length);
-
+
if (!wipe)
dump_clusters(walk->image, rl + i);
-
+
for (j = 0; j < lcn_length; j++) {
u64 k = (u64)lcn + j;
if (ntfs_bit_get_and_set(lcn_bitmap.bm, k, 1))
@@ -799,7 +799,7 @@ static void walk_runs(struct ntfs_walk_c
walk->image->ni->mft_no == FILE_LogFile &&
walk->image->ctx->attr->type == AT_DATA)
clone_logfile_parts(walk->image, rl);
-
+
free(rl);
}
@@ -847,7 +847,7 @@ static void compare_bitmaps(struct bitma
}
for (i = 0; i < count; i++, pos++) {
- s64 cl; /* current cluster */
+ s64 cl; /* current cluster */
if (a->bm[pos] == bm[i])
continue;
@@ -858,7 +858,7 @@ static void compare_bitmaps(struct bitma
bit = ntfs_bit_get(a->bm, cl);
if (bit == ntfs_bit_get(bm, i * 8 + cl % 8))
continue;
-
+
if (opt.ignore_fs_check) {
lseek_to_cluster(cl);
copy_cluster(opt.rescue, cl);
@@ -892,13 +892,13 @@ static void compare_bitmaps(struct bitma
static int wipe_data(char *p, int pos, int len)
{
int wiped = 0;
-
+
for (p += pos; --len >= 0;) {
if (p[len]) {
p[len] = 0;
wiped++;
- }
- }
+ }
+ }
return wiped;
}
@@ -907,11 +907,11 @@ static void wipe_unused_mft_data(ntfs_in
{
int unused;
MFT_RECORD *m = ni->mrec;
-
+
/* FIXME: broken MFTMirr update was fixed in libntfs, check if OK now */
if (ni->mft_no <= LAST_METADATA_INODE)
return;
-
+
unused = le32_to_cpu(m->bytes_allocated) - le32_to_cpu(m->bytes_in_use);
wiped_unused_mft_data += wipe_data((char *)m,
le32_to_cpu(m->bytes_in_use), unused);
@@ -921,11 +921,11 @@ static void wipe_unused_mft(ntfs_inode *
{
int unused;
MFT_RECORD *m = ni->mrec;
-
+
/* FIXME: broken MFTMirr update was fixed in libntfs, check if OK now */
if (ni->mft_no <= LAST_METADATA_INODE)
return;
-
+
unused = le32_to_cpu(m->bytes_in_use) - sizeof(MFT_RECORD);
wiped_unused_mft += wipe_data((char *)m, sizeof(MFT_RECORD), unused);
}
@@ -945,7 +945,7 @@ static int walk_clusters(ntfs_volume *vo
progress_init(&progress, inode, last_mft_rec, 100);
for (; inode <= last_mft_rec; inode++) {
-
+
int err, deleted_inode;
MFT_REF mref = (MFT_REF)inode;
@@ -956,14 +956,14 @@ static int walk_clusters(ntfs_volume *vo
ni = (ntfs_inode*)calloc(1, sizeof(ntfs_inode));
if (!ni)
perr_exit("walk_clusters");
-
+
ni->vol = volume;
err = ntfs_file_record_read(volume, mref, &ni->mrec, NULL);
if (err == -1) {
free(ni);
continue;
- }
+ }
deleted_inode = !(ni->mrec->flags & MFT_RECORD_IN_USE);
@@ -975,16 +975,16 @@ static int walk_clusters(ntfs_volume *vo
wipe_unused_mft_data(ni);
if (ntfs_mft_record_write(volume, ni->mft_no, ni->mrec))
perr_exit("ntfs_mft_record_write");
- }
+ }
}
if (ni->mrec)
free(ni->mrec);
free(ni);
- if (deleted_inode)
+ if (deleted_inode)
continue;
-
+
if ((ni = ntfs_inode_open(volume, mref)) == NULL) {
/* FIXME: continue only if it make sense, e.g.
MFT record not in use based on $MFT bitmap */
@@ -1001,17 +1001,17 @@ static int walk_clusters(ntfs_volume *vo
walk->image->ni = ni;
walk_attributes(walk);
-out:
+out:
if (wipe) {
wipe_unused_mft_data(ni);
if (ntfs_mft_record_write(volume, ni->mft_no, ni->mrec))
perr_exit("ntfs_mft_record_write");
- }
+ }
if (ntfs_inode_close(ni))
perr_exit("ntfs_inode_close for inode %lld", inode);
}
-
+
return 0;
}
@@ -1088,7 +1088,7 @@ static void print_image_info(void)
static void check_if_mounted(const char *device, unsigned long new_mntflag)
{
unsigned long mntflag;
-
+
if (ntfs_check_if_mounted(device, &mntflag))
perr_exit("Failed to check '%s' mount state", device);
@@ -1110,7 +1110,7 @@ static void check_if_mounted(const char
static void mount_volume(unsigned long new_mntflag)
{
check_if_mounted(opt.volume, new_mntflag);
-
+
if (!(vol = ntfs_mount(opt.volume, new_mntflag))) {
int err = errno;
@@ -1129,7 +1129,7 @@ static void mount_volume(unsigned long n
if (opt.force-- <= 0)
err_exit("Volume is dirty. Run chkdsk and "
"please try again (or see -f option).\n");
-
+
if (NTFS_MAX_CLUSTER_SIZE < vol->cluster_size)
err_exit("Cluster size %u is too large!\n",
(unsigned int)vol->cluster_size);
@@ -1144,7 +1144,7 @@ static void mount_volume(unsigned long n
volume_size(vol, vol->nr_clusters));
}
-struct ntfs_walk_cluster backup_clusters = { NULL, NULL };
+struct ntfs_walk_cluster backup_clusters = { NULL, NULL };
static int device_offset_valid(int fd, s64 ofs)
{
@@ -1163,7 +1163,7 @@ static s64 device_size_get(int fd)
if (ioctl(fd, BLKGETSIZE64, &size) >= 0) {
Dprintf("BLKGETSIZE64 nr bytes = %llu (0x%llx)\n",
- (unsigned long long)size,
+ (unsigned long long)size,
(unsigned long long)size);
return (s64)size;
}
@@ -1250,7 +1250,7 @@ static void set_filesize(s64 filesize)
static s64 open_image(void)
{
if (strcmp(opt.volume, "-") == 0) {
- if ((fd_in = fileno(stdin)) == -1)
+ if ((fd_in = fileno(stdin)) == -1)
perr_exit("fileno for stdout failed");
} else {
if ((fd_in = open(opt.volume, O_RDONLY)) == -1)
@@ -1269,15 +1269,15 @@ static s64 open_image(void)
static s64 open_volume(void)
{
s64 device_size;
-
+
mount_volume(MS_RDONLY);
-
+
device_size = ntfs_device_size_get(vol->dev, 1);
if (device_size <= 0)
err_exit("Couldn't get device size (%lld)!\n", device_size);
-
+
print_volume_size("Current device size", device_size);
-
+
if (device_size < vol->nr_clusters * vol->cluster_size)
err_exit("Current NTFS volume size is bigger than the device "
"size (%lld)!\nCorrupt partition table or incorrect "
@@ -1304,7 +1304,7 @@ static void check_output_device(s64 inpu
if (dest_size < input_size)
err_exit("Output device is too small (%lld) to fit the "
"NTFS image (%lld).\n", dest_size, input_size);
-
+
check_if_mounted(opt.output, 0);
} else
set_filesize(input_size);
@@ -1331,7 +1331,7 @@ static int str2unicode(const char *aname
*ustr = AT_UNNAMED;
*len = 0;
}
-
+
return 0;
}
@@ -1348,10 +1348,10 @@ static ntfs_attr_search_ctx *lookup_data
if ((ctx = attr_get_search_ctx(ni, NULL)) == NULL)
return NULL;
-
+
if (str2unicode(aname, &ustr, &len) == -1)
goto error_out;
-
+
if (ntfs_attr_lookup(AT_DATA, ustr, len, 0, 0, NULL, 0, ctx)) {
perr_printf("ntfs_attr_lookup");
goto error_out;
@@ -1364,14 +1364,14 @@ error_out:
ntfs_attr_put_search_ctx(ctx);
return NULL;
}
-
+
static void ignore_bad_clusters(ntfs_walk_clusters_ctx *image)
{
ntfs_inode *ni;
ntfs_attr_search_ctx *ctx = NULL;
runlist *rl;
s64 nr_bad_clusters = 0;
-
+
if (!(ni = ntfs_inode_open(vol, FILE_BadClus)))
perr_exit("ntfs_open_inode");
@@ -1380,10 +1380,10 @@ static void ignore_bad_clusters(ntfs_wal
if (!(rl = ntfs_mapping_pairs_decompress(vol, ctx->attr, NULL)))
perr_exit("ntfs_mapping_pairs_decompress");
-
+
for (; rl->length; rl++) {
s64 lcn = rl->lcn;
-
+
if (lcn == LCN_HOLE || lcn < 0)
continue;
@@ -1413,7 +1413,7 @@ int main(int argc, char **argv)
msg_out = stderr;
parse_options(argc, argv);
-
+
utils_set_locale();
if (opt.restore_image) {
@@ -1426,19 +1426,19 @@ int main(int argc, char **argv)
ntfs_size += 512; /* add backup boot sector */
if (opt.std_out) {
- if ((fd_out = fileno(stdout)) == -1)
+ if ((fd_out = fileno(stdout)) == -1)
perr_exit("fileno for stdout failed");
} else {
/* device_size_get() might need to read() */
int flags = O_RDWR;
-
+
if (!opt.blkdev_out) {
flags |= O_CREAT | O_TRUNC;
if (!opt.overwrite)
flags |= O_EXCL;
}
- if ((fd_out = open(opt.output, flags, S_IRWXU)) == -1)
+ if ((fd_out = open(opt.output, flags, S_IRWXU)) == -1)
perr_exit("Opening file '%s' failed", opt.output);
if (!opt.save_image)
@@ -1451,20 +1451,20 @@ int main(int argc, char **argv)
fsync_clone(fd_out);
exit(0);
}
-
+
setup_lcn_bitmap();
memset(&image, 0, sizeof(image));
- backup_clusters.image = ℑ
+ backup_clusters.image = ℑ
walk_clusters(vol, &backup_clusters);
compare_bitmaps(&lcn_bitmap);
print_disk_usage(vol->cluster_size, vol->nr_clusters, image.inuse);
-
+
ignore_bad_clusters(&image);
if (opt.save_image)
initialise_image_hdr(device_size, image.inuse);
-
+
/* FIXME: save backup boot sector */
if (opt.std_out || !opt.metadata_only) {
@@ -1477,9 +1477,9 @@ int main(int argc, char **argv)
exit(0);
}
- wipe = 1;
+ wipe = 1;
opt.volume = opt.output;
- /* 'force' again mount for dirty volumes (e.g. after resize).
+ /* 'force' again mount for dirty volumes (e.g. after resize).
FIXME: use mount flags to avoid potential side-effects in future */
opt.force++;
mount_volume(0);
@@ -1487,26 +1487,26 @@ int main(int argc, char **argv)
free(lcn_bitmap.bm);
setup_lcn_bitmap();
memset(&image, 0, sizeof(image));
- backup_clusters.image = ℑ
+ backup_clusters.image = ℑ
walk_clusters(vol, &backup_clusters);
-
+
Printf("Num of MFT records = %10lld\n",
(long long)vol->mft_na->initialized_size >>
- vol->mft_record_size_bits);
- Printf("Num of used MFT records = %10u\n", nr_used_mft_records);
-
- Printf("Wiped unused MFT data = %10u\n", wiped_unused_mft_data);
- Printf("Wiped deleted MFT data = %10u\n", wiped_unused_mft);
+ vol->mft_record_size_bits);
+ Printf("Num of used MFT records = %10u\n", nr_used_mft_records);
+
+ Printf("Wiped unused MFT data = %10u\n", wiped_unused_mft_data);
+ Printf("Wiped deleted MFT data = %10u\n", wiped_unused_mft);
Printf("Wiped resident user data = %10u\n", wiped_resident_data);
Printf("Wiped timestamp data = %10u\n", wiped_timestamp_data);
-
+
wiped_total += wiped_unused_mft_data;
wiped_total += wiped_unused_mft;
wiped_total += wiped_resident_data;
wiped_total += wiped_timestamp_data;
Printf("Wiped totally = %10u\n", wiped_total);
-
+
fsync_clone(fd_out);
exit(0);
}
Index: ntfscluster.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfscluster.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -p -r1.24 -r1.25
--- ntfscluster.c 12 Jun 2005 18:12:56 -0000 1.24
+++ ntfscluster.c 19 Jun 2005 21:09:41 -0000 1.25
@@ -357,7 +357,7 @@ static int info (ntfs_volume *vol)
*/
static int dump_file (ntfs_volume *vol, ntfs_inode *ino)
{
- u8 buffer[1024];
+ char buffer[1024];
ntfs_attr_search_ctx *ctx;
ATTR_RECORD *rec;
int i;
Index: ntfscluster.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfscluster.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -p -r1.9 -r1.10
...
[truncated message content] |