apply patch from Szaka:

- all warnings fixed for maintainer mode for ntfsresize and ntfsclone
- added 'const' to ntfs_ucstombs()'s first parameter
- 'fsync' also after metadata-only cloning
- fixed forced metadata-only, dirty ntfs cloning (only one -f needed)

(Logical change 1.264)
edge.strict_endians
cantab.net!aia21 2004-01-15 17:07:57 +00:00
parent f67f495e28
commit 401c8ebf7d
4 changed files with 105 additions and 100 deletions

View File

@ -57,7 +57,7 @@ extern int ntfs_file_values_compare(FILE_NAME_ATTR *file_name_attr1,
extern int ntfs_ucstombs(const uchar_t *ins, const int ins_len, char **outs,
int outs_len);
extern int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len);
extern int ntfs_mbstoucs(const char *ins, uchar_t **outs, int outs_len);
#endif /* defined _NTFS_UNISTR_H */

View File

@ -427,7 +427,7 @@ err_out:
* ENAMETOOLONG Destination buffer is too small for input string.
* ENOMEM Not enough memory to allocate destination buffer.
*/
int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
int ntfs_mbstoucs(const char *ins, uchar_t **outs, int outs_len)
{
uchar_t *ucs;
char *s;

View File

@ -1,7 +1,7 @@
/**
* ntfsclone - Part of the Linux-NTFS project.
*
* Copyright (c) 2003 Szabolcs Szakacsits
* Copyright (c) 2003-2004 Szabolcs Szakacsits
*
* Clone NTFS data and/or metadata to a sparse file, device or stdout.
*
@ -111,13 +111,20 @@ int wiped_timestamp_data = 0;
#define read_all(f, p, n) io_all((f), (p), (n), 0)
#define write_all(f, p, n) io_all((f), (p), (n), 1)
/* FIXME: They should be #included but Eprintf conflicts with mkntfs's Eprintf */
extern int Eprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
extern int Vprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
extern int Qprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
/* FIXME: should be 'static' */
extern int Printf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
GEN_PRINTF(Eprintf, stderr, NULL, FALSE)
GEN_PRINTF(Vprintf, msg_out, &opt.verbose, TRUE)
GEN_PRINTF(Qprintf, msg_out, &opt.quiet, FALSE)
GEN_PRINTF(Printf, msg_out, NULL, FALSE)
void perr_printf(const char *fmt, ...)
static void perr_printf(const char *fmt, ...)
{
va_list ap;
int eo = errno;
@ -130,7 +137,7 @@ void perr_printf(const char *fmt, ...)
fflush(msg_out);
}
void err_printf(const char *fmt, ...)
static void err_printf(const char *fmt, ...)
{
va_list ap;
@ -141,7 +148,7 @@ void err_printf(const char *fmt, ...)
fflush(msg_out);
}
int err_exit(const char *fmt, ...)
static int err_exit(const char *fmt, ...)
{
va_list ap;
@ -154,7 +161,7 @@ int err_exit(const char *fmt, ...)
}
int perr_exit(const char *fmt, ...)
static int perr_exit(const char *fmt, ...)
{
va_list ap;
int eo = errno;
@ -169,7 +176,7 @@ int perr_exit(const char *fmt, ...)
}
void usage(void)
static void usage(void)
{
Eprintf("\nUsage: %s [options] device\n"
" Efficiently clone NTFS to a sparse file, device or standard output.\n"
@ -191,7 +198,7 @@ void usage(void)
}
void parse_options(int argc, char **argv)
static void parse_options(int argc, char **argv)
{
static const char *sopt = "-dfhmo:O:";
static const struct option lopt[] = {
@ -292,7 +299,7 @@ void parse_options(int argc, char **argv)
perr_exit("Couldn't open /dev/null");
}
void progress_init(struct progress_bar *p, u64 start, u64 stop, int res)
static void progress_init(struct progress_bar *p, u64 start, u64 stop, int res)
{
p->start = start;
p->stop = stop;
@ -301,7 +308,7 @@ void progress_init(struct progress_bar *p, u64 start, u64 stop, int res)
}
void progress_update(struct progress_bar *p, u64 current)
static void progress_update(struct progress_bar *p, u64 current)
{
float percent = p->unit * current;
@ -320,7 +327,7 @@ void progress_update(struct progress_bar *p, u64 current)
* Take the number of clusters in the volume and calculate the size of $Bitmap.
* The size will always be a multiple of 8 bytes.
*/
s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
static s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
{
s64 bm_bsize;
@ -333,7 +340,7 @@ s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
return bm_bsize;
}
int is_critical_metadata(ntfs_walk_clusters_ctx *image)
static int is_critical_metadata(ntfs_walk_clusters_ctx *image)
{
s64 inode;
@ -350,7 +357,7 @@ int is_critical_metadata(ntfs_walk_clusters_ctx *image)
}
int io_all(void *fd, void *buf, int count, int do_write)
static int io_all(void *fd, void *buf, int count, int do_write)
{
int i;
struct ntfs_device *dev = (struct ntfs_device *)fd;
@ -372,7 +379,7 @@ int io_all(void *fd, void *buf, int count, int do_write)
}
void copy_cluster(void)
static void copy_cluster(void)
{
char buff[NTFS_MAX_CLUSTER_SIZE]; /* overflow checked at mount time */
@ -383,7 +390,7 @@ void copy_cluster(void)
perr_exit("write_all");
}
void lseek_to_cluster(s64 lcn)
static void lseek_to_cluster(s64 lcn)
{
off_t pos;
@ -399,7 +406,7 @@ void lseek_to_cluster(s64 lcn)
perr_exit("lseek output");
}
void dump_clusters(ntfs_walk_clusters_ctx *image, runlist *rl)
static void dump_clusters(ntfs_walk_clusters_ctx *image, runlist *rl)
{
int i;
@ -416,7 +423,7 @@ void dump_clusters(ntfs_walk_clusters_ctx *image, runlist *rl)
copy_cluster();
}
void clone_ntfs(u64 nr_clusters)
static void clone_ntfs(u64 nr_clusters)
{
s64 i, pos, count;
u8 bm[NTFS_BUF_SIZE];
@ -480,7 +487,7 @@ do { \
\
} while(0)
void wipe_timestamps(ntfs_walk_clusters_ctx *image)
static void wipe_timestamps(ntfs_walk_clusters_ctx *image)
{
ATTR_RECORD *a = image->ctx->attr;
@ -494,7 +501,7 @@ void wipe_timestamps(ntfs_walk_clusters_ctx *image)
WIPE_TIMESTAMPS(STANDARD_INFORMATION, a);
}
void wipe_resident_data(ntfs_walk_clusters_ctx *image)
static void wipe_resident_data(ntfs_walk_clusters_ctx *image)
{
ATTR_RECORD *a;
u32 i;
@ -520,7 +527,7 @@ void wipe_resident_data(ntfs_walk_clusters_ctx *image)
wiped_resident_data += n;
}
void walk_runs(struct ntfs_walk_cluster *walk)
static void walk_runs(struct ntfs_walk_cluster *walk)
{
int i, j;
runlist *rl;
@ -572,7 +579,7 @@ void walk_runs(struct ntfs_walk_cluster *walk)
}
void walk_attributes(struct ntfs_walk_cluster *walk)
static void walk_attributes(struct ntfs_walk_cluster *walk)
{
ntfs_attr_search_ctx *ctx;
@ -592,7 +599,7 @@ void walk_attributes(struct ntfs_walk_cluster *walk)
void compare_bitmaps(struct bitmap *a)
static void compare_bitmaps(struct bitmap *a)
{
s64 i, pos, count;
int mismatch = 0;
@ -647,7 +654,7 @@ void compare_bitmaps(struct bitmap *a)
}
int wipe_data(char *p, int pos, int len)
static int wipe_data(char *p, int pos, int len)
{
int wiped = 0;
@ -662,7 +669,7 @@ int wipe_data(char *p, int pos, int len)
return wiped;
}
void wipe_unused_mft_data(ntfs_inode *ni)
static void wipe_unused_mft_data(ntfs_inode *ni)
{
int unused;
MFT_RECORD *m = ni->mrec;
@ -675,7 +682,7 @@ void wipe_unused_mft_data(ntfs_inode *ni)
wiped_unused_mft_data += wipe_data((char *)m, m->bytes_in_use, unused);
}
void wipe_unused_mft(ntfs_inode *ni)
static void wipe_unused_mft(ntfs_inode *ni)
{
int unused;
MFT_RECORD *m = ni->mrec;
@ -690,7 +697,7 @@ void wipe_unused_mft(ntfs_inode *ni)
}
int walk_clusters(ntfs_volume *vol, struct ntfs_walk_cluster *walk)
static int walk_clusters(ntfs_volume *volume, struct ntfs_walk_cluster *walk)
{
s64 inode = 0;
s64 last_mft_rec;
@ -699,7 +706,7 @@ int walk_clusters(ntfs_volume *vol, struct ntfs_walk_cluster *walk)
Printf("Scanning volume ...\n");
last_mft_rec = vol->nr_mft_records - 1;
last_mft_rec = volume->nr_mft_records - 1;
progress_init(&progress, inode, last_mft_rec, 100);
for (; inode <= last_mft_rec; inode++) {
@ -715,9 +722,9 @@ int walk_clusters(ntfs_volume *vol, struct ntfs_walk_cluster *walk)
if (!ni)
perr_exit("walk_clusters");
ni->vol = vol;
ni->vol = volume;
err = ntfs_file_record_read(vol, mref, &ni->mrec, NULL);
err = ntfs_file_record_read(volume, mref, &ni->mrec, NULL);
if (err == -1) {
free(ni);
continue;
@ -731,7 +738,7 @@ int walk_clusters(ntfs_volume *vol, struct ntfs_walk_cluster *walk)
if (wipe) {
wipe_unused_mft(ni);
wipe_unused_mft_data(ni);
if (ntfs_mft_record_write(vol, ni->mft_no, ni->mrec))
if (ntfs_mft_record_write(volume, ni->mft_no, ni->mrec))
perr_exit("ntfs_mft_record_write");
}
}
@ -743,7 +750,7 @@ int walk_clusters(ntfs_volume *vol, struct ntfs_walk_cluster *walk)
if (deleted_inode)
continue;
if ((ni = ntfs_inode_open(vol, mref)) == NULL) {
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 */
if (errno == EIO || errno == ENOENT)
@ -762,7 +769,7 @@ int walk_clusters(ntfs_volume *vol, struct ntfs_walk_cluster *walk)
out:
if (wipe) {
wipe_unused_mft_data(ni);
if (ntfs_mft_record_write(vol, ni->mft_no, ni->mrec))
if (ntfs_mft_record_write(volume, ni->mft_no, ni->mrec))
perr_exit("ntfs_mft_record_write");
}
@ -778,7 +785,7 @@ out:
* $Bitmap can overlap the end of the volume. Any bits in this region
* must be set. This region also encompasses the backup boot sector.
*/
void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
static void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
{
for (; cluster < bm->size << 3; cluster++)
ntfs_bit_set(bm->bm, (u64)cluster, 1);
@ -790,7 +797,7 @@ void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
* All the bits are set to 0, except those representing the region beyond the
* end of the disk.
*/
void setup_lcn_bitmap(void)
static void setup_lcn_bitmap(void)
{
/* Determine lcn bitmap byte size and allocate it. */
lcn_bitmap.size = nr_clusters_to_bitmap_byte_size(vol->nr_clusters);
@ -802,20 +809,20 @@ void setup_lcn_bitmap(void)
}
s64 volume_size(ntfs_volume *vol, s64 nr_clusters)
static s64 volume_size(ntfs_volume *volume, s64 nr_clusters)
{
return nr_clusters * vol->cluster_size;
return nr_clusters * volume->cluster_size;
}
void print_volume_size(char *str, s64 bytes)
static void print_volume_size(const char *str, s64 bytes)
{
Printf("%s: %lld bytes (%lld MB)\n",
str, bytes, rounded_up_division(bytes, NTFS_MBYTE));
}
void print_disk_usage(ntfs_walk_clusters_ctx *image)
static void print_disk_usage(ntfs_walk_clusters_ctx *image)
{
s64 total, used;
@ -834,7 +841,7 @@ void print_disk_usage(ntfs_walk_clusters_ctx *image)
* is dirty (Windows wasn't shutdown properly). If everything is OK, then mount
* the volume (load the metadata into memory).
*/
void mount_volume(unsigned long new_mntflag)
static void mount_volume(unsigned long new_mntflag)
{
unsigned long mntflag;
@ -883,7 +890,7 @@ void mount_volume(unsigned long new_mntflag)
struct ntfs_walk_cluster backup_clusters = { NULL, NULL };
int device_offset_valid(int fd, s64 ofs)
static int device_offset_valid(int fd, s64 ofs)
{
char ch;
@ -892,7 +899,7 @@ int device_offset_valid(int fd, s64 ofs)
return -1;
}
s64 device_size_get(int fd)
static s64 device_size_get(int fd)
{
s64 high, low;
#ifdef BLKGETSIZE
@ -933,6 +940,12 @@ s64 device_size_get(int fd)
return (low + 1LL);
}
static void fsync_clone(int fd)
{
Printf("Syncing ...\n");
if (fsync(fd) && errno != EINVAL)
perr_exit("fsync");
}
int main(int argc, char **argv)
{
@ -1016,14 +1029,15 @@ int main(int argc, char **argv)
s64 nr_clusters = opt.stdout ? vol->nr_clusters : image.inuse;
clone_ntfs(nr_clusters);
Printf("Syncing ...\n");
if (fsync(fd_out) && errno != EINVAL)
perr_exit("fsync");
fsync_clone(fd_out);
exit(0);
}
wipe = 1;
opt.volume = opt.output;
/* '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);
setup_lcn_bitmap();
@ -1046,6 +1060,7 @@ int main(int argc, char **argv)
wiped_total += wiped_timestamp_data;
Printf("Wiped totally = %8d\n", wiped_total);
fsync_clone(fd_out);
exit(0);
}

View File

@ -1,7 +1,7 @@
/**
* ntfsresize - Part of the Linux-NTFS project.
*
* Copyright (c) 2002-2003 Szabolcs Szakacsits
* Copyright (c) 2002-2004 Szabolcs Szakacsits
* Copyright (c) 2002-2003 Anton Altaparmakov
* Copyright (c) 2002-2003 Richard Russon
*
@ -126,6 +126,11 @@ struct bitmap lcn_bitmap;
#define rounded_up_division(a, b) (((a) + (b - 1)) / (b))
/* FIXME: They should be included but Eprintf conflicts with mkntfs's Eprintf */
extern int Eprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
extern int Vprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
extern int Qprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
GEN_PRINTF (Eprintf, stderr, NULL, FALSE)
GEN_PRINTF (Vprintf, stdout, &opt.verbose, TRUE)
GEN_PRINTF (Qprintf, stdout, &opt.quiet, FALSE)
@ -135,7 +140,7 @@ GEN_PRINTF (Qprintf, stdout, &opt.quiet, FALSE)
*
* Print an error message.
*/
void perr_printf(const char *fmt, ...)
static void perr_printf(const char *fmt, ...)
{
va_list ap;
int eo = errno;
@ -154,7 +159,7 @@ void perr_printf(const char *fmt, ...)
*
* Print and error message and exit the program.
*/
int err_exit(const char *fmt, ...)
static int err_exit(const char *fmt, ...)
{
va_list ap;
@ -172,7 +177,7 @@ int err_exit(const char *fmt, ...)
*
* Print and error message and exit the program
*/
int perr_exit(const char *fmt, ...)
static int perr_exit(const char *fmt, ...)
{
va_list ap;
int eo = errno;
@ -194,7 +199,7 @@ int perr_exit(const char *fmt, ...)
*
* Return: none
*/
void usage(void)
static void usage(void)
{
printf ("\nUsage: %s [options] device\n"
@ -227,7 +232,7 @@ void usage(void)
* Force the user to confirm an action before performing it.
* Copy-paste from e2fsprogs
*/
void proceed_question(void)
static void proceed_question(void)
{
char buf[256];
const char *short_yes = "yY";
@ -251,7 +256,7 @@ void proceed_question(void)
*
* Return: none
*/
void version (void)
static void version (void)
{
printf ("\nResize an NTFS Volume, without data loss.\n\n");
printf ("Copyright (c) 2002-2003 Szabolcs Szakacsits\n");
@ -267,7 +272,7 @@ void version (void)
* will be assumed to be in bytes. If the number has a suffix of k, M or G it
* will be scaled up by 1000, 1000000, or 1000000000.
*/
s64 get_new_volume_size(char *s)
static s64 get_new_volume_size(char *s)
{
s64 size;
char *suffix;
@ -322,7 +327,7 @@ s64 get_new_volume_size(char *s)
* Return: 1 Success
* 0 Error, one or more problems
*/
int parse_options(int argc, char **argv)
static int parse_options(int argc, char **argv)
{
static const char *sopt = "-dfhinPs:vV";
static const struct option lopt[] = {
@ -438,28 +443,13 @@ int parse_options(int argc, char **argv)
return (!err && !help && !ver);
}
/**
* runlist_extent_number
*
* Count the runs in a runlist.
*/
int runlist_extent_number(runlist *rl)
{
int i;
for (i = 0; rl[i].length; i++)
;
return i;
}
/**
* nr_clusters_to_bitmap_byte_size
*
* Take the number of clusters in the volume and calculate the size of $Bitmap.
* The size will always be a multiple of 8 bytes.
*/
s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
static s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
{
s64 bm_bsize;
@ -472,7 +462,7 @@ s64 nr_clusters_to_bitmap_byte_size(s64 nr_clusters)
return bm_bsize;
}
int str2unicode(char *aname, uchar_t **ustr, int *len)
static int str2unicode(const char *aname, uchar_t **ustr, int *len)
{
if (aname && ((*len = ntfs_mbstoucs(aname, ustr, 0)) == -1))
return -1;
@ -485,7 +475,7 @@ int str2unicode(char *aname, uchar_t **ustr, int *len)
return 0;
}
int has_bad_sectors(ntfs_resize_t *resize)
static int has_bad_sectors(ntfs_resize_t *resize)
{
int len, ret = 0;
uchar_t *ustr = NULL;
@ -508,7 +498,7 @@ int has_bad_sectors(ntfs_resize_t *resize)
return ret;
}
void collect_shrink_constraints(ntfs_resize_t *resize, s64 last_lcn)
static void collect_shrink_constraints(ntfs_resize_t *resize, s64 last_lcn)
{
s64 inode;
ATTR_FLAGS flags;
@ -551,7 +541,7 @@ void collect_shrink_constraints(ntfs_resize_t *resize, s64 last_lcn)
}
void collect_shrink_info(ntfs_resize_t *resize, runlist *rl)
static void collect_shrink_info(ntfs_resize_t *resize, runlist *rl)
{
s64 new_volume_size, lcn, lcn_length;
@ -589,7 +579,7 @@ void collect_shrink_info(ntfs_resize_t *resize, runlist *rl)
*
* This serves as a rudimentary "chkdsk" operation.
*/
void build_lcn_usage_bitmap(ntfs_resize_t *resize)
static void build_lcn_usage_bitmap(ntfs_resize_t *resize)
{
s64 inode;
ATTR_RECORD *a;
@ -647,7 +637,7 @@ void build_lcn_usage_bitmap(ntfs_resize_t *resize)
* For a given MFT Record, iterate through all its attributes. Any non-resident
* data runs will be marked in lcn_bitmap.
*/
void walk_attributes(ntfs_resize_t *resize)
static void walk_attributes(ntfs_resize_t *resize)
{
ntfs_attr_search_ctx *ctx;
@ -670,7 +660,7 @@ void walk_attributes(ntfs_resize_t *resize)
* Compare two bitmaps. In this case, $Bitmap as read from the disk and
* lcn_bitmap which we built from the MFT Records.
*/
void compare_bitmaps(struct bitmap *a)
static void compare_bitmaps(struct bitmap *a)
{
s64 i, pos, count;
int mismatch = 0;
@ -739,7 +729,7 @@ void compare_bitmaps(struct bitmap *a)
*
* Create and scale our progress bar.
*/
void progress_init(struct progress_bar *p, u64 start, u64 stop, int res)
static void progress_init(struct progress_bar *p, u64 start, u64 stop, int res)
{
p->start = start;
p->stop = stop;
@ -752,7 +742,7 @@ void progress_init(struct progress_bar *p, u64 start, u64 stop, int res)
*
* Update the progress bar and tell the user.
*/
void progress_update(struct progress_bar *p, u64 current)
static void progress_update(struct progress_bar *p, u64 current)
{
float percent;
@ -775,7 +765,7 @@ void progress_update(struct progress_bar *p, u64 current)
* Read each record in the MFT, skipping the unused ones, and build up a bitmap
* from all the non-resident attributes.
*/
void walk_inodes(ntfs_resize_t *resize)
static void walk_inodes(ntfs_resize_t *resize)
{
s64 inode = 0;
s64 last_mft_rec;
@ -809,7 +799,7 @@ close_inode:
}
}
void print_hint(const char *s, struct llcn_t llcn)
static void print_hint(const char *s, struct llcn_t llcn)
{
s64 runs_b, runs_mb;
@ -828,7 +818,7 @@ void print_hint(const char *s, struct llcn_t llcn)
* already been read into lcn_bitmap. By looking for the last used cluster on
* the disk, we can work out by how much we can shrink the volume.
*/
void advise_on_resize(ntfs_resize_t *resize)
static void advise_on_resize(ntfs_resize_t *resize)
{
s64 old_b, new_b, g_b, old_mb, new_mb, g_mb;
s64 supp_lcn = 0; /* smallest size supported in LCN */
@ -884,7 +874,7 @@ void advise_on_resize(ntfs_resize_t *resize)
*
* Helper to set up a runlist object
*/
void rl_set(runlist *rl, VCN vcn, LCN lcn, s64 len)
static void rl_set(runlist *rl, VCN vcn, LCN lcn, s64 len)
{
rl->vcn = vcn;
rl->lcn = lcn;
@ -897,7 +887,7 @@ void rl_set(runlist *rl, VCN vcn, LCN lcn, s64 len)
* $Bitmap can overlap the end of the volume. Any bits in this region
* must be set. This region also encompasses the backup boot sector.
*/
void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
static void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
{
for (; cluster < bm->size << 3; cluster++)
ntfs_bit_set(bm->bm, (u64)cluster, 1);
@ -911,7 +901,7 @@ void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
* FIXME: this function should go away and instead using a generalized
* "truncate_bitmap_data_attr()"
*/
void truncate_badclust_bad_attr(ATTR_RECORD *a, s64 nr_clusters)
static void truncate_badclust_bad_attr(ATTR_RECORD *a, s64 nr_clusters)
{
runlist *rl_bad;
int mp_size;
@ -955,7 +945,7 @@ void truncate_badclust_bad_attr(ATTR_RECORD *a, s64 nr_clusters)
* Shrink the metadata file $Bitmap. It must be large enough for one bit per
* cluster of the shrunken volume. Also it must be a of 8 bytes in size.
*/
void shrink_bitmap_data_attr(runlist **rlist, s64 nr_bm_clusters, s64 new_size)
static void shrink_bitmap_data_attr(runlist **rlist, s64 nr_bm_clusters, s64 new_size)
{
runlist *rl = *rlist;
int i, j;
@ -1000,7 +990,7 @@ void shrink_bitmap_data_attr(runlist **rlist, s64 nr_bm_clusters, s64 new_size)
* Enlarge the metadata file $Bitmap. It must be large enough for one bit per
* cluster of the shrunken volume. Also it must be a of 8 bytes in size.
*/
void enlarge_bitmap_data_attr(runlist **rlist, s64 nr_bm_clusters, s64 new_size)
static void enlarge_bitmap_data_attr(runlist **rlist, s64 nr_bm_clusters, s64 new_size)
{
runlist *rl = *rlist;
s64 i, j, free_zone = 0;
@ -1037,7 +1027,7 @@ void enlarge_bitmap_data_attr(runlist **rlist, s64 nr_bm_clusters, s64 new_size)
/**
* truncate_bitmap_data_attr
*/
void truncate_bitmap_data_attr(ntfs_resize_t *resize)
static void truncate_bitmap_data_attr(ntfs_resize_t *resize)
{
ATTR_RECORD *a;
runlist *rl;
@ -1116,7 +1106,7 @@ void truncate_bitmap_data_attr(ntfs_resize_t *resize)
* Find the $DATA attribute (with or without a name) for the given MFT reference
* (inode number).
*/
void lookup_data_attr(MFT_REF mref, char *aname, ntfs_attr_search_ctx **ctx)
static void lookup_data_attr(MFT_REF mref, const char *aname, ntfs_attr_search_ctx **ctx)
{
ntfs_inode *ni;
uchar_t *ustr = NULL;
@ -1147,7 +1137,7 @@ void lookup_data_attr(MFT_REF mref, char *aname, ntfs_attr_search_ctx **ctx)
* Write an MFT Record back to the disk. If the read-only command line option
* was given, this function will do nothing.
*/
int write_mft_record(ntfs_attr_search_ctx *ctx)
static int write_mft_record(ntfs_attr_search_ctx *ctx)
{
if (ntfs_mft_record_write(vol, ctx->ntfs_ino->mft_no, ctx->mrec))
perr_exit("ntfs_mft_record_write");
@ -1163,7 +1153,7 @@ int write_mft_record(ntfs_attr_search_ctx *ctx)
*
* Shrink the $BadClus file to match the new volume size.
*/
void truncate_badclust_file(s64 nr_clusters)
static void truncate_badclust_file(s64 nr_clusters)
{
ntfs_attr_search_ctx *ctx = NULL;
@ -1184,7 +1174,7 @@ void truncate_badclust_file(s64 nr_clusters)
*
* Shrink the $Bitmap file to match the new volume size.
*/
void truncate_bitmap_file(ntfs_resize_t *resize)
static void truncate_bitmap_file(ntfs_resize_t *resize)
{
printf("Updating $Bitmap file ...\n");
@ -1204,7 +1194,7 @@ void truncate_bitmap_file(ntfs_resize_t *resize)
* All the bits are set to 0, except those representing the region beyond the
* end of the disk.
*/
void setup_lcn_bitmap(void)
static void setup_lcn_bitmap(void)
{
/* Determine lcn bitmap byte size and allocate it. */
lcn_bitmap.size = nr_clusters_to_bitmap_byte_size(vol->nr_clusters);
@ -1220,7 +1210,7 @@ void setup_lcn_bitmap(void)
*
* FIXME: should be done using ntfs_* functions
*/
void update_bootsector(s64 nr_clusters)
static void update_bootsector(s64 nr_clusters)
{
NTFS_BOOT_SECTOR bs;
@ -1248,9 +1238,9 @@ void update_bootsector(s64 nr_clusters)
/**
* volume_size
*/
s64 volume_size(ntfs_volume *vol, s64 nr_clusters)
static s64 volume_size(ntfs_volume *v, s64 nr_clusters)
{
return nr_clusters * vol->cluster_size;
return nr_clusters * v->cluster_size;
}
/**
@ -1258,7 +1248,7 @@ s64 volume_size(ntfs_volume *vol, s64 nr_clusters)
*
* Print the volume size in bytes and decimal megabytes.
*/
void print_volume_size(char *str, s64 bytes)
static void print_volume_size(const char *str, s64 bytes)
{
printf("%s: %lld bytes (%lld MB)\n",
str, bytes, rounded_up_division(bytes, NTFS_MBYTE));
@ -1269,7 +1259,7 @@ void print_volume_size(char *str, s64 bytes)
*
* Display the amount of disk space in use.
*/
void print_disk_usage(ntfs_resize_t *resize)
static void print_disk_usage(ntfs_resize_t *resize)
{
s64 total, used, relocations;
@ -1294,7 +1284,7 @@ void print_disk_usage(ntfs_resize_t *resize)
* is dirty (Windows wasn't shutdown properly). If everything is OK, then mount
* the volume (load the metadata into memory).
*/
void mount_volume(void)
static void mount_volume(void)
{
unsigned long mntflag;
@ -1348,7 +1338,7 @@ void mount_volume(void)
* boots it will automatically run chkdsk to check for any problems. If the
* read-only command line option was given, this function will do nothing.
*/
void prepare_volume_fixup(void)
static void prepare_volume_fixup(void)
{
u16 flags;