$NetBSD: patch-af,v 1.3 2005/11/04 21:46:12 dbj Exp $ --- ntfsprogs/ntfsclone.c.orig 2004-09-04 06:16:32.000000000 -0400 +++ ntfsprogs/ntfsclone.c 2005-09-25 10:43:27.000000000 -0400 @@ -30,6 +30,19 @@ #include #include +#ifdef __NetBSD__ +# include + /* NetBSD versions later than 2.99.9 have statvfs(2) instead of statfs(2) */ +# if __NetBSD_Version__ >= 299000900 +# include +# define F_TYPE f_fsid +# else +# define F_TYPE f_type +# endif +#else +# define F_TYPE f_type +#endif + #include "debug.h" #include "types.h" #include "support.h" @@ -66,7 +79,11 @@ int restore_image; char *output; char *volume; +#if defined(__NetBSD__) && (__NetBSD_Version__ >= 299000900) + struct statvfs stfs; +#else struct statfs stfs; +#endif } opt; struct bitmap { @@ -338,16 +355,13 @@ } 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; - else - if (!(stderr = fopen("/dev/null", "rw"))) - perr_exit("Couldn't open /dev/null"); + +#ifdef DEBUG + if (!opt.debug) + ntfs_err_out = NULL; +#endif } static void progress_init(struct progress_bar *p, u64 start, u64 stop, int res) @@ -462,7 +476,7 @@ if (write_all(&fd_out, buff, csize) == -1) { int err = errno; perr_printf("Write failed"); - if (err == EIO && opt.stfs.f_type == 0x517b) + if (err == EIO && opt.stfs.F_TYPE == 0x517b) Printf("Apparently you tried to clone to a remote " "Windows computer but they don't\nhave " "efficient sparse file handling by default. " @@ -1152,12 +1166,12 @@ if (fstatfs(fd_out, &opt.stfs) == -1) Printf("WARNING: Couldn't get filesystem type: " "%s\n", strerror(errno)); - else if (opt.stfs.f_type == 0x52654973) + else if (opt.stfs.F_TYPE == 0x52654973) Printf("WARNING: You're using ReiserFS, it has very poor " "performance creating\nlarge sparse files. The next " "operation might take a very long time!\n" "Creating sparse output file ...\n"); - else if (opt.stfs.f_type == 0x517b) + else if (opt.stfs.F_TYPE == 0x517b) Printf("WARNING: You're using SMBFS and if the remote share " "isn't Samba but a Windows\ncomputer then the clone " "operation will be very inefficient and may fail!\n"); @@ -1168,7 +1182,7 @@ if (err == E2BIG) { Printf("Your system or the destination filesystem " "doesn't support large files.\n"); - if (opt.stfs.f_type == 0x517b) { + if (opt.stfs.F_TYPE == 0x517b) { Printf("SMBFS needs minimum Linux kernel " "version 2.4.25 and\n the 'lfs' option" "\nfor smbmount to have large "