summaryrefslogtreecommitdiff
path: root/sysutils/ntfsprogs/patches/patch-af
blob: becf4803adf0477eeda51d467a414debd6e5dbf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
$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 <errno.h>
 #include <getopt.h>
 
+#ifdef __NetBSD__
+#  include <sys/param.h>
+   /* NetBSD versions later than 2.99.9 have statvfs(2) instead of statfs(2) */
+#  if __NetBSD_Version__ >= 299000900
+#    include <sys/statvfs.h>
+#    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 "