aboutsummaryrefslogtreecommitdiff
path: root/sysutils/linuxfdisk/files/patch-FreeBSD
blob: 4885c5491eac4a5dd2d243b578754523518b4fe9 (plain) (blame)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
diff -rNu cfdisk.c cfdisk.c
--- cfdisk.c	Tue Nov 26 18:44:33 2002
+++ cfdisk.c	Fri Jun 20 19:47:15 2003
@@ -76,25 +76,14 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include <linux/types.h>
 
 #include "nls.h"
-#include "xstrncpy.h"
 #include "common.h"
 
-#if defined(__GNUC__) || defined(HAS_LONG_LONG)
-typedef long long ext2_loff_t;
-#else
-typedef long      ext2_loff_t;
-#endif
-
-extern ext2_loff_t ext2_llseek(unsigned int fd, ext2_loff_t offset,
-			       unsigned int origin);
-
 #define VERSION UTIL_LINUX_VERSION
 
-#define DEFAULT_DEVICE "/dev/hda"
-#define ALTERNATE_DEVICE "/dev/sda"
+#define DEFAULT_DEVICE "/dev/ada0"
+#define ALTERNATE_DEVICE "/dev/da0"
 
 /* With K=1024 we have `binary' megabytes, gigabytes, etc.
    Some misguided hackers like that.
@@ -324,7 +313,8 @@
 int logical = 0;
 int logical_sectors[MAXIMUM_PARTS];
 
-__sighandler_t old_SIGINT, old_SIGTERM;
+void (*old_SIGINT)(int);
+void (*old_SIGTERM)(int);
 
 int arrow_cursor = FALSE;
 int display_units = MEGABYTES;
@@ -571,7 +561,7 @@
 
 static void
 read_sector(char *buffer, int sect_num) {
-    if (ext2_llseek(fd, ((ext2_loff_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0)
+    if (lseek(fd, ((off_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0)
 	fatal(_("Cannot seek on disk drive"), 2);
     if (read(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE)
 	fatal(_("Cannot read disk drive"), 2);
@@ -579,7 +569,7 @@
 
 static void
 write_sector(char *buffer, int sect_num) {
-    if (ext2_llseek(fd, ((ext2_loff_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0)
+    if (lseek(fd, ((off_t) sect_num)*SECTOR_SIZE, SEEK_SET) < 0)
 	fatal(_("Cannot seek on disk drive"), 2);
     if (write(fd, buffer, SECTOR_SIZE) != SECTOR_SIZE)
 	fatal(_("Cannot write disk drive"), 2);
@@ -603,11 +593,11 @@
 #define DOS_OSTYPE_SZ 8
 #define DOS_LABEL_SZ 11
 #define DOS_FSTYPE_SZ 8
-	ext2_loff_t offset;
+	off_t offset;
 
-	offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
+	offset = ((off_t) p_info[i].first_sector + p_info[i].offset)
 		* SECTOR_SIZE;
-	if (ext2_llseek(fd, offset, SEEK_SET) == offset
+	if (lseek(fd, offset, SEEK_SET) == offset
 	    && read(fd, &sector, sizeof(sector)) == sizeof(sector)) {
 		dos_copy_to_info(p_info[i].ostype, OSTYPESZ,
 				 sector+DOS_OSTYPE_OFFSET, DOS_OSTYPE_SZ);
@@ -664,12 +654,12 @@
 	} xfsb;
 
 	char *label;
-	ext2_loff_t offset;
+	off_t offset;
 	int j;
 
-	offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
+	offset = ((off_t) p_info[i].first_sector + p_info[i].offset)
 		* SECTOR_SIZE + 1024;
-	if (ext2_llseek(fd, offset, SEEK_SET) == offset
+	if (lseek(fd, offset, SEEK_SET) == offset
 	    && read(fd, &e2fsb, sizeof(e2fsb)) == sizeof(e2fsb)
 	    && e2fsb.s_magic[0] + (e2fsb.s_magic[1]<<8) == EXT2_SUPER_MAGIC) {
 		label = e2fsb.s_volume_name;
@@ -684,9 +674,9 @@
 		return;
 	}
 
-	offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
+	offset = ((off_t) p_info[i].first_sector + p_info[i].offset)
 		* SECTOR_SIZE + 0;
-	if (ext2_llseek(fd, offset, SEEK_SET) == offset
+	if (lseek(fd, offset, SEEK_SET) == offset
 	    && read(fd, &xfsb, sizeof(xfsb)) == sizeof(xfsb)
 	    && !strcmp(xfsb.s_magic, XFS_SUPER_MAGIC)) {
 		label = xfsb.s_fname;
@@ -698,9 +688,9 @@
 	}
 
 	/* reiserfs? */
-	offset = ((ext2_loff_t) p_info[i].first_sector + p_info[i].offset)
+	offset = ((off_t) p_info[i].first_sector + p_info[i].offset)
 		* SECTOR_SIZE + REISERFS_DISK_OFFSET_IN_BYTES;
