summaryrefslogtreecommitdiff
path: root/sysutils/vobcopy/patches/patch-aa
blob: 79340ab334fea22c91c36c26d9036cf8f710fa09 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
$NetBSD: patch-aa,v 1.2 2004/04/22 15:28:47 drochner Exp $

--- dvd.c.orig	2004-03-26 19:53:10.000000000 +0100
+++ dvd.c	2004-04-22 16:27:45.000000000 +0200
@@ -23,9 +23,18 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <sys/stat.h>
-#if (defined(__unix__) || defined(unix)) && !defined(USG) || (defined(__APPLE__) && defined(__GNUC__))
+#if (defined(__unix__) || defined(unix)) && !defined(USG) || (defined(__APPLE__) && defined(__GNUC__)) || defined(__NetBSD__)
 #include <sys/param.h>  
+#define USE_GETMNTINFO
+#if !defined(__NetBSD__) || (__NetBSD_Version__ < 200040000)
 #include <sys/mount.h>
+#define USE_STATFS_FOR_DEV
+#define GETMNTINFO_USES_STATFS
+#else
+#include <sys/statvfs.h>
+#define USE_STATVFS_FOR_DEV
+#define GETMNTINFO_USES_STATVFS
+#endif
 #endif
 #include "vobcopy.h"
 #if (defined(__sun__))
@@ -61,9 +70,10 @@
   int  filehandle = 0;
   int  i = 0, last = 0;
   int  bytes_read;
+  char help[2048];
   
   /* open the device */
-  if ( !(filehandle = open(device, O_RDONLY)) )
+  if ( !(filehandle = open(device, O_RDONLY, 0)) )
   {
       /* open failed */
       fprintf( stderr, "[Error] something wrong in dvd_name getting - please specify path as /cdrom or /dvd (mount point) or use -t\n");
@@ -72,7 +82,7 @@
   }
   
   /* seek to title of first track, which is at (track_no * 32768) + 40 */
-  if ( 32808 != lseek( filehandle, 32808, SEEK_SET ) ) 
+  if ( 32768 != lseek( filehandle, 32768, SEEK_SET ) ) 
   {
       /* seek failed */
       close( filehandle );
@@ -82,13 +92,15 @@
   }
   
   /* read title */
-  if ( (bytes_read = read(filehandle, title, 32)) != 32) 
+  if ( (bytes_read = read(filehandle, help, 2048)) != 2048) 
   {
       close(filehandle);
       fprintf( stderr, "[Error] something wrong in dvd_name getting - please specify path as /cdrom or /dvd (mount point) or use -t\n" );
-      fprintf(stderr, "[Error] only read %d bytes instead of 32\n", bytes_read);
+      fprintf(stderr, "[Error] only read %d bytes instead of 2048\n", bytes_read);
       return -1;
   }
+
+  memcpy(title, help + 40, 32);
   
   /* make sure string is terminated */
   title[32] = '\0';
@@ -138,9 +150,12 @@
   char  *k;
   bool  mounted = FALSE;
   int mntcheck;
-#if ( defined( BSD ) && ( BSD >= 199306 ) ) || ( defined( __APPLE__ ) && defined( __GNUC__ ) )
+#ifdef USE_STATFS_FOR_DEV
   struct statfs buf;
 #endif
+#ifdef USE_STATVFS_FOR_DEV
+  struct statvfs buf;
+#endif
 
 
   /* the string should have no trailing / */
@@ -166,12 +181,19 @@
     /*
      *look through /etc/mtab to see if it's actually mounted
      */
-#if ( defined( BSD ) && ( BSD >= 199306 ) )  || ( defined( __APPLE__ ) && defined( __GNUC__ ) )
+#if defined(USE_STATFS_FOR_DEV) || defined(USE_STATVFS_FOR_DEV)
+#ifdef USE_STATFS_FOR_DEV
     if( !statfs( path, &buf ) )
+#else
+    if( !statvfs( path, &buf ) )
+#endif
       {
        if( !strcmp( path, buf.f_mntonname ) )
          {
            mounted = TRUE;
+	   strcpy(device, "/dev/r");
+	   strcat(device, buf.f_mntfromname + 5);
+	   return mounted;
          }
       }
     else
@@ -366,9 +388,13 @@
 /* returns <0 if error                            */
 int get_device_oyo( char *path, char *device )
 { /*oyo*/
-#if (defined(BSD) && (BSD >= 199306)) || (defined(__APPLE__) && defined(__GNUC__))
+#ifdef USE_GETMNTINFO
   int i, n, dvd_count = 0;
+#ifdef GETMNTINFO_USES_STATFS
   struct statfs *mntbuf;
+#else
+  struct statvfs *mntbuf;
+#endif
 
   if( ( n = getmntinfo( &mntbuf, MNT_WAIT ) ) > 0 )
     {
@@ -378,7 +404,8 @@
             {
               dvd_count++;
               strcpy( path, mntbuf[i].f_mntonname );
-              strcpy( device, mntbuf[i].f_mntfromname );
+	      strcpy(device, "/dev/r");
+	      strcat(device, mntbuf[i].f_mntfromname + 5);
             }
         }
       if(dvd_count == 0)