Lines 1-6
Link Here
|
1 |
--- lib/device.c.orig Sat Oct 13 00:20:05 2001 |
1 |
--- lib/device.c.orig Sat Jan 24 01:52:56 2004 |
2 |
+++ lib/device.c Sun Mar 24 10:31:41 2002 |
2 |
+++ lib/device.c Sun Jan 25 00:07:02 2004 |
3 |
@@ -209,7 +209,7 @@ |
3 |
@@ -78,6 +78,12 @@ |
|
|
4 |
# include <sys/ioctl.h> /* ioctl */ |
5 |
# include <sys/disklabel.h> |
6 |
# include <sys/cdio.h> /* CDIOCCLRDEBUG */ |
7 |
+#if defined(__FreeBSD__) |
8 |
+#include <sys/param.h> |
9 |
+#if __FreeBSD_version >= 500040 |
10 |
+#include <sys/disk.h> |
11 |
+#endif |
12 |
+#endif |
13 |
#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */ |
14 |
|
15 |
#ifdef HAVE_OPENDISK |
16 |
@@ -123,6 +129,7 @@ |
17 |
/* FreeBSD, NetBSD or OpenBSD */ |
18 |
{ |
19 |
struct disklabel hdg; |
20 |
+#if __FreeBSD_version < 500040 |
21 |
if (ioctl (fd, DIOCGDINFO, &hdg)) |
22 |
goto fail; |
23 |
|
24 |
@@ -131,6 +138,38 @@ |
25 |
geom->sectors = hdg.d_nsectors; |
26 |
geom->total_sectors = hdg.d_secperunit; |
27 |
|
28 |
+#else |
29 |
+ u_int u, secsize; |
30 |
+ off_t mediasize; |
31 |
+ |
32 |
+ if(ioctl(fd, DIOCGSECTORSIZE, &secsize) != 0) |
33 |
+ secsize = 512; |
34 |
+ |
35 |
+ if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) != 0) |
36 |
+ goto fail; |
37 |
+ |
38 |
+ hdg.d_secperunit = mediasize / secsize; |
39 |
+ |
40 |
+ if (ioctl(fd, DIOCGFWSECTORS, &u) == 0) |
41 |
+ hdg.d_nsectors = u; |
42 |
+ else |
43 |
+ hdg.d_nsectors = 63; |
44 |
+ if (ioctl(fd, DIOCGFWHEADS, &u) == 0) |
45 |
+ hdg.d_ntracks = u; |
46 |
+ else if (hdg.d_secperunit <= 63*1*1024) |
47 |
+ hdg.d_ntracks = 1; |
48 |
+ else if (hdg.d_secperunit <= 63*16*1024) |
49 |
+ hdg.d_ntracks = 16; |
50 |
+ else |
51 |
+ hdg.d_ntracks = 255; |
52 |
+ hdg.d_secpercyl = hdg.d_ntracks * hdg.d_nsectors; |
53 |
+ hdg.d_ncylinders = hdg.d_secperunit / hdg.d_secpercyl; |
54 |
+ |
55 |
+ geom->cylinders = hdg.d_ncylinders; |
56 |
+ geom->heads = hdg.d_ntracks; |
57 |
+ geom->sectors = hdg.d_nsectors; |
58 |
+ geom->total_sectors = hdg.d_secperunit; |
59 |
+#endif |
60 |
close (fd); |
61 |
return; |
62 |
} |
63 |
@@ -233,7 +272,7 @@ |
4 |
#elif defined(__FreeBSD__) |
64 |
#elif defined(__FreeBSD__) |
5 |
/* FreeBSD */ |
65 |
/* FreeBSD */ |
6 |
# if __FreeBSD__ >= 4 |
66 |
# if __FreeBSD__ >= 4 |
Lines 9-20
Link Here
|
9 |
# else /* __FreeBSD__ <= 3 */ |
69 |
# else /* __FreeBSD__ <= 3 */ |
10 |
sprintf (name, "/dev/rwd%d", unit); |
70 |
sprintf (name, "/dev/rwd%d", unit); |
11 |
# endif /* __FreeBSD__ <= 3 */ |
71 |
# endif /* __FreeBSD__ <= 3 */ |
12 |
@@ -245,7 +245,7 @@ |
72 |
@@ -274,7 +313,11 @@ |
13 |
sprintf (name, "/dev/sd%d", unit); |
73 |
sprintf (name, "/dev/sd%d", unit); |
14 |
#elif defined(__FreeBSD__) |
74 |
#elif defined(__FreeBSD__) |
15 |
/* FreeBSD */ |
75 |
/* FreeBSD */ |
16 |
- sprintf (name, "/dev/rda%d", unit); |
76 |
+# if __FreeBSD__ >= 4 |
17 |
+ sprintf (name, "/dev/da%d", unit); |
77 |
+ sprintf (name, "/dev/da%d", unit); |
|
|
78 |
+# else /* __FreeBSD__ <= 3 */ |
79 |
sprintf (name, "/dev/rda%d", unit); |
80 |
+# endif /* __FreeBSD__ <= 3 */ |
18 |
#elif defined(__NetBSD__) && defined(HAVE_OPENDISK) |
81 |
#elif defined(__NetBSD__) && defined(HAVE_OPENDISK) |
19 |
/* NetBSD */ |
82 |
/* NetBSD */ |
20 |
char shortname[16]; |
83 |
char shortname[16]; |