-	if (ext2_llseek(fd, offset, SEEK_SET) == offset
+	if (lseek(fd, offset, SEEK_SET) == offset
 	    && read(fd, &reiserfsb, 1024) == 1024
 	    && is_reiserfs_magic_string(&reiserfsb)) {
 		strncpy(p_info[i].fstype, "reiserfs", FSTYPESZ);
@@ -1140,7 +1130,7 @@
             print_warning(_("Menu item too long. Menu may look odd."));
 #endif
 	if (lenName >= sizeof(buff)) {	/* truncate ridiculously long string */
-	    xstrncpy(buff, mi, sizeof(buff));
+	    strlcpy(buff, mi, sizeof(buff));
 	} else {
             snprintf(buff, sizeof(buff),
 		     (menuType & MENU_BUTTON) ? "[%*s%-*s]" : "%*s%-*s",
@@ -1605,17 +1595,7 @@
 	 opentype = O_RDWR;
     opened = TRUE;
 
-    /* Blocks are visible in more than one way:
-       e.g. as block on /dev/hda and as block on /dev/hda3
-       By a bug in the Linux buffer cache, we will see the old
-       contents of /dev/hda when the change was made to /dev/hda3.
-       In order to avoid this, discard all blocks on /dev/hda.
-       Note that partition table blocks do not live in /dev/hdaN,
-       so this only plays a role if we want to show volume labels. */
-    ioctl(fd, BLKFLSBUF);	/* ignore errors */
-				/* e.g. Permission Denied */
-
-    if (ioctl(fd, BLKGETSIZE, &actual_size))
+    if (sys_bsd_getsectors(fd, &actual_size))
 	fatal(_("Cannot get disk size"), 3);
 
     read_sector(buffer.c.b, 0);
@@ -1824,7 +1804,7 @@
     if (is_bdev) {
 	 sync();
 	 sleep(2);
-	 if (!ioctl(fd,BLKRRPART))
+	 if (!sys_bsd_ptsync(fd))
 	      changed = TRUE;
 	 sync();
 	 sleep(4);
@@ -2850,9 +2830,11 @@
     int c;
     int i, len;
 
+#if 0
     setlocale(LC_ALL, "");
     bindtextdomain(PACKAGE, LOCALEDIR);
     textdomain(PACKAGE);
+#endif
 
     while ((c = getopt(argc, argv, "ac:gh:s:vzP:")) != -1)
 	switch (c) {
diff -rNu common.h common.h
--- common.h	Thu May  9 02:50:35 2002
+++ common.h	Fri Jun 20 19:25:55 2003
@@ -1,11 +1,10 @@
 /* common stuff for fdisk, cfdisk, sfdisk */
 
-/* including <linux/fs.h> fails */
-#include <sys/ioctl.h>
-#define BLKRRPART  _IO(0x12,95)    /* re-read partition table */
-#define BLKGETSIZE _IO(0x12,96)    /* return device size */
-#define BLKFLSBUF  _IO(0x12,97)    /* flush buffer cache */
-#define BLKSSZGET  _IO(0x12,104)   /* get block device sector size */
+#include <sys/types.h>
+typedef u_int16_t __u16;
+typedef u_int32_t __u32;
+typedef int16_t __s16;
+typedef u_int8_t __u8;
 
 /* including <linux/hdreg.h> also fails */
 struct hd_geometry {
@@ -15,9 +14,6 @@
       unsigned long start;
 };
 
-#define HDIO_GETGEO		0x0301	/* get device geometry */
-
-
 struct systypes {
 	unsigned char type;
 	char *name;
@@ -26,3 +22,8 @@
 extern struct systypes i386_sys_types[];
 
 extern char *partname(char *dev, int pno, int lth);
+
+unsigned int sys_bsd_sectorsize(int fd);
+int sys_bsd_getsectors(int fd, unsigned long* s);
+int sys_bsd_ptsync(int fd);
+int sys_bsd_getgeometry(int, struct hd_geometry*);
diff -rNu fdisk.c fdisk.c
--- fdisk.c	Sat Nov 23 18:05:24 2002
+++ fdisk.c	Fri Jun 20 19:25:55 2003
@@ -37,11 +37,6 @@
 #include "fdisksgilabel.h"
 #include "fdiskaixlabel.h"
 
-#include "../defines.h"
-#ifdef HAVE_blkpg_h
-#include <linux/blkpg.h>
-#endif
-
 static void delete_partition(int i);
 
 #define hex_val(c)	({ \
@@ -194,23 +189,21 @@
 
 	switch (why) {
 		case usage: message = _(
-"Usage: fdisk [-b SSZ] [-u] DISK     Change partition table\n"
-"       fdisk -l [-b SSZ] [-u] DISK  List partition table(s)\n"
-"       fdisk -s PARTITION           Give partition size(s) in blocks\n"
-"       fdisk -v                     Give fdisk version\n"
-"Here DISK is something like /dev/hdb or /dev/sda\n"
-"and PARTITION is something like /dev/hda7\n"
+"Usage: fdisk-linux [-b SSZ] [-u] DISK     Change partition table\n"
+"       fdisk-linux -l [-b SSZ] [-u] DISK  List partition table(s)\n"
+"       fdisk-linux -s PARTITION           Give partition size(s) in blocks\n"
+"       fdisk-linux -v                     Give fdisk version\n"
+"Here DISK is something like /dev/ada1 or /dev/da0\n"
+"and PARTITION is something like /dev/ada0s7\n"
 "-u: give Start and End in sector (instead of cylinder) units\n"
 "-b 2048: (for certain MO disks) use 2048-byte sectors\n");
 			break;
 		case usage2:
 		  /* msg in cases where fdisk used to probe */
 			message = _(
-"Usage: fdisk [-l] [-b SSZ] [-u] device\n"
-"E.g.: fdisk /dev/hda  (for the first IDE disk)\n"
-"  or: fdisk /dev/sdc  (for the third SCSI disk)\n"
-"  or: fdisk /dev/eda  (for the first PS/2 ESDI drive)\n"
-"  or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)\n"
+"Usage: fdisk-linux [-l] [-b SSZ] [-u] device\n"
+"E.g.: fdisk-linux /dev/ada0  (for the first IDE disk)\n"
+"  or: fdisk-linux /dev/da2  (for the third SCSI disk)\n"
 "  ...\n");
 			break;
 		case unable_to_open:
@@ -231,7 +224,7 @@
 			break;
 		case ioctl_error:
 			snprintf(error, sizeof(error),
-				 _("BLKGETSIZE ioctl failed on %s\n"),
+				 _("DIOCGDINFO ioctl failed on %s\n"),
 				disk_device);
 			break;
 		case out_of_memory:
@@ -248,8 +241,8 @@
 
 static void
 seek_sector(int fd, uint secno) {
-	ext2_loff_t offset = (ext2_loff_t) secno * sector_size;
-	if (ext2_llseek(fd, offset, SEEK_SET) == (ext2_loff_t) -1)
+	off_t offset = (off_t) secno * sector_size;
+	if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
 		fatal(unable_to_seek);
 }
 
@@ -725,53 +718,23 @@
 	get_boot(create_empty_dos);
 }
 
-#include <sys/utsname.h>
-#define MAKE_VERSION(p,q,r)     (65536*(p) + 256*(q) + (r))
-
-static int
-linux_version_code(void) {
-	static int kernel_version = 0;
-        struct utsname my_utsname;
-        int p, q, r;
-
-        if (!kernel_version && uname(&my_utsname) == 0) {
-                p = atoi(strtok(my_utsname.release, "."));
-                q = atoi(strtok(NULL, "."));
-                r = atoi(strtok(NULL, "."));
-                kernel_version = MAKE_VERSION(p,q,r);
-        }
-        return kernel_version;
-}
-
 static void
 get_sectorsize(int fd) {
-#if defined(BLKSSZGET)
-	if (!user_set_sector_size &&
-	    linux_version_code() >= MAKE_VERSION(2,3,3)) {
-		int arg;
-		if (ioctl(fd, BLKSSZGET, &arg) == 0)
-			sector_size = arg;
-		if (sector_size != DEFAULT_SECTOR_SIZE)
-			printf(_("Note: sector size is %d (not %d)\n"),
-			       sector_size, DEFAULT_SECTOR_SIZE);
-	}
-#else
-	/* maybe the user specified it; and otherwise we still
-	   have the DEFAULT_SECTOR_SIZE default */
-#endif
+	unsigned int r = sys_bsd_sectorsize(fd);
+	if (r)
+		sector_size = r;
+	if (sector_size != DEFAULT_SECTOR_SIZE)
+		printf(_("Note: sector size is %d (not %d)\n"),
+		       sector_size, DEFAULT_SECTOR_SIZE);
 }
 
 static void
 get_kernel_geometry(int fd) {
-#ifdef HDIO_GETGEO
-	struct hd_geometry geometry;
-
-	if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
-		kern_heads = geometry.heads;
-		kern_sectors = geometry.sectors;
-		/* never use geometry.cylinders - it is truncated */
+	struct hd_geometry h;
+	if (!sys_bsd_getgeometry(fd, &h)) {
+		kern_heads = h.heads;
+		kern_sectors = h.sectors;
 	}
-#endif
 }
 
 static void
@@ -813,7 +776,7 @@
 
 	get_sectorsize(fd);
 	sec_fac = sector_size / 512;
-	guess_device_type(fd);
+	//guess_device_type(fd);
 	heads = cylinders = sectors = 0;
 	kern_heads = kern_sectors = 0;
 	pt_heads = pt_sectors = 0;
@@ -828,8 +791,11 @@
 		pt_sectors ? pt_sectors :
 		kern_sectors ? kern_sectors : 63;
 
-	if (ioctl(fd, BLKGETSIZE, &longsectors))
-		longsectors = 0;
+	;{
+		unsigned long r;
+		if (sys_bsd_getsectors(fd, &r) == 0)
+			longsectors = r;
+	}
 
 	sector_offset = 1;
 	if (dos_compatible_flag)
@@ -1404,7 +1370,7 @@
  * Jan.  1990 (version 1.2.1 by Gordon W. Ross Aug. 1990; Modified by S.
  * Lubkin Oct.  1991). */
 
-static void long2chs(ulong ls, uint *c, uint *h, uint *s) {
+static void long2chs(unsigned long ls, uint *c, uint *h, uint *s) {
 	int	spc = heads * sectors;
 
 	*c = ls / spc;
@@ -2102,16 +2068,8 @@
 	printf(_("Calling ioctl() to re-read partition table.\n"));
 	sync();
 	sleep(2);
-	if ((i = ioctl(fd, BLKRRPART)) != 0) {
+	if ((i = sys_bsd_ptsync(fd)) != 0) {
                 error = errno;
-        } else {
-                /* some kernel versions (1.2.x) seem to have trouble
-                   rereading the partition table, but if asked to do it
-		   twice, the second time works. - biro@yggdrasil.com */
-                sync();
-                sleep(2);
-                if ((i = ioctl(fd, BLKRRPART)) != 0)
-                        error = errno;
         }
 
 	if (i) {
@@ -2403,9 +2361,11 @@
 	int j, c;
 	int optl = 0, opts = 0;
 
+#if 0
 	setlocale(LC_ALL, "");
 	bindtextdomain(PACKAGE, LOCALEDIR);
 	textdomain(PACKAGE);
+#endif
 
 	/*
 	 * Calls:
@@ -2455,7 +2415,7 @@
 			break;
 		case 'V':
 		case 'v':
-			printf("fdisk v" UTIL_LINUX_VERSION "\n");
+			printf("fdisk v" UTIL_LINUX_VERSION "-freebsd-portbld\n");
 			exit(0);
 		default:
 			fatal(usage);
@@ -2504,7 +2464,7 @@
 			disk_device = argv[j];
 			if ((fd = open(disk_device, type_open)) < 0)
 				fatal(unable_to_open);
-			if (ioctl(fd, BLKGETSIZE, &size))
+			if (sys_bsd_getsectors(fd, &size))
 				fatal(ioctl_error);
 			close(fd);
 			if (opts == 1)
diff -rNu fdisk.h fdisk.h
--- fdisk.h	2001-09-13 23:05:35 UTC
+++ fdisk.h
@@ -101,4 +101,4 @@
 /* prototypes for fdisksgilabel.c */
 extern int valid_part_table_flag(unsigned char *b);
 
-#define PROC_PARTITIONS "/proc/partitions"
+#define PROC_PARTITIONS "/compat/linux/proc/partitions"
diff -rNu fdiskaixlabel.c fdiskaixlabel.c
--- fdiskaixlabel.c	Tue Apr 18 15:21:28 2000
+++ fdiskaixlabel.c	Fri Jun 20 19:25:55 2003
@@ -8,7 +8,7 @@
 #include <string.h>             /* strstr */
 #include <unistd.h>             /* write */
 
-#include <endian.h>
+#include <sys/endian.h>
 
 #include "common.h"
 #include "fdisk.h"
diff -rNu fdiskaixlabel.h fdiskaixlabel.h
--- fdiskaixlabel.h	Sun Feb 20 18:50:51 2000
+++ fdiskaixlabel.h	Fri Jun 20 19:25:55 2003
@@ -1,4 +1,3 @@
-#include <linux/types.h>   /* for __u32 etc */
 /*
  * Copyright (C) Andreas Neuper, Sep 1998.
  *	This file may be redistributed under
diff -rNu fdiskbsdlabel.c fdiskbsdlabel.c
--- fdiskbsdlabel.c	Thu Oct 31 15:43:42 2002
+++ fdiskbsdlabel.c	Fri Jun 20 19:25:55 2003
@@ -566,7 +566,7 @@
   sector = get_start_sect(xbsd_part);
 #endif
 
-  if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
+  if (lseek (fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
     fatal (unable_to_seek);
   if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
     fatal (unable_to_write);
@@ -735,7 +735,7 @@
 	sector = 0;
 #endif
 
-	if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
+	if (lseek (fd, (off_t) sector * SECTOR_SIZE, SEEK_SET) == -1)
 		fatal (unable_to_seek);
 	if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE))
 		fatal (unable_to_read);
@@ -781,12 +781,12 @@
 
 #if defined (__alpha__) && BSD_LABELSECTOR == 0
   alpha_bootblock_checksum (disklabelbuffer);
-  if (ext2_llseek (fd, (ext2_loff_t) 0, SEEK_SET) == -1)
+  if (lseek (fd, (off_t) 0, SEEK_SET) == -1)
     fatal (unable_to_seek);
   if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
     fatal (unable_to_write);
 #else
-  if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE + BSD_LABELOFFSET,
+  if (lseek (fd, (off_t) sector * SECTOR_SIZE + BSD_LABELOFFSET,
 		   SEEK_SET) == -1)
     fatal (unable_to_seek);
   if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel)))
@@ -847,9 +847,11 @@
 
 #if defined (__alpha__)
 
+/*
 #if !defined(__GLIBC__)
 typedef unsigned long long u_int64_t;
 #endif
+*/

 void
 alpha_bootblock_checksum (char *boot)
diff -rNu fdiskbsdlabel.h fdiskbsdlabel.h
--- fdiskbsdlabel.h	Thu Oct 31 15:45:34 2002
+++ fdiskbsdlabel.h	Fri Jun 20 19:25:55 2003
@@ -31,8 +31,6 @@
  * SUCH DAMAGE.
  */
 
-#include <linux/types.h>	/* for __u32, __u16, __u8, __s16 */
-
 #ifndef BSD_DISKMAGIC
 #define BSD_DISKMAGIC     ((__u32) 0x82564557)
 #endif
diff -rNu fdisksgilabel.c fdisksgilabel.c
--- fdisksgilabel.c	Thu May  9 02:51:31 2002
+++ fdisksgilabel.c	Fri Jun 20 19:25:55 2003
@@ -17,9 +17,8 @@
 #include <sys/stat.h>           /* stat */
 #include <assert.h>             /* assert */
 
-#include <endian.h>
+#include <sys/endian.h>
 #include "nls.h"
-#include <linux/major.h>        /* FLOPPY_MAJOR */
 
 #include "common.h"
 #include "fdisk.h"
@@ -382,7 +381,7 @@
 	 */
 	sgiinfo*info = fill_sgiinfo();	/* fills the block appropriately */
 	int infostartblock = SSWAP32( sgilabel->directory[0].vol_file_start );
-	if( ext2_llseek(fd, (ext2_loff_t)infostartblock*
+	if( lseek(fd, (off_t)infostartblock*
 	    SECTOR_SIZE, SEEK_SET) < 0 )
 	    fatal(unable_to_seek);
 	if( write(fd, info, SECTOR_SIZE) != SECTOR_SIZE )
@@ -735,11 +734,7 @@
 
     other_endian = (BYTE_ORDER == LITTLE_ENDIAN);
 
-#ifdef HDIO_REQ
-    if (!ioctl(fd, HDIO_REQ, &geometry))
-#else
-    if (!ioctl(fd, HDIO_GETGEO, &geometry))
-#endif
+    if (!sys_bsd_getgeometry(fd, &geometry))
     {
 	heads = geometry.heads;
 	sectors = geometry.sectors;
diff -rNu fdisksgilabel.h fdisksgilabel.h
--- fdisksgilabel.h	Tue Feb 20 12:26:53 2001
+++ fdisksgilabel.h	Fri Jun 20 19:25:55 2003
@@ -1,4 +1,3 @@
-#include <linux/types.h>   /* for __u32 etc */
 /*
  * Copyright (C) Andreas Neuper, Sep 1998.
  *	This file may be modified and redistributed under
diff -rNu fdisksunlabel.c fdisksunlabel.c
--- fdisksunlabel.c	Fri Nov  1 03:55:25 2002
+++ fdisksunlabel.c	Fri Jun 20 19:25:55 2003
@@ -16,18 +16,18 @@
 #include <unistd.h>		/* write */
 #include <sys/ioctl.h>		/* ioctl */
 #include <sys/stat.h>		/* stat */
-#include <sys/sysmacros.h>	/* major */
+//#include <sys/sysmacros.h>	/* major */
 
 #include "nls.h"
 
-#include <endian.h>
-#include "../defines.h"		/* for HAVE_scsi_h */
+#include <sys/endian.h>
+//#include "../defines.h"		/* for HAVE_scsi_h */
 #ifdef HAVE_scsi_h
 #define u_char	unsigned char
 #include <scsi/scsi.h>		/* SCSI_IOCTL_GET_IDLUN */
 #undef u_char
 #endif
-#include <linux/major.h>	/* FLOPPY_MAJOR */
+//#include <linux/major.h>	/* FLOPPY_MAJOR */
 
 #include "common.h"
 #include "fdisk.h"
@@ -71,6 +71,7 @@
 	return SSWAP32(p.num_sectors);
 }
 
+#if 0
 #ifndef IDE0_MAJOR
 #define IDE0_MAJOR 3
 #endif
@@ -97,6 +98,7 @@
                 floppy = 0;
 	}
 }
+#endif
 
 static void
 set_sun_partition(int i, uint start, uint stop, int sysid) {
@@ -296,11 +298,7 @@
 	    }
 	}
 	if (!p || floppy) {
-#ifdef HDIO_REQ
-	    if (!ioctl(fd, HDIO_REQ, &geometry)) {
-#else
-	    if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
-#endif
+	    if (!sys_bsd_getgeometry(fd, &geometry)) {
 	        heads = geometry.heads;
 	        sectors = geometry.sectors;
 	        cylinders = geometry.cylinders;
diff -rNu fdisksunlabel.h fdisksunlabel.h
--- fdisksunlabel.h	Tue Oct  3 00:42:10 2000
+++ fdisksunlabel.h	Fri Jun 20 19:25:55 2003
@@ -1,4 +1,3 @@
-#include <linux/types.h>   /* for __u16, __u32 */
 
 typedef struct {
 	unsigned char info[128];   /* Informative text string */
diff -rNu nls.h nls.h
--- nls.h	Thu Jan  1 03:00:00 1970
+++ nls.h	Fri Jun 20 19:25:55 2003
@@ -0,0 +1,2 @@
+#define _(x) (x)
+#define N_(x) (x)
diff -rNu partname.c partname.c
--- partname.c	Sun Jul  7 15:16:43 2002
+++ partname.c	Fri Jun 20 19:25:55 2003
@@ -21,14 +21,16 @@
 	p = "";
 
 	if (isdigit(dev[w-1]))
-		p = "p";
+		p = "s";
 
+#if 0
 	/* devfs kludge - note: fdisk partition names are not supposed
 	   to equal kernel names, so there is no reason to do this */
 	if (strcmp (dev + w - 4, "disc") == 0) {
 		w -= 4;
 		p = "part";
 	}
+#endif
 
 	wp = strlen(p);
 		
diff -rNu sfdisk.8 sfdisk.8
--- sfdisk.8	Fri Jun 20 20:37:34 2003
+++ sfdisk.8	Fri Jun 20 20:43:24 2003
@@ -9,9 +9,9 @@
 .SH NAME
 sfdisk \- Partition table manipulator for Linux
 .SH SYNOPSIS
-.BR sfdisk " [options] device"
+.BR sfdisk-linux " [options] device"
 .br
-.BR "sfdisk \-s " [partition]
+.BR "sfdisk-linux \-s " [partition]
 .SH DESCRIPTION
 .B sfdisk
 has four (main) uses: list the size of a partition, list the partitions
@@ -19,7 +19,7 @@
 repartition a device.
 
 .SS "List Sizes"
-.BI "sfdisk \-s " partition
+.BI "sfdisk-linux \-s " partition
 gives the size of
 .I partition
 in blocks. This may be useful in connection with programs like
@@ -27,16 +27,16 @@
 or so. Here
 .I partition
 is usually something like
-.I /dev/hda1
+.I /dev/ada0s1
 or
-.IR /dev/sdb12 ,
+.IR /dev/da2s12 ,
 but may also be an entire disk, like
-.IR /dev/xda .
+.IR /dev/amrd0 .
 .br
 .RS
 .nf
 .if t .ft CW
-% sfdisk \-s /dev/hda9
+% sfdisk-linux \-s /dev/ada0s9
 81599
 %
 .if t .ft R
@@ -49,12 +49,12 @@
 .RS
 .nf
 .if t .ft CW
-% sfdisk \-s
-/dev/hda: 208896
-/dev/hdb: 1025136
-/dev/hdc: 1031063
-/dev/sda: 8877895
-/dev/sdb: 1758927
+% sfdisk-linux \-s
+/dev/ada0: 208896
+/dev/ada1: 1025136
+/dev/ada2: 1031063
+/dev/da0: 8877895
+/dev/da1: 1758927
 total: 12901917 blocks
 %
 .if t .ft R
@@ -70,16 +70,16 @@
 .br
 .nf
 .if t .ft CW
-% sfdisk \-l /dev/hdc
+% sfdisk-linux \-l /dev/ada2
 
-Disk /dev/hdc: 16 heads, 63 sectors, 2045 cylinders
+Disk /dev/ada2: 16 heads, 63 sectors, 2045 cylinders
 Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0
 
    Device Boot Start     End   #cyls   #blocks   Id  System
-/dev/hdc1          0+    406     407\-   205096+  83  Linux native
-/dev/hdc2        407     813     407    205128   83  Linux native
-/dev/hdc3        814    2044    1231    620424   83  Linux native
-/dev/hdc4          0       \-       0         0    0  Empty
+/dev/ada2s1        0+    406     407\-   205096+  83  Linux native
+/dev/ada2s2      407     813     407    205128   83  Linux native
+/dev/ada2s3      814    2044    1231    620424   83  Linux native
+/dev/ada2s4        0       \-       0         0    0  Empty
 %
 .if t .ft R
 .fi
@@ -89,17 +89,17 @@
 
 .SS "Check partitions"
 The third type of invocation:
-.BI "sfdisk \-V " device
+.BI "sfdisk-linux \-V " device
 will apply various consistency checks to the partition tables on
 .IR device .
 It prints `OK' or complains. The \-V option can be used together
 with \-l. In a shell script one might use
-.BI "sfdisk \-V \-q " device
+.BI "sfdisk-linux \-V \-q " device
 which only returns a status.
 
 .SS "Create partitions"
 The fourth type of invocation:
-.BI "sfdisk " device
+.BI "sfdisk-linux " device
 will cause
 .B sfdisk
 to read the specification for the desired partitioning of
@@ -119,7 +119,7 @@
 .RS
 .nf
 .if t .ft CW
-% sfdisk /dev/hdd \-O hdd-partition-sectors.save
+% sfdisk-linux /dev/ada3 \-O ada3-partition-sectors.save
 \&...
 %
 .if t .ft R
@@ -132,7 +132,7 @@
 .RS
 .nf
 .if t .ft CW
-% sfdisk /dev/hdd \-I hdd-partition-sectors.save
+% sfdisk-linux /dev/ada3 \-I ada3-partition-sectors.save
 %
 .if t .ft R
 .fi
@@ -176,8 +176,8 @@
 .br
 .nf
 .if t .ft CW
-    % sfdisk -d /dev/hda > hda.out
-    % sfdisk /dev/hda < hda.out
+    % sfdisk-linux -d /dev/ada0 > ada0.out
+    % sfdisk-linux /dev/ada0 < ada0.out
 .if t .ft R
 .fi
 will correct the bad last extended partition that the OS/2
@@ -194,14 +194,14 @@
 .br
 .nf
 .if t .ft CW
-    % sfdisk /dev/hdb \-N5
+    % sfdisk-linux /dev/ada1 \-N5
     ,,,*
     %
 .if t .ft R
 .fi
-will make the fifth partition on /dev/hdb bootable (`active')
+will make the fifth partition on /dev/ada1 bootable (`active')
 and change nothing else. (Probably this fifth partition
-is called /dev/hdb5, but you are free to call it something else,
+is called /dev/ada1s5, but you are free to call it something else,
 like `/my_equipment/disks/2/5' or so).
 .TP
 .BI \-A "number"
@@ -216,13 +216,13 @@
 .br
 .nf
 .if t .ft CW
-    % sfdisk --print-id /dev/hdb 5
+    % sfdisk-linux --print-id /dev/ada1 5
     6
-    % sfdisk --change-id /dev/hdb 5 83
+    % sfdisk-linux --change-id /dev/ada1 5 83
     OK
 .if t .ft R
 .fi
-first reports that /dev/hdb5 has Id 6, and then changes that into 83.
+first reports that /dev/ada1s5 has Id 6, and then changes that into 83.
 .TP
 .BR \-uS " or " \-uB " or " \-uC " or " \-uM
 Accept or report in units of sectors (blocks, cylinders, megabytes,
@@ -420,7 +420,7 @@
 .RS
 .nf
 .if t .ft CW
-sfdisk /dev/hdc << EOF
+sfdisk-linux /dev/ada2 << EOF
 0,407
 ,407
 ;
@@ -429,7 +429,7 @@
 .if t .ft R
 .fi
 .RE
-will partition /dev/hdc just as indicated above.
+will partition /dev/ada2 just as indicated above.
 
 With the \-x option, the number of input lines must be a multiple of 4:
 you have to list the two empty partitions that you never want
@@ -456,9 +456,9 @@
 .B dd
 to zero the first 512 bytes of that partition before using DOS FORMAT to
 format the partition.  For example, if you were using sfdisk to make a DOS
-partition table entry for /dev/hda1, then (after exiting sfdisk and
+partition table entry for /dev/ada0s1, then (after exiting sfdisk and
 rebooting Linux so that the partition table information is valid) you
-would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero
+would use the command "dd if=/dev/zero of=/dev/ada0s1 bs=512 count=1" to zero
 the first 512 bytes of the partition.
 .B BE EXTREMELY CAREFUL
 if you use the
@@ -508,7 +508,7 @@
 
 .SH BUGS
 A corresponding interactive
-.B cfdisk
+.B cfdisk-linux
 (with curses interface) is still lacking.
 .LP
 There are too many options.
@@ -519,7 +519,7 @@
 A. E. Brouwer (aeb@cwi.nl)
 
 .SH "SEE ALSO"
-.BR cfdisk (8),
+.BR cfdisk-linux (8),
+.BR fdisk-linux (8),
 .BR fdisk (8),
-.BR mkfs (8),
-.BR parted (8)
+.BR newfs (8)
diff -rNu cfdisk.8 cfdisk.8
--- cfdisk.8	Sun Jul  7 15:28:27 2002
+++ cfdisk.8	Fri Jun 20 20:57:52 2003
@@ -15,7 +15,7 @@
 .SH NAME
 cfdisk \- Curses based disk partition table manipulator for Linux
 .SH SYNOPSIS
-.BI "cfdisk [ \-agvz ] [ \-c " cylinders " ] [ \-h " heads " ]"
+.BI "cfdisk-linux [ \-agvz ] [ \-c " cylinders " ] [ \-h " heads " ]"
 .BI "[ \-s " sectors-per-track " ] [ -P " opt " ] [ " device " ]"
 .SH DESCRIPTION
 .B cfdisk
@@ -26,12 +26,10 @@
 .sp
 .nf
 .RS
-/dev/hda [default]
-/dev/hdb
-/dev/sda
-/dev/sdb
-/dev/sdc
-/dev/sdd
+/dev/ada0 [default]
+/dev/ada1
+/dev/da0
+/dev/da1
 .RE
 .fi
 
@@ -132,9 +130,9 @@
 .B dd
 to zero the first 512 bytes of that partition before using DOS FORMAT to
 format the partition.  For example, if you were using cfdisk to make a DOS
-partition table entry for /dev/hda1, then (after exiting fdisk or cfdisk
+partition table entry for /dev/ada0s1, then (after exiting fdisk or cfdisk
 and rebooting Linux so that the partition table information is valid) you
-would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero
+would use the command "dd if=/dev/zero of=/dev/ada0s1 bs=512 count=1" to zero
 the first 512 bytes of the partition. Note:
 
 .B BE EXTREMELY CAREFUL
@@ -418,10 +416,10 @@
 0: No errors; 1: Invocation error; 2: I/O error;
 3: cannot get geometry; 4: bad partition table on disk.
 .SH "SEE ALSO"
+.BR fdisk-linux (8),
+.BR newfs (8),
 .BR fdisk (8),
-.BR mkfs (8),
-.BR parted (8),
-.BR sfdisk (8)
+.BR sfdisk-linux (8)
 .SH BUGS
 The current version does not support multiple disks.
 .SH AUTHOR
diff -rNu fdisk.8 fdisk.8
--- fdisk.8	Tue Aug  6 17:33:33 2002
+++ fdisk.8	Fri Jun 20 21:01:24 2003
@@ -5,14 +5,14 @@
 .SH NAME
 fdisk \- Partition table manipulator for Linux
 .SH SYNOPSIS
-.BI "fdisk [\-u] [\-b " sectorsize ]
+.BI "fdisk-linux [\-u] [\-b " sectorsize ]
 .BI "[\-C " cyls "] [\-H " heads "] [\-S " sects "] " device
 .sp
-.BI "fdisk \-l [\-u] [" "device ..." ]
+.BI "fdisk-linux \-l [\-u] [" "device ..." ]
 .sp
-.BI "fdisk \-s " "partition ..."
+.BI "fdisk-linux \-s " "partition ..."
 .sp
-.BI "fdisk \-v
+.BI "fdisk-linux \-v
 .SH DESCRIPTION
 Hard disks can be divided into one or more logical disks called
 .IR partitions .
@@ -48,26 +48,22 @@
 .br
 .nf
 .RS
-/dev/hda
-/dev/hdb
-/dev/sda
-/dev/sdb
+/dev/ada0
+/dev/ada1
+/dev/da0
+/dev/da1
 .RE
 .fi
-(/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks,
-/dev/ed[a-d] for ESDI disks, /dev/xd[ab] for XT disks).
+(/dev/adaN for IDE disks, /dev/daN for SCSI disks, N=0,1,2...)
 A device name refers to the entire disk.
 
 The
 .I partition
 is a
 .I device
-name followed by a partition number.  For example,
-.B /dev/hda1
+name followed by 's' and a partition number.  For example,
+.B /dev/ada0s1
 is the first partition on the first IDE hard disk in the system.
-IDE disks can have up to 63 partitions, SCSI disks up to 15.
-See also
-.IR /usr/src/linux/Documentation/devices.txt .
 
 A BSD/SUN type disklabel can describe 8 partitions,
 the third of which should be a `whole disk' partition.
@@ -132,7 +128,7 @@
 Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but
 this is unlikely to cause difficulty unless you have OS/2 on your machine.
 
-A sync() and a BLKRRPART ioctl() (reread partition table from disk)
+A sync() and a sys_bsd_ptsync() (reread partition table from disk)
 are performed before exiting when the partition table has been updated.
 Long ago it used to be necessary to reboot after the use of fdisk.
 I do not think this is the case anymore - indeed, rebooting too quickly
@@ -242,7 +238,7 @@
 .\" Andreas Neuper (ANeuper@GUUG.de)
 .\" and many others.
 .SH "SEE ALSO"
-.BR cfdisk (8),
-.BR mkfs (8),
-.BR parted (8),
-.BR sfdisk (8)
+.BR cfdisk_linux (8),
+.BR newfs (8),
+.BR fdisk (8),
+.BR sfdisk_linux (8)
diff -rNu sfdisk.c sfdisk.c
--- sfdisk.c	Tue Jan 28 20:18:03 2003
+++ sfdisk.c	Tue Jun 24 01:10:28 2003
@@ -30,7 +30,7 @@
  * 19990319 - Arnaldo Carvalho de Melo <acme@conectiva.com.br> - i18n
  */
 
-#define PROGNAME "sfdisk"
+#define PROGNAME "sfdisk-linux"
 #define VERSION "3.07"
 #define DATE "990908"
 
@@ -42,11 +42,9 @@
 #include <errno.h>		/* ERANGE */
 #include <string.h>		/* index() */
 #include <ctype.h>
-#include <getopt.h>
+#include "getopt.h"
 #include <sys/ioctl.h>
 #include <sys/stat.h>
-#include <sys/utsname.h>
-#include <linux/unistd.h>	/* _syscall */
 #include "nls.h"
 #include "common.h"
 
@@ -130,23 +128,14 @@
  *
  * Note: we use 512-byte sectors here, irrespective of the hardware ss.
  */
-#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) && !defined (__s390x__)
-static
-_syscall5(int,  _llseek,  uint,  fd, ulong, hi, ulong, lo,
-       loff_t *, res, uint, wh);
-#endif
 
 static int
 sseek(char *dev, unsigned int fd, unsigned long s) {
-    loff_t in, out;
-    in = ((loff_t) s << 9);
+    off_t in, out;
+    in = ((off_t) s << 9);
     out = 1;
 
-#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) && !defined (__s390x__)
-    if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0) {
-#else
     if ((out = lseek(fd, in, SEEK_SET)) != in) {
-#endif
 	perror("llseek");
 	error(_("seek error on %s - cannot seek to %lu\n"), dev, s);
 	return 0;
@@ -399,12 +388,13 @@
     long size;
     struct geometry R;
 
-    if (ioctl(fd, BLKGETSIZE, &size)) {
+    if (sys_bsd_getsectors(fd, (unsigned long*) &size)) {
 	size = 0;
 	if (!silent)
 	    printf(_("Disk %s: cannot get size\n"), dev);
     }
-    if (ioctl(fd, HDIO_GETGEO, &g)) {
+    g.start = 0; /* XXX ?????????? */
+    if (sys_bsd_getgeometry(fd, &g)) {
 	g.heads = g.sectors = g.cylinders = g.start = 0;
 	if (!silent)
 	    printf(_("Disk %s: cannot get geometry\n"), dev);
@@ -721,8 +711,8 @@
 /* tell the kernel to reread the partition tables */
 static int
 reread_ioctl(int fd) {
-    if(ioctl(fd, BLKRRPART)) {
-	perror("BLKRRPART");
+    if(sys_bsd_ptsync(fd)) {
+	perror("sys_bsd_ptsync");
 	return -1;
     }
     return 0;
@@ -1428,22 +1418,6 @@
 	z->partno = pno;
 }
 
-#define MAKE_VERSION(p,q,r)     (65536*(p) + 256*(q) + (r))
-
-static int
-linux_version_code(void) {
-        struct utsname my_utsname;
-        int p, q, r;
-
-        if (uname(&my_utsname) == 0) {
-                p = atoi(strtok(my_utsname.release, "."));
-                q = atoi(strtok(NULL, "."));
-                r = atoi(strtok(NULL, "."));
-                return MAKE_VERSION(p,q,r);
-        }
-        return 0;
-}
-
 static int
 msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) {
     int i;
@@ -1452,7 +1426,10 @@
     struct sector *s;
     struct part_desc *partitions = &(z->partitions[0]);
     int pno = z->partno;
-    int bsd_later = (linux_version_code() >= MAKE_VERSION(2,3,40));
+    /* Under FreeBSD, "bsd later" is always true because BSD partitions
+     * in MBR or MBREXT partitions doesn't be listed immediately.
+     */
+    int bsd_later = 1;
 
     if (!(s = get_sector(dev, fd, start)))
 	return 0;
@@ -1501,6 +1478,8 @@
 	    }
 	    extended_partition(dev, fd, &partitions[i], z);
 	}
+#if 0
+/* FreeBSD port: don't count partitions as they won't be list as slices */
 	if (!bsd_later && is_bsd(partitions[i].p.sys_type)) {
 	    if (!partitions[i].size) {
 		printf(_("strange..., a BSD partition of size 0?\n"));
@@ -1508,8 +1487,11 @@
 	    }
 	    bsd_partition(dev, fd, &partitions[i], z);
 	}
+#endif
     }
 
+#if 0
+/* FreeBSD port: don't count partitions as they won't be list as slices */
     if (bsd_later) {
 	for (i=0; i<4; i++) {
 	    if (is_bsd(partitions[i].p.sys_type)) {
@@ -1521,6 +1503,7 @@
 	    }
 	}
     }
+#endif
 	    
     return 1;
 }
@@ -2229,7 +2212,7 @@
 usage(void) {
     version();
     printf(_("Usage: %s [options] device ...\n"), PROGNAME);
-    puts (_("device: something like /dev/hda or /dev/sda"));
+    puts (_("device: something like /dev/ada0 or /dev/da0"));
     puts (_("useful options:"));
     puts (_("    -s [or --show-size]: list size of a partition"));
     puts (_("    -c [or --id]:        print or change partition Id"));
@@ -2353,7 +2336,7 @@
 	return is_ide;
 }
 
-#define PROC_PARTITIONS	"/proc/partitions"
+#define PROC_PARTITIONS	"/compat/linux/proc/partitions"
 static FILE *procf = NULL;
 
 static void
@@ -2413,9 +2396,11 @@
     char *activatearg = 0;
     char *unhidearg = 0;
 
+#if 0
     setlocale(LC_ALL, "");
     bindtextdomain(PACKAGE, LOCALEDIR);
     textdomain(PACKAGE);
+#endif
 
     if (argc < 1)
       fatal(_("no command?\n"));
@@ -2543,9 +2528,9 @@
 
     if (optind == argc) {
 	if (activate)
-	  activate_usage(fdisk ? "sfdisk -A" : progn);
+	  activate_usage(fdisk ? PROGNAME " -A" : progn);
 	else if (unhide)
-	  unhide_usage(fdisk ? "sfdisk -U" : progn);
+	  unhide_usage(fdisk ? PROGNAME " -U" : progn);
 	else
 	  usage();
     }
@@ -2573,11 +2558,11 @@
     }
     if (do_id) {
         if ((do_id & PRINT_ID) != 0 && optind != argc-2)
-	  fatal(_("usage: sfdisk --print-id device partition-number\n"));
+	  fatal(_("usage: " PROGNAME " --print-id device partition-number\n"));
 	else if ((do_id & CHANGE_ID) != 0 && optind != argc-3)
-	  fatal(_("usage: sfdisk --change-id device partition-number Id\n"));
+	  fatal(_("usage: " PROGNAME " --change-id device partition-number Id\n"));
 	else if (optind != argc-3 && optind != argc-2)
-	  fatal(_("usage: sfdisk --id device partition-number [Id]\n"));
+	  fatal(_("usage: " PROGNAME " --id device partition-number [Id]\n"));
 	do_change_id(argv[optind], argv[optind+1],
 		     (optind == argc-2) ? 0 : argv[optind+2]);
 	exit(exit_status);
@@ -2668,10 +2653,10 @@
     if (fd < 0)
 	return;
 
-    if(ioctl(fd, BLKGETSIZE, &size)) {
+    if(sys_bsd_getsectors(fd, (unsigned long*) &size)) {
 	if(!silent) {
 	    perror(dev);
-	    fatal(_("BLKGETSIZE ioctl failed for %s\n"), dev);
+	    fatal(_("sys_bsd_getsectors() failed for %s\n"), dev);
 	}
 	return;
     }