ntfsclone: check available free space on the destination
parent
a732881c5e
commit
594c23aff0
|
@ -67,6 +67,8 @@ xx/xx/2005 - 1.12.2-WIP
|
|||
block devices, FIFOs and sockets) to layout.h. Teech ntfsmount to
|
||||
handle them. (Yura)
|
||||
- Fix allocated data size for resident attributes. (Yura)
|
||||
- ntfsclone: check available free space on the destination before
|
||||
starting to clone or restore. (Szaka)
|
||||
|
||||
10/10/2005 - 1.12.1 - Minor fix to location of mount.ntfs-fuse and mkfs.ntfs.
|
||||
|
||||
|
|
|
@ -311,8 +311,9 @@ AC_CHECK_HEADERS([ctype.h fcntl.h libintl.h limits.h locale.h mntent.h \
|
|||
stddef.h stdint.h stdlib.h stdio.h stdarg.h string.h strings.h \
|
||||
errno.h time.h unistd.h utime.h wchar.h getopt.h features.h endian.h \
|
||||
byteswap.h sys/byteorder.h sys/endian.h sys/param.h sys/ioctl.h \
|
||||
sys/mount.h sys/stat.h sys/types.h sys/vfs.h linux/major.h linux/fd.h \
|
||||
linux/hdreg.h machine/endian.h gcrypt.h windows.h gnutls/pkcs12.h])
|
||||
sys/mount.h sys/stat.h sys/types.h sys/vfs.h sys/statvfs.h \
|
||||
linux/major.h linux/fd.h linux/hdreg.h machine/endian.h gcrypt.h \
|
||||
windows.h gnutls/pkcs12.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_HEADER_STDBOOL
|
||||
|
|
|
@ -34,7 +34,10 @@
|
|||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_VFS_H
|
||||
# include <sys/vfs.h>
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STATVFS_H
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
|
@ -1444,6 +1447,28 @@ static void ignore_bad_clusters(ntfs_walk_clusters_ctx *image)
|
|||
perr_exit("ntfs_inode_close failed for $BadClus");
|
||||
}
|
||||
|
||||
static void check_dest_free_space(u64 src_bytes)
|
||||
{
|
||||
u64 dest_bytes;
|
||||
struct statvfs stvfs;
|
||||
|
||||
if (opt.save_image || opt.metadata_only || opt.blkdev_out || opt.std_out)
|
||||
return;
|
||||
|
||||
if (fstatvfs(fd_out, &stvfs) == -1) {
|
||||
Printf("WARNING: Unknown free space on the destination: %s\n",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
dest_bytes = stvfs.f_bsize * stvfs.f_bfree;
|
||||
|
||||
if (dest_bytes < src_bytes)
|
||||
err_exit("Destination has no enough free space: %llu MB < %llu"
|
||||
" MB\n", rounded_up_division(dest_bytes, NTFS_MBYTE),
|
||||
rounded_up_division(src_bytes, NTFS_MBYTE));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ntfs_walk_clusters_ctx image;
|
||||
|
@ -1504,6 +1529,8 @@ int main(int argc, char **argv)
|
|||
compare_bitmaps(&lcn_bitmap);
|
||||
print_disk_usage(vol->cluster_size, vol->nr_clusters, image.inuse);
|
||||
|
||||
check_dest_free_space(vol->cluster_size * image.inuse);
|
||||
|
||||
ignore_bad_clusters(&image);
|
||||
|
||||
if (opt.save_image)
|
||||
|
|
Loading…
Reference in New Issue