File: superformat-devfs_floppy.patch

package info (click to toggle)
fdutils 5.6-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,540 kB
  • sloc: ansic: 6,334; sh: 3,570; makefile: 262; sed: 4
file content (51 lines) | stat: -rw-r--r-- 1,266 bytes parent folder | download | duplicates (3)
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
Subject: [superformat] Use /dev/floppy/%d instead of /dev/fd%d on devfs-systems
Author: Jochen Voss <voss@debian.org>
Bug-Debian: http://bugs.debian.org/110225
Last-Update: 2021-01-30
--- a/src/superformat.c
+++ b/src/superformat.c
@@ -487,6 +487,21 @@
 
 #define DRIVE_DEFAULTS (drive_defaults[drivedesc.type.cmos])
 
+static int
+file_exists (const char *filename)
+{
+  struct stat  buf;
+  int  res;
+  res = stat (filename, &buf);
+  if (! res)  return 1;
+  if (res && errno != ENOENT) {
+    fprintf (stderr, "error: cannot stat %s (%s)\n",
+	     filename, strerror (errno));
+    exit (1);
+  }
+  return 0;
+}
+
 int main(int argc, char **argv)
 {
 	int nseqs; /* number of sequences used */
@@ -495,7 +510,7 @@
 	struct params fd[MAX_SECTORS], fd0;
 	int ch,i;
 	short density = DENS_UNKNOWN;
-	char drivename[10];
+	char drivename[15];
 
 	int have_geom = 0;
 	int margin=50;
@@ -771,7 +786,12 @@
 				ioctl(fd[0].fd, FDGETPRM, &geometry);
 			have_geom = 1;
 			close(fd[0].fd);
-			snprintf(drivename,9,"/dev/fd%d", fd[0].drive);
+
+			if (file_exists ("/dev/.devfsd")) {
+			  snprintf(drivename,14,"/dev/floppy/%d", fd[0].drive);
+			} else {
+			  snprintf(drivename,9,"/dev/fd%d", fd[0].drive);
+			}
 			fd[0].name = drivename;
 			continue;
 		}