summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2018-08-08 15:57:29 +0300
committerDan McDonald <danmcd@joyent.com>2018-08-13 14:42:59 -0400
commit734b3a42d9fd315e40f7ce511604865fb3c2e799 (patch)
tree45b59f06924111f2431b508e3f042ee522686bca
parent857c96d257470e097e846ab8886580991b329c32 (diff)
downloadillumos-joyent-734b3a42d9fd315e40f7ce511604865fb3c2e799.tar.gz
9716 libstand: cstyle cleanup of what we just did touch
Reviewed by: Jason King <jason.king@joyent.com> Reviewed by: Yuri Pankov <yuripv@yuripv.net> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/boot/include/isofs/cd9660/cd9660_rrip.h66
-rw-r--r--usr/src/boot/include/isofs/cd9660/iso.h339
-rw-r--r--usr/src/boot/lib/libstand/bootp.c368
-rw-r--r--usr/src/boot/lib/libstand/bootp.h100
-rw-r--r--usr/src/boot/lib/libstand/cd9660.c97
-rw-r--r--usr/src/boot/lib/libstand/dosfs.c1262
-rw-r--r--usr/src/boot/lib/libstand/gzipfs.c508
-rw-r--r--usr/src/boot/lib/libstand/netif.c26
-rw-r--r--usr/src/boot/lib/libstand/nfs.c125
-rw-r--r--usr/src/boot/sys/sys/types.h3
10 files changed, 1470 insertions, 1424 deletions
diff --git a/usr/src/boot/include/isofs/cd9660/cd9660_rrip.h b/usr/src/boot/include/isofs/cd9660/cd9660_rrip.h
index 4dd0687116..a6de8057b8 100644
--- a/usr/src/boot/include/isofs/cd9660/cd9660_rrip.h
+++ b/usr/src/boot/include/isofs/cd9660/cd9660_rrip.h
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1993, 1994
* The Regents of the University of California. All rights reserved.
*
@@ -32,27 +32,29 @@
* SUCH DAMAGE.
*
* @(#)cd9660_rrip.h 8.2 (Berkeley) 12/5/94
- * $FreeBSD$
*/
+#ifndef CD9660_RRIP_H
+#define CD9660_RRIP_H
+
typedef struct {
- char type [ISODCL ( 0, 1)];
- u_char length [ISODCL ( 2, 2)]; /* 711 */
- u_char version [ISODCL ( 3, 3)];
+ char type [ISODCL(0, 1)];
+ uchar_t length [ISODCL(2, 2)]; /* 711 */
+ uchar_t version [ISODCL(3, 3)];
} ISO_SUSP_HEADER;
typedef struct {
ISO_SUSP_HEADER h;
- char mode [ISODCL ( 4, 11)]; /* 733 */
- char links [ISODCL ( 12, 19)]; /* 733 */
- char uid [ISODCL ( 20, 27)]; /* 733 */
- char gid [ISODCL ( 28, 35)]; /* 733 */
+ char mode [ISODCL(4, 11)]; /* 733 */
+ char links [ISODCL(12, 19)]; /* 733 */
+ char uid [ISODCL(20, 27)]; /* 733 */
+ char gid [ISODCL(28, 35)]; /* 733 */
} ISO_RRIP_ATTR;
typedef struct {
ISO_SUSP_HEADER h;
- char dev_t_high [ISODCL ( 4, 11)]; /* 733 */
- char dev_t_low [ISODCL ( 12, 19)]; /* 733 */
+ char dev_t_high [ISODCL(4, 11)]; /* 733 */
+ char dev_t_low [ISODCL(12, 19)]; /* 733 */
} ISO_RRIP_DEVICE;
#define ISO_SUSP_CFLAG_CONTINUE 0x01
@@ -63,31 +65,31 @@ typedef struct {
#define ISO_SUSP_CFLAG_HOST 0x20
typedef struct {
- u_char cflag [ISODCL ( 1, 1)];
- u_char clen [ISODCL ( 2, 2)];
- u_char name [1]; /* XXX */
+ uchar_t cflag [ISODCL(1, 1)];
+ uchar_t clen [ISODCL(2, 2)];
+ uchar_t name [1]; /* XXX */
} ISO_RRIP_SLINK_COMPONENT;
#define ISO_RRIP_SLSIZ 2
typedef struct {
ISO_SUSP_HEADER h;
- u_char flags [ISODCL ( 4, 4)];
- u_char component [ISODCL ( 5, 5)];
+ uchar_t flags [ISODCL(4, 4)];
+ uchar_t component [ISODCL(5, 5)];
} ISO_RRIP_SLINK;
typedef struct {
ISO_SUSP_HEADER h;
- char flags [ISODCL ( 4, 4)];
+ char flags [ISODCL(4, 4)];
} ISO_RRIP_ALTNAME;
typedef struct {
ISO_SUSP_HEADER h;
- char dir_loc [ISODCL ( 4, 11)]; /* 733 */
+ char dir_loc [ISODCL(4, 11)]; /* 733 */
} ISO_RRIP_CLINK;
typedef struct {
ISO_SUSP_HEADER h;
- char dir_loc [ISODCL ( 4, 11)]; /* 733 */
+ char dir_loc [ISODCL(4, 11)]; /* 733 */
} ISO_RRIP_PLINK;
typedef struct {
@@ -106,32 +108,34 @@ typedef struct {
typedef struct {
ISO_SUSP_HEADER h;
- u_char flags [ISODCL ( 4, 4)];
- u_char time [ISODCL ( 5, 5)];
+ uchar_t flags [ISODCL(4, 4)];
+ uchar_t time [ISODCL(5, 5)];
} ISO_RRIP_TSTAMP;
typedef struct {
ISO_SUSP_HEADER h;
- u_char flags [ISODCL ( 4, 4)];
+ uchar_t flags [ISODCL(4, 4)];
} ISO_RRIP_IDFLAG;
typedef struct {
ISO_SUSP_HEADER h;
- char len_id [ISODCL ( 4, 4)];
- char len_des [ISODCL ( 5, 5)];
- char len_src [ISODCL ( 6, 6)];
- char version [ISODCL ( 7, 7)];
+ char len_id [ISODCL(4, 4)];
+ char len_des [ISODCL(5, 5)];
+ char len_src [ISODCL(6, 6)];
+ char version [ISODCL(7, 7)];
} ISO_RRIP_EXTREF;
typedef struct {
ISO_SUSP_HEADER h;
- char check [ISODCL ( 4, 5)];
- char skip [ISODCL ( 6, 6)];
+ char check [ISODCL(4, 5)];
+ char skip [ISODCL(6, 6)];
} ISO_RRIP_OFFSET;
typedef struct {
ISO_SUSP_HEADER h;
- u_char location [ISODCL ( 4, 11)];
- u_char offset [ISODCL ( 12, 19)];
- u_char length [ISODCL ( 20, 27)];
+ uchar_t location [ISODCL(4, 11)];
+ uchar_t offset [ISODCL(12, 19)];
+ uchar_t length [ISODCL(20, 27)];
} ISO_RRIP_CONT;
+
+#endif /* CD9660_RRIP_H */
diff --git a/usr/src/boot/include/isofs/cd9660/iso.h b/usr/src/boot/include/isofs/cd9660/iso.h
index 2784a9f24e..6180affdd8 100644
--- a/usr/src/boot/include/isofs/cd9660/iso.h
+++ b/usr/src/boot/include/isofs/cd9660/iso.h
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
*
@@ -32,68 +32,70 @@
* SUCH DAMAGE.
*
* @(#)iso.h 8.6 (Berkeley) 5/10/95
- * $FreeBSD$
*/
-#define ISODCL(from, to) (to - from + 1)
+#ifndef ISO_H
+#define ISO_H
+
+#define ISODCL(from, to) (to - from + 1)
struct iso_volume_descriptor {
- char type[ISODCL(1,1)]; /* 711 */
- char id[ISODCL(2,6)];
- char version[ISODCL(7,7)];
- char unused[ISODCL(8,8)];
- char type_sierra[ISODCL(9,9)]; /* 711 */
- char id_sierra[ISODCL(10,14)];
- char version_sierra[ISODCL(15,15)];
- char data[ISODCL(16,2048)];
+ char type[ISODCL(1, 1)]; /* 711 */
+ char id[ISODCL(2, 6)];
+ char version[ISODCL(7, 7)];
+ char unused[ISODCL(8, 8)];
+ char type_sierra[ISODCL(9, 9)]; /* 711 */
+ char id_sierra[ISODCL(10, 14)];
+ char version_sierra[ISODCL(15, 15)];
+ char data[ISODCL(16, 2048)];
};
/* volume descriptor types */
-#define ISO_VD_PRIMARY 1
-#define ISO_VD_SUPPLEMENTARY 2
-#define ISO_VD_END 255
+#define ISO_VD_PRIMARY 1
+#define ISO_VD_SUPPLEMENTARY 2
+#define ISO_VD_END 255
-#define ISO_STANDARD_ID "CD001"
-#define ISO_ECMA_ID "CDW01"
+#define ISO_STANDARD_ID "CD001"
+#define ISO_ECMA_ID "CDW01"
-#define ISO_SIERRA_ID "CDROM"
+#define ISO_SIERRA_ID "CDROM"
struct iso_primary_descriptor {
- u_char type [ISODCL ( 1, 1)]; /* 711 */
- char id [ISODCL ( 2, 6)];
- char version [ISODCL ( 7, 7)]; /* 711 */
- char unused1 [ISODCL ( 8, 8)];
- char system_id [ISODCL ( 9, 40)]; /* achars */
- char volume_id [ISODCL ( 41, 72)]; /* dchars */
- char unused2 [ISODCL ( 73, 80)];
- char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
- char unused3 [ISODCL ( 89, 120)];
- char volume_set_size [ISODCL (121, 124)]; /* 723 */
- char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
- u_char logical_block_size [ISODCL (129, 132)]; /* 723 */
- char path_table_size [ISODCL (133, 140)]; /* 733 */
- char type_l_path_table [ISODCL (141, 144)]; /* 731 */
- char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
- char type_m_path_table [ISODCL (149, 152)]; /* 732 */
- char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
- char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
- char volume_set_id [ISODCL (191, 318)]; /* dchars */
- char publisher_id [ISODCL (319, 446)]; /* achars */
- char preparer_id [ISODCL (447, 574)]; /* achars */
- char application_id [ISODCL (575, 702)]; /* achars */
- char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
- char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
- char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
- char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
- char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
- char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
- char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
- char file_structure_version [ISODCL (882, 882)]; /* 711 */
- char unused4 [ISODCL (883, 883)];
- char application_data [ISODCL (884, 1395)];
- char unused5 [ISODCL (1396, 2048)];
+ uchar_t type [ISODCL(1, 1)]; /* 711 */
+ char id [ISODCL(2, 6)];
+ char version [ISODCL(7, 7)]; /* 711 */
+ char unused1 [ISODCL(8, 8)];
+ char system_id [ISODCL(9, 40)]; /* achars */
+ char volume_id [ISODCL(41, 72)]; /* dchars */
+ char unused2 [ISODCL(73, 80)];
+ char volume_space_size [ISODCL(81, 88)]; /* 733 */
+ char unused3 [ISODCL(89, 120)];
+ char volume_set_size [ISODCL(121, 124)]; /* 723 */
+ char volume_sequence_number [ISODCL(125, 128)]; /* 723 */
+ uchar_t logical_block_size [ISODCL(129, 132)]; /* 723 */
+ char path_table_size [ISODCL(133, 140)]; /* 733 */
+ char type_l_path_table [ISODCL(141, 144)]; /* 731 */
+ char opt_type_l_path_table [ISODCL(145, 148)]; /* 731 */
+ char type_m_path_table [ISODCL(149, 152)]; /* 732 */
+ char opt_type_m_path_table [ISODCL(153, 156)]; /* 732 */
+ char root_directory_record [ISODCL(157, 190)]; /* 9.1 */
+ char volume_set_id [ISODCL(191, 318)]; /* dchars */
+ char publisher_id [ISODCL(319, 446)]; /* achars */
+ char preparer_id [ISODCL(447, 574)]; /* achars */
+ char application_id [ISODCL(575, 702)]; /* achars */
+ char copyright_file_id [ISODCL(703, 739)]; /* 7.5 dchars */
+ char abstract_file_id [ISODCL(740, 776)]; /* 7.5 dchars */
+ char bibliographic_file_id [ISODCL(777, 813)]; /* 7.5 dchars */
+ char creation_date [ISODCL(814, 830)]; /* 8.4.26.1 */
+ char modification_date [ISODCL(831, 847)]; /* 8.4.26.1 */
+ char expiration_date [ISODCL(848, 864)]; /* 8.4.26.1 */
+ char effective_date [ISODCL(865, 881)]; /* 8.4.26.1 */
+ char file_structure_version [ISODCL(882, 882)]; /* 711 */
+ char unused4 [ISODCL(883, 883)];
+ char application_data [ISODCL(884, 1395)];
+ char unused5 [ISODCL(1396, 2048)];
} __packed;
-#define ISO_DEFAULT_BLOCK_SIZE 2048
+#define ISO_DEFAULT_BLOCK_SIZE 2048
/*
* Used by Microsoft Joliet extension to ISO9660. Almost the same
@@ -101,119 +103,127 @@ struct iso_primary_descriptor {
*/
struct iso_supplementary_descriptor {
- char type [ISODCL ( 1, 1)]; /* 711 */
- char id [ISODCL ( 2, 6)];
- char version [ISODCL ( 7, 7)]; /* 711 */
- char flags [ISODCL ( 8, 8)]; /* 711? */
- char system_id [ISODCL ( 9, 40)]; /* achars */
- char volume_id [ISODCL ( 41, 72)]; /* dchars */
- char unused2 [ISODCL ( 73, 80)];
- char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
- char escape [ISODCL ( 89, 120)];
- char volume_set_size [ISODCL (121, 124)]; /* 723 */
- char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
- char logical_block_size [ISODCL (129, 132)]; /* 723 */
- char path_table_size [ISODCL (133, 140)]; /* 733 */
- char type_l_path_table [ISODCL (141, 144)]; /* 731 */
- char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
- char type_m_path_table [ISODCL (149, 152)]; /* 732 */
- char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
- char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
- char volume_set_id [ISODCL (191, 318)]; /* dchars */
- char publisher_id [ISODCL (319, 446)]; /* achars */
- char preparer_id [ISODCL (447, 574)]; /* achars */
- char application_id [ISODCL (575, 702)]; /* achars */
- char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
- char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
- char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
- char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
- char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
- char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
- char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
- char file_structure_version [ISODCL (882, 882)]; /* 711 */
- char unused4 [ISODCL (883, 883)];
- char application_data [ISODCL (884, 1395)];
- char unused5 [ISODCL (1396, 2048)];
+ char type [ISODCL(1, 1)]; /* 711 */
+ char id [ISODCL(2, 6)];
+ char version [ISODCL(7, 7)]; /* 711 */
+ char flags [ISODCL(8, 8)]; /* 711? */
+ char system_id [ISODCL(9, 40)]; /* achars */
+ char volume_id [ISODCL(41, 72)]; /* dchars */
+ char unused2 [ISODCL(73, 80)];
+ char volume_space_size [ISODCL(81, 88)]; /* 733 */
+ char escape [ISODCL(89, 120)];
+ char volume_set_size [ISODCL(121, 124)]; /* 723 */
+ char volume_sequence_number [ISODCL(125, 128)]; /* 723 */
+ char logical_block_size [ISODCL(129, 132)]; /* 723 */
+ char path_table_size [ISODCL(133, 140)]; /* 733 */
+ char type_l_path_table [ISODCL(141, 144)]; /* 731 */
+ char opt_type_l_path_table [ISODCL(145, 148)]; /* 731 */
+ char type_m_path_table [ISODCL(149, 152)]; /* 732 */
+ char opt_type_m_path_table [ISODCL(153, 156)]; /* 732 */
+ char root_directory_record [ISODCL(157, 190)]; /* 9.1 */
+ char volume_set_id [ISODCL(191, 318)]; /* dchars */
+ char publisher_id [ISODCL(319, 446)]; /* achars */
+ char preparer_id [ISODCL(447, 574)]; /* achars */
+ char application_id [ISODCL(575, 702)]; /* achars */
+ char copyright_file_id [ISODCL(703, 739)]; /* 7.5 dchars */
+ char abstract_file_id [ISODCL(740, 776)]; /* 7.5 dchars */
+ char bibliographic_file_id [ISODCL(777, 813)]; /* 7.5 dchars */
+ char creation_date [ISODCL(814, 830)]; /* 8.4.26.1 */
+ char modification_date [ISODCL(831, 847)]; /* 8.4.26.1 */
+ char expiration_date [ISODCL(848, 864)]; /* 8.4.26.1 */
+ char effective_date [ISODCL(865, 881)]; /* 8.4.26.1 */
+ char file_structure_version [ISODCL(882, 882)]; /* 711 */
+ char unused4 [ISODCL(883, 883)];
+ char application_data [ISODCL(884, 1395)];
+ char unused5 [ISODCL(1396, 2048)];
};
struct iso_sierra_primary_descriptor {
- char unknown1 [ISODCL ( 1, 8)]; /* 733 */
- char type [ISODCL ( 9, 9)]; /* 711 */
- char id [ISODCL ( 10, 14)];
- char version [ISODCL ( 15, 15)]; /* 711 */
- char unused1 [ISODCL ( 16, 16)];
- char system_id [ISODCL ( 17, 48)]; /* achars */
- char volume_id [ISODCL ( 49, 80)]; /* dchars */
- char unused2 [ISODCL ( 81, 88)];
- char volume_space_size [ISODCL ( 89, 96)]; /* 733 */
- char unused3 [ISODCL ( 97, 128)];
- char volume_set_size [ISODCL (129, 132)]; /* 723 */
- char volume_sequence_number [ISODCL (133, 136)]; /* 723 */
- char logical_block_size [ISODCL (137, 140)]; /* 723 */
- char path_table_size [ISODCL (141, 148)]; /* 733 */
- char type_l_path_table [ISODCL (149, 152)]; /* 731 */
- char opt_type_l_path_table [ISODCL (153, 156)]; /* 731 */
- char unknown2 [ISODCL (157, 160)]; /* 731 */
- char unknown3 [ISODCL (161, 164)]; /* 731 */
- char type_m_path_table [ISODCL (165, 168)]; /* 732 */
- char opt_type_m_path_table [ISODCL (169, 172)]; /* 732 */
- char unknown4 [ISODCL (173, 176)]; /* 732 */
- char unknown5 [ISODCL (177, 180)]; /* 732 */
- char root_directory_record [ISODCL (181, 214)]; /* 9.1 */
- char volume_set_id [ISODCL (215, 342)]; /* dchars */
- char publisher_id [ISODCL (343, 470)]; /* achars */
- char preparer_id [ISODCL (471, 598)]; /* achars */
- char application_id [ISODCL (599, 726)]; /* achars */
- char copyright_id [ISODCL (727, 790)]; /* achars */
- char creation_date [ISODCL (791, 806)]; /* ? */
- char modification_date [ISODCL (807, 822)]; /* ? */
- char expiration_date [ISODCL (823, 838)]; /* ? */
- char effective_date [ISODCL (839, 854)]; /* ? */
- char file_structure_version [ISODCL (855, 855)]; /* 711 */
- char unused4 [ISODCL (856, 2048)];
+ char unknown1 [ISODCL(1, 8)]; /* 733 */
+ char type [ISODCL(9, 9)]; /* 711 */
+ char id [ISODCL(10, 14)];
+ char version [ISODCL(15, 15)]; /* 711 */
+ char unused1 [ISODCL(16, 16)];
+ char system_id [ISODCL(17, 48)]; /* achars */
+ char volume_id [ISODCL(49, 80)]; /* dchars */
+ char unused2 [ISODCL(81, 88)];
+ char volume_space_size [ISODCL(89, 96)]; /* 733 */
+ char unused3 [ISODCL(97, 128)];
+ char volume_set_size [ISODCL(129, 132)]; /* 723 */
+ char volume_sequence_number [ISODCL(133, 136)]; /* 723 */
+ char logical_block_size [ISODCL(137, 140)]; /* 723 */
+ char path_table_size [ISODCL(141, 148)]; /* 733 */
+ char type_l_path_table [ISODCL(149, 152)]; /* 731 */
+ char opt_type_l_path_table [ISODCL(153, 156)]; /* 731 */
+ char unknown2 [ISODCL(157, 160)]; /* 731 */
+ char unknown3 [ISODCL(161, 164)]; /* 731 */
+ char type_m_path_table [ISODCL(165, 168)]; /* 732 */
+ char opt_type_m_path_table [ISODCL(169, 172)]; /* 732 */
+ char unknown4 [ISODCL(173, 176)]; /* 732 */
+ char unknown5 [ISODCL(177, 180)]; /* 732 */
+ char root_directory_record [ISODCL(181, 214)]; /* 9.1 */
+ char volume_set_id [ISODCL(215, 342)]; /* dchars */
+ char publisher_id [ISODCL(343, 470)]; /* achars */
+ char preparer_id [ISODCL(471, 598)]; /* achars */
+ char application_id [ISODCL(599, 726)]; /* achars */
+ char copyright_id [ISODCL(727, 790)]; /* achars */
+ char creation_date [ISODCL(791, 806)]; /* ? */
+ char modification_date [ISODCL(807, 822)]; /* ? */
+ char expiration_date [ISODCL(823, 838)]; /* ? */
+ char effective_date [ISODCL(839, 854)]; /* ? */
+ char file_structure_version [ISODCL(855, 855)]; /* 711 */
+ char unused4 [ISODCL(856, 2048)];
};
struct iso_directory_record {
- u_char length [ISODCL (1, 1)]; /* 711 */
- u_char ext_attr_length [ISODCL (2, 2)]; /* 711 */
- u_char extent [ISODCL (3, 10)]; /* 733 */
- u_char size [ISODCL (11, 18)]; /* 733 */
- char date [ISODCL (19, 25)]; /* 7 by 711 */
- u_char flags [ISODCL (26, 26)];
- char file_unit_size [ISODCL (27, 27)]; /* 711 */
- char interleave [ISODCL (28, 28)]; /* 711 */
- char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
- u_char name_len [ISODCL (33, 33)]; /* 711 */
+ uchar_t length [ISODCL(1, 1)]; /* 711 */
+ uchar_t ext_attr_length [ISODCL(2, 2)]; /* 711 */
+ uchar_t extent [ISODCL(3, 10)]; /* 733 */
+ uchar_t size [ISODCL(11, 18)]; /* 733 */
+ char date [ISODCL(19, 25)]; /* 7 by 711 */
+ uchar_t flags [ISODCL(26, 26)];
+ char file_unit_size [ISODCL(27, 27)]; /* 711 */
+ char interleave [ISODCL(28, 28)]; /* 711 */
+ char volume_sequence_number [ISODCL(29, 32)]; /* 723 */
+ uchar_t name_len [ISODCL(33, 33)]; /* 711 */
char name [1]; /* XXX */
} __packed;
-/* can't take sizeof(iso_directory_record), because of possible alignment
- of the last entry (34 instead of 33) */
-#define ISO_DIRECTORY_RECORD_SIZE 33
+/*
+ * can't take sizeof(iso_directory_record), because of possible alignment
+ * of the last entry (34 instead of 33)
+ */
+#define ISO_DIRECTORY_RECORD_SIZE 33
struct iso_extended_attributes {
- u_char owner [ISODCL (1, 4)]; /* 723 */
- u_char group [ISODCL (5, 8)]; /* 723 */
- u_char perm [ISODCL (9, 10)]; /* 9.5.3 */
- char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */
- char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */
- char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */
- char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */
- char recfmt [ISODCL (79, 79)]; /* 711 */
- char recattr [ISODCL (80, 80)]; /* 711 */
- u_char reclen [ISODCL (81, 84)]; /* 723 */
- char system_id [ISODCL (85, 116)]; /* achars */
- char system_use [ISODCL (117, 180)];
- char version [ISODCL (181, 181)]; /* 711 */
- char len_esc [ISODCL (182, 182)]; /* 711 */
- char reserved [ISODCL (183, 246)];
- u_char len_au [ISODCL (247, 250)]; /* 723 */
+ uchar_t owner [ISODCL(1, 4)]; /* 723 */
+ uchar_t group [ISODCL(5, 8)]; /* 723 */
+ uchar_t perm [ISODCL(9, 10)]; /* 9.5.3 */
+ char ctime [ISODCL(11, 27)]; /* 8.4.26.1 */
+ char mtime [ISODCL(28, 44)]; /* 8.4.26.1 */
+ char xtime [ISODCL(45, 61)]; /* 8.4.26.1 */
+ char ftime [ISODCL(62, 78)]; /* 8.4.26.1 */
+ char recfmt [ISODCL(79, 79)]; /* 711 */
+ char recattr [ISODCL(80, 80)]; /* 711 */
+ uchar_t reclen [ISODCL(81, 84)]; /* 723 */
+ char system_id [ISODCL(85, 116)]; /* achars */
+ char system_use [ISODCL(117, 180)];
+ char version [ISODCL(181, 181)]; /* 711 */
+ char len_esc [ISODCL(182, 182)]; /* 711 */
+ char reserved [ISODCL(183, 246)];
+ uchar_t len_au [ISODCL(247, 250)]; /* 723 */
};
#ifdef _KERNEL
/* CD-ROM Format type */
-enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP,
- ISO_FTYPE_JOLIET, ISO_FTYPE_ECMA, ISO_FTYPE_HIGH_SIERRA };
+enum ISO_FTYPE {
+ ISO_FTYPE_DEFAULT,
+ ISO_FTYPE_9660,
+ ISO_FTYPE_RRIP,
+ ISO_FTYPE_JOLIET,
+ ISO_FTYPE_ECMA,
+ ISO_FTYPE_HIGH_SIERRA
+};
#ifndef ISOFSMNT_ROOT
#define ISOFSMNT_ROOT 0
@@ -235,7 +245,7 @@ struct iso_mnt {
int volume_space_size;
- char root[ISODCL (157, 190)];
+ char root[ISODCL(157, 190)];
int root_extent;
int root_size;
enum ISO_FTYPE iso_ftype;
@@ -250,32 +260,33 @@ struct iso_mnt {
};
struct ifid {
- u_short ifid_len;
- u_short ifid_pad;
+ ushort_t ifid_len;
+ ushort_t ifid_pad;
int ifid_ino;
long ifid_start;
};
-#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data))
+#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data))
-#define blkoff(imp, loc) ((loc) & (imp)->im_bmask)
-#define lblktosize(imp, blk) ((blk) << (imp)->im_bshift)
-#define lblkno(imp, loc) ((loc) >> (imp)->im_bshift)
-#define blksize(imp, ip, lbn) ((imp)->logical_block_size)
+#define blkoff(imp, loc) ((loc) & (imp)->im_bmask)
+#define lblktosize(imp, blk) ((blk) << (imp)->im_bshift)
+#define lblkno(imp, loc) ((loc) >> (imp)->im_bshift)
+#define blksize(imp, ip, lbn) ((imp)->logical_block_size)
int cd9660_vget_internal(struct mount *, ino_t, int, struct vnode **, int,
- struct iso_directory_record *);
-#define cd9660_sysctl ((int (*)(int *, u_int, void *, size_t *, void *, \
+ struct iso_directory_record *);
+#define cd9660_sysctl ((int (*)(int *, uint_t, void *, size_t *, void *, \
size_t, struct proc *))eopnotsupp)
extern struct vop_vector cd9660_vnodeops;
extern struct vop_vector cd9660_fifoops;
-int isochar(u_char *, u_char *, int, u_short *, int *, int, void *);
-int isofncmp(u_char *, int, u_char *, int, int, int, void *, void *);
-void isofntrans(u_char *, int, u_char *, u_short *, int, int, int, int, void *);
+int isochar(uchar_t *, uchar_t *, int, ushort_t *, int *, int, void *);
+int isofncmp(uchar_t *, int, uchar_t *, int, int, int, void *, void *);
+void isofntrans(uchar_t *, int, uchar_t *, ushort_t *, int, int, int, int,
+ void *);
ino_t isodirino(struct iso_directory_record *, struct iso_mnt *);
-u_short sgetrune(const char *, size_t, char const **, int, void *);
+ushort_t sgetrune(const char *, size_t, char const **, int, void *);
#endif /* _KERNEL */
@@ -357,3 +368,5 @@ isonum_733(const unsigned char *p)
* Associated files have a leading '='.
*/
#define ASSOCCHAR '='
+
+#endif /* ISO_H */
diff --git a/usr/src/boot/lib/libstand/bootp.c b/usr/src/boot/lib/libstand/bootp.c
index 2e8773ca46..a17d399019 100644
--- a/usr/src/boot/lib/libstand/bootp.c
+++ b/usr/src/boot/lib/libstand/bootp.c
@@ -42,14 +42,14 @@
#include <string.h>
-#define BOOTP_DEBUGxx
-#define SUPPORT_DHCP
+#define BOOTP_DEBUGxx
+#define SUPPORT_DHCP
#define DHCP_ENV_NOVENDOR 1 /* do not parse vendor options */
#define DHCP_ENV_PXE 10 /* assume pxe vendor options */
#define DHCP_ENV_FREEBSD 11 /* assume freebsd vendor options */
/* set DHCP_ENV to one of the values above to export dhcp options to kenv */
-#define DHCP_ENV DHCP_ENV_NO_VENDOR
+#define DHCP_ENV DHCP_ENV_NO_VENDOR
#include "stand.h"
#include "net.h"
@@ -69,16 +69,16 @@ static char vm_cmu[4] = VM_CMU;
/* Local forwards */
static ssize_t bootpsend(struct iodesc *, void *, size_t);
static ssize_t bootprecv(struct iodesc *, void **, void **, time_t, void *);
-static int vend_rfc1048(u_char *, u_int);
+static int vend_rfc1048(uchar_t *, uint_t);
#ifdef BOOTP_VEND_CMU
-static void vend_cmu(u_char *);
+static void vend_cmu(uchar_t *);
#endif
#ifdef DHCP_ENV /* export the dhcp response to kenv */
struct dhcp_opt;
-static void setenv_(u_char *cp, u_char *ep, struct dhcp_opt *opts);
+static void setenv_(uchar_t *cp, uchar_t *ep, struct dhcp_opt *opts);
#else
-#define setenv_(a, b, c)
+#define setenv_(a, b, c)
#endif
#ifdef SUPPORT_DHCP
@@ -125,37 +125,37 @@ bootp(int sock)
struct iodesc *d;
struct bootp *bp;
struct {
- u_char header[HEADER_SIZE];
+ uchar_t header[HEADER_SIZE];
struct bootp wbootp;
} wbuf;
struct bootp *rbootp;
#ifdef BOOTP_DEBUG
- if (debug)
+ if (debug)
printf("bootp: socket=%d\n", sock);
#endif
if (!bot)
bot = getsecs();
-
+
if (!(d = socktodesc(sock))) {
printf("bootp: bad socket. %d\n", sock);
return;
}
#ifdef BOOTP_DEBUG
- if (debug)
+ if (debug)
printf("bootp: d=%lx\n", (long)d);
#endif
bp = &wbuf.wbootp;
- bzero(bp, sizeof(*bp));
+ bzero(bp, sizeof (*bp));
bp->bp_op = BOOTREQUEST;
bp->bp_htype = 1; /* 10Mb Ethernet (48 bits) */
bp->bp_hlen = 6;
bp->bp_xid = htonl(d->xid);
MACPY(d->myea, bp->bp_chaddr);
- strncpy(bp->bp_file, bootfile, sizeof(bp->bp_file));
- bcopy(vm_rfc1048, bp->bp_vend, sizeof(vm_rfc1048));
+ strncpy(bp->bp_file, bootfile, sizeof (bp->bp_file));
+ bcopy(vm_rfc1048, bp->bp_vend, sizeof (vm_rfc1048));
#ifdef SUPPORT_DHCP
bp->bp_vend[4] = TAG_DHCP_MSGTYPE;
bp->bp_vend[5] = 1;
@@ -175,16 +175,15 @@ bootp(int sock)
dhcp_ok = 0;
#endif
- if(sendrecv(d,
- bootpsend, bp, sizeof(*bp),
- bootprecv, &pkt, (void **)&rbootp, NULL) == -1) {
- printf("bootp: no reply\n");
- return;
+ if (sendrecv(d, bootpsend, bp, sizeof (*bp),
+ bootprecv, &pkt, (void **)&rbootp, NULL) == -1) {
+ printf("bootp: no reply\n");
+ return;
}
#ifdef SUPPORT_DHCP
- if(dhcp_ok) {
- u_int32_t leasetime;
+ if (dhcp_ok) {
+ uint32_t leasetime;
bp->bp_vend[6] = DHCPREQUEST;
bp->bp_vend[7] = TAG_REQ_ADDR;
bp->bp_vend[8] = 4;
@@ -201,9 +200,8 @@ bootp(int sock)
expected_dhcpmsgtype = DHCPACK;
free(pkt);
- if(sendrecv(d,
- bootpsend, bp, sizeof(*bp),
- bootprecv, &pkt, (void **)&rbootp, NULL) == -1) {
+ if (sendrecv(d, bootpsend, bp, sizeof (*bp),
+ bootprecv, &pkt, (void **)&rbootp, NULL) == -1) {
printf("DHCPREQUEST failed\n");
return;
}
@@ -214,8 +212,8 @@ bootp(int sock)
servip = rbootp->bp_siaddr;
if (rootip.s_addr == INADDR_ANY)
rootip = servip;
- bcopy(rbootp->bp_file, bootfile, sizeof(bootfile));
- bootfile[sizeof(bootfile) - 1] = '\0';
+ bcopy(rbootp->bp_file, bootfile, sizeof (bootfile));
+ bootfile[sizeof (bootfile) - 1] = '\0';
if (!netmask) {
if (IN_CLASSA(ntohl(myip.s_addr)))
@@ -269,7 +267,7 @@ bootpsend(struct iodesc *d, void *pkt, size_t len)
#endif
bp = pkt;
- bp->bp_secs = htons((u_short)(getsecs() - bot));
+ bp->bp_secs = htons((ushort_t)(getsecs() - bot));
#ifdef BOOTP_DEBUG
if (debug)
@@ -294,7 +292,7 @@ bootprecv(struct iodesc *d, void **pkt, void **payload, time_t tleft,
ptr = NULL;
n = readudp(d, &ptr, (void **)&bp, tleft);
- if (n == -1 || n < sizeof(struct bootp) - BOOTP_VENDSIZE)
+ if (n == -1 || n < sizeof (struct bootp) - BOOTP_VENDSIZE)
goto bad;
#ifdef BOOTP_DEBUG
@@ -317,10 +315,10 @@ bootprecv(struct iodesc *d, void **pkt, void **payload, time_t tleft,
#endif
/* Suck out vendor info */
- if (bcmp(vm_rfc1048, bp->bp_vend, sizeof(vm_rfc1048)) == 0) {
+ if (bcmp(vm_rfc1048, bp->bp_vend, sizeof (vm_rfc1048)) == 0) {
int vsize = n - offsetof(struct bootp, bp_vend);
- if(vend_rfc1048(bp->bp_vend, vsize) != 0)
- goto bad;
+ if (vend_rfc1048(bp->bp_vend, vsize) != 0)
+ goto bad;
/* Save copy of bootp reply or DHCP ACK message */
if (bp->bp_op == BOOTREPLY &&
@@ -335,7 +333,7 @@ bootprecv(struct iodesc *d, void **pkt, void **payload, time_t tleft,
}
}
#ifdef BOOTP_VEND_CMU
- else if (bcmp(vm_cmu, bp->bp_vend, sizeof(vm_cmu)) == 0)
+ else if (bcmp(vm_cmu, bp->bp_vend, sizeof (vm_cmu)) == 0)
vend_cmu(bp->bp_vend);
#endif
else
@@ -343,7 +341,7 @@ bootprecv(struct iodesc *d, void **pkt, void **payload, time_t tleft,
*pkt = ptr;
*payload = bp;
- return(n);
+ return (n);
bad:
free(ptr);
errno = 0;
@@ -351,11 +349,11 @@ bad:
}
static int
-vend_rfc1048(u_char *cp, u_int len)
+vend_rfc1048(uchar_t *cp, uint_t len)
{
- u_char *ep;
+ uchar_t *ep;
int size;
- u_char tag;
+ uchar_t tag;
const char *val;
#ifdef BOOTP_DEBUG
@@ -365,7 +363,7 @@ vend_rfc1048(u_char *cp, u_int len)
ep = cp + len;
/* Step over magic cookie */
- cp += sizeof(int);
+ cp += sizeof (int);
setenv_(cp, ep, NULL);
@@ -376,24 +374,24 @@ vend_rfc1048(u_char *cp, u_int len)
break;
if (tag == TAG_SUBNET_MASK) {
- bcopy(cp, &netmask, sizeof(netmask));
+ bcopy(cp, &netmask, sizeof (netmask));
}
if (tag == TAG_GATEWAY) {
- bcopy(cp, &gateip.s_addr, sizeof(gateip.s_addr));
+ bcopy(cp, &gateip.s_addr, sizeof (gateip.s_addr));
}
if (tag == TAG_SWAPSERVER) {
/* let it override bp_siaddr */
- bcopy(cp, &rootip.s_addr, sizeof(rootip.s_addr));
+ bcopy(cp, &rootip.s_addr, sizeof (rootip.s_addr));
}
if (tag == TAG_ROOTPATH) {
if ((val = getenv("dhcp.root-path")) == NULL)
val = (const char *)cp;
- strlcpy(rootpath, val, sizeof(rootpath));
+ strlcpy(rootpath, val, sizeof (rootpath));
}
if (tag == TAG_HOSTNAME) {
if ((val = getenv("dhcp.host-name")) == NULL)
val = (const char *)cp;
- strlcpy(hostname, val, sizeof(hostname));
+ strlcpy(hostname, val, sizeof (hostname));
}
if (tag == TAG_INTF_MTU) {
intf_mtu = 0;
@@ -414,7 +412,7 @@ vend_rfc1048(u_char *cp, u_int len)
"ignoring\n",
"dhcp.interface-mtu", val);
} else {
- intf_mtu = (u_int)tmp;
+ intf_mtu = (uint_t)tmp;
}
}
if (intf_mtu == 0)
@@ -422,23 +420,23 @@ vend_rfc1048(u_char *cp, u_int len)
}
#ifdef SUPPORT_DHCP
if (tag == TAG_DHCP_MSGTYPE) {
- if(*cp != expected_dhcpmsgtype)
- return(-1);
+ if (*cp != expected_dhcpmsgtype)
+ return (-1);
dhcp_ok = 1;
}
if (tag == TAG_SERVERID) {
bcopy(cp, &dhcp_serverip.s_addr,
- sizeof(dhcp_serverip.s_addr));
+ sizeof (dhcp_serverip.s_addr));
}
#endif
cp += size;
}
- return(0);
+ return (0);
}
#ifdef BOOTP_VEND_CMU
static void
-vend_cmu(u_char *cp)
+vend_cmu(uchar_t *cp)
{
struct cmu_vend *vp;
@@ -632,144 +630,150 @@ static struct dhcp_opt dhcp_opt[] = {
* to the list of selected tags.
*/
static void
-setenv_(u_char *cp, u_char *ep, struct dhcp_opt *opts)
+setenv_(uchar_t *cp, uchar_t *ep, struct dhcp_opt *opts)
{
- u_char *ncp;
- u_char tag;
- char tags[512], *tp; /* the list of tags */
-
-#define FLD_SEP ',' /* separator in list of elements */
- ncp = cp;
- tp = tags;
- if (opts == NULL)
- opts = dhcp_opt;
-
- while (ncp < ep) {
- unsigned int size; /* option size */
- char *vp, *endv, buf[256]; /* the value buffer */
- struct dhcp_opt *op;
-
- tag = *ncp++; /* extract tag and size */
- size = *ncp++;
- cp = ncp; /* current payload */
- ncp += size; /* point to the next option */
-
- if (tag == TAG_END)
- break;
- if (tag == 0)
- continue;
-
- for (op = opts+1; op->tag && op->tag != tag; op++)
- ;
- /* if not found we end up on the default entry */
+ uchar_t *ncp;
+ uchar_t tag;
+ char tags[512], *tp; /* the list of tags */
+
+#define FLD_SEP ',' /* separator in list of elements */
+ ncp = cp;
+ tp = tags;
+ if (opts == NULL)
+ opts = dhcp_opt;
+
+ while (ncp < ep) {
+ unsigned int size; /* option size */
+ char *vp, *endv, buf[256]; /* the value buffer */
+ struct dhcp_opt *op;
+
+ tag = *ncp++; /* extract tag and size */
+ size = *ncp++;
+ cp = ncp; /* current payload */
+ ncp += size; /* point to the next option */
- /*
- * Copy data into the buffer. libstand does not have snprintf so we
- * need to be careful with sprintf(). With strings, the source is
- * always <256 char so shorter than the buffer so we are safe; with
- * other arguments, the longest string is inet_ntoa which is 16 bytes
- * so we make sure to have always enough room in the string before
- * trying an sprint.
- */
- vp = buf;
- *vp = '\0';
- endv = buf + sizeof(buf) - 1 - 16; /* last valid write position */
-
- switch(op->fmt) {
- case __NONE:
- break; /* should not happen */
-
- case __VE: /* recurse, vendor specific */
- setenv_(cp, cp+size, vndr_opt);
- break;
-
- case __IP: /* ip address */
- for (; size > 0 && vp < endv; size -= 4, cp += 4) {
- struct in_addr in_ip; /* ip addresses */
- if (vp != buf)
- *vp++ = FLD_SEP;
- bcopy(cp, &in_ip.s_addr, sizeof(in_ip.s_addr));
- sprintf(vp, "%s", inet_ntoa(in_ip));
- vp += strlen(vp);
- }
- break;
-
- case __BYTES: /* opaque byte string */
- for (; size > 0 && vp < endv; size -= 1, cp += 1) {
- sprintf(vp, "%02x", *cp);
- vp += strlen(vp);
- }
- break;
-
- case __TXT:
- bcopy(cp, buf, size); /* cannot overflow */
- buf[size] = 0;
- break;
-
- case __32:
- case __16:
- case __8: /* op->fmt is also the length of each field */
- for (; size > 0 && vp < endv; size -= op->fmt, cp += op->fmt) {
- uint32_t v;
- if (op->fmt == __32)
- v = (cp[0]<<24) + (cp[1]<<16) + (cp[2]<<8) + cp[3];
- else if (op->fmt == __16)
- v = (cp[0]<<8) + cp[1];
- else
- v = cp[0];
- if (vp != buf)
- *vp++ = FLD_SEP;
- sprintf(vp, "%u", v);
- vp += strlen(vp);
- }
- break;
-
- case __INDIR: /* name=value */
- case __ILIST: /* name=value;name=value... */
- bcopy(cp, buf, size); /* cannot overflow */
- buf[size] = '\0';
- for (endv = buf; endv; endv = vp) {
- char *s = NULL; /* semicolon ? */
-
- /* skip leading whitespace */
- while (*endv && strchr(" \t\n\r", *endv))
- endv++;
- vp = strchr(endv, '='); /* find name=value separator */
- if (!vp)
- break;
- *vp++ = 0;
- if (op->fmt == __ILIST && (s = strchr(vp, ';')))
- *s++ = '\0';
- setenv(endv, vp, 1);
- vp = s; /* prepare for next round */
- }
- buf[0] = '\0'; /* option already done */
- }
+ if (tag == TAG_END)
+ break;
+ if (tag == 0)
+ continue;
+
+ for (op = opts+1; op->tag && op->tag != tag; op++)
+ ;
+ /* if not found we end up on the default entry */
+
+ /*
+ * Copy data into the buffer. libstand does not have snprintf
+ * so we need to be careful with sprintf(). With strings, the
+ * source is always <256 char so shorter than the buffer so we
+ * are safe; with other arguments, the longest string is
+ * inet_ntoa which is 16 bytes so we make sure to have always
+ * enough room in the string before trying an sprint.
+ */
+ vp = buf;
+ *vp = '\0';
+ /* last valid write position */
+ endv = buf + sizeof (buf) - 1 - 16;
+
+ switch (op->fmt) {
+ case __NONE:
+ break; /* should not happen */
+
+ case __VE: /* recurse, vendor specific */
+ setenv_(cp, cp+size, vndr_opt);
+ break;
- if (tp - tags < sizeof(tags) - 5) { /* add tag to the list */
- if (tp != tags)
- *tp++ = FLD_SEP;
- sprintf(tp, "%d", tag);
- tp += strlen(tp);
+ case __IP: /* ip address */
+ for (; size > 0 && vp < endv; size -= 4, cp += 4) {
+ struct in_addr in_ip; /* ip addresses */
+ if (vp != buf)
+ *vp++ = FLD_SEP;
+ bcopy(cp, &in_ip.s_addr, sizeof (in_ip.s_addr));
+ sprintf(vp, "%s", inet_ntoa(in_ip));
+ vp += strlen(vp);
+ }
+ break;
+
+ case __BYTES: /* opaque byte string */
+ for (; size > 0 && vp < endv; size -= 1, cp += 1) {
+ sprintf(vp, "%02x", *cp);
+ vp += strlen(vp);
+ }
+ break;
+
+ case __TXT:
+ bcopy(cp, buf, size); /* cannot overflow */
+ buf[size] = 0;
+ break;
+
+ case __32:
+ case __16:
+ case __8: /* op->fmt is also the length of each field */
+ for (; size > 0 && vp < endv;
+ size -= op->fmt, cp += op->fmt) {
+ uint32_t v;
+ if (op->fmt == __32)
+ v = (cp[0]<<24) + (cp[1]<<16) +
+ (cp[2]<<8) + cp[3];
+ else if (op->fmt == __16)
+ v = (cp[0]<<8) + cp[1];
+ else
+ v = cp[0];
+ if (vp != buf)
+ *vp++ = FLD_SEP;
+ sprintf(vp, "%u", v);
+ vp += strlen(vp);
+ }
+ break;
+
+ case __INDIR: /* name=value */
+ case __ILIST: /* name=value;name=value... */
+ bcopy(cp, buf, size); /* cannot overflow */
+ buf[size] = '\0';
+ for (endv = buf; endv; endv = vp) {
+ char *s = NULL; /* semicolon ? */
+
+ /* skip leading whitespace */
+ while (*endv && strchr(" \t\n\r", *endv))
+ endv++;
+ /* find name=value separator */
+ vp = strchr(endv, '=');
+ if (!vp)
+ break;
+ *vp++ = 0;
+ if (op->fmt == __ILIST && (s = strchr(vp, ';')))
+ *s++ = '\0';
+ setenv(endv, vp, 1);
+ vp = s; /* prepare for next round */
+ }
+ buf[0] = '\0'; /* option already done */
+ }
+
+ if (tp - tags < sizeof (tags) - 5) {
+ /* add tag to the list */
+ if (tp != tags)
+ *tp++ = FLD_SEP;
+ sprintf(tp, "%d", tag);
+ tp += strlen(tp);
+ }
+ if (buf[0]) {
+ char env[128]; /* the string name */
+
+ if (op->tag == 0)
+ sprintf(env, op->desc, opts[0].desc, tag);
+ else
+ sprintf(env, "%s%s", opts[0].desc, op->desc);
+ /*
+ * Do not replace existing values in the environment,
+ * so that locally-obtained values can override
+ * server-provided values.
+ */
+ setenv(env, buf, 0);
+ }
}
- if (buf[0]) {
- char env[128]; /* the string name */
-
- if (op->tag == 0)
- sprintf(env, op->desc, opts[0].desc, tag);
- else
- sprintf(env, "%s%s", opts[0].desc, op->desc);
- /*
- * Do not replace existing values in the environment, so that
- * locally-obtained values can override server-provided values.
- */
- setenv(env, buf, 0);
+ if (tp != tags) {
+ char env[128]; /* the string name */
+ sprintf(env, "%stags", opts[0].desc);
+ setenv(env, tags, 1);
}
- }
- if (tp != tags) {
- char env[128]; /* the string name */
- sprintf(env, "%stags", opts[0].desc);
- setenv(env, tags, 1);
- }
}
#endif /* additional dhcp */
diff --git a/usr/src/boot/lib/libstand/bootp.h b/usr/src/boot/lib/libstand/bootp.h
index 4fbb712e7d..b26a5cd45c 100644
--- a/usr/src/boot/lib/libstand/bootp.h
+++ b/usr/src/boot/lib/libstand/bootp.h
@@ -18,11 +18,11 @@
* without express or implied warranty.
*/
-#include <netinet/in.h>
-
#ifndef _BOOTP_H_
#define _BOOTP_H_
+#include <netinet/in.h>
+
struct bootp {
unsigned char bp_op; /* packet opcode type */
unsigned char bp_htype; /* hardware addr type */
@@ -39,11 +39,11 @@ struct bootp {
unsigned char bp_sname[64]; /* server host name */
char bp_file[128]; /* boot file name */
#ifdef SUPPORT_DHCP
-#define BOOTP_VENDSIZE 312
+#define BOOTP_VENDSIZE 312
#else
-#define BOOTP_VENDSIZE 64
+#define BOOTP_VENDSIZE 64
#endif
- unsigned char bp_vend[BOOTP_VENDSIZE]; /* vendor-specific area */
+ unsigned char bp_vend[BOOTP_VENDSIZE]; /* vendor-specific area */
};
/*
@@ -52,73 +52,71 @@ struct bootp {
#define IPPORT_BOOTPS 67
#define IPPORT_BOOTPC 68
-#define BOOTREPLY 2
-#define BOOTREQUEST 1
+#define BOOTREPLY 2
+#define BOOTREQUEST 1
/*
* Vendor magic cookie (v_magic) for CMU
*/
-#define VM_CMU "CMU"
+#define VM_CMU "CMU"
/*
* Vendor magic cookie (v_magic) for RFC1048
*/
-#define VM_RFC1048 { 99, 130, 83, 99 }
-
-
+#define VM_RFC1048 { 99, 130, 83, 99 }
/*
* RFC1048 tag values used to specify what information is being supplied in
* the vendor field of the packet.
*/
-#define TAG_PAD ((unsigned char) 0)
-#define TAG_SUBNET_MASK ((unsigned char) 1)
-#define TAG_TIME_OFFSET ((unsigned char) 2)
-#define TAG_GATEWAY ((unsigned char) 3)
-#define TAG_TIME_SERVER ((unsigned char) 4)
-#define TAG_NAME_SERVER ((unsigned char) 5)
-#define TAG_DOMAIN_SERVER ((unsigned char) 6)
-#define TAG_LOG_SERVER ((unsigned char) 7)
-#define TAG_COOKIE_SERVER ((unsigned char) 8)
-#define TAG_LPR_SERVER ((unsigned char) 9)
-#define TAG_IMPRESS_SERVER ((unsigned char) 10)
-#define TAG_RLP_SERVER ((unsigned char) 11)
-#define TAG_HOSTNAME ((unsigned char) 12)
-#define TAG_BOOTSIZE ((unsigned char) 13)
-#define TAG_DUMPFILE ((unsigned char) 14)
-#define TAG_DOMAINNAME ((unsigned char) 15)
-#define TAG_SWAPSERVER ((unsigned char) 16)
-#define TAG_ROOTPATH ((unsigned char) 17)
+#define TAG_PAD ((unsigned char) 0)
+#define TAG_SUBNET_MASK ((unsigned char) 1)
+#define TAG_TIME_OFFSET ((unsigned char) 2)
+#define TAG_GATEWAY ((unsigned char) 3)
+#define TAG_TIME_SERVER ((unsigned char) 4)
+#define TAG_NAME_SERVER ((unsigned char) 5)
+#define TAG_DOMAIN_SERVER ((unsigned char) 6)
+#define TAG_LOG_SERVER ((unsigned char) 7)
+#define TAG_COOKIE_SERVER ((unsigned char) 8)
+#define TAG_LPR_SERVER ((unsigned char) 9)
+#define TAG_IMPRESS_SERVER ((unsigned char) 10)
+#define TAG_RLP_SERVER ((unsigned char) 11)
+#define TAG_HOSTNAME ((unsigned char) 12)
+#define TAG_BOOTSIZE ((unsigned char) 13)
+#define TAG_DUMPFILE ((unsigned char) 14)
+#define TAG_DOMAINNAME ((unsigned char) 15)
+#define TAG_SWAPSERVER ((unsigned char) 16)
+#define TAG_ROOTPATH ((unsigned char) 17)
#define TAG_INTF_MTU ((unsigned char) 26)
#ifdef SUPPORT_DHCP
-#define TAG_REQ_ADDR ((unsigned char) 50)
-#define TAG_LEASETIME ((unsigned char) 51)
-#define TAG_OVERLOAD ((unsigned char) 52)
-#define TAG_DHCP_MSGTYPE ((unsigned char) 53)
-#define TAG_SERVERID ((unsigned char) 54)
-#define TAG_PARAM_REQ ((unsigned char) 55)
-#define TAG_MSG ((unsigned char) 56)
-#define TAG_MAXSIZE ((unsigned char) 57)
-#define TAG_T1 ((unsigned char) 58)
-#define TAG_T2 ((unsigned char) 59)
-#define TAG_CLASSID ((unsigned char) 60)
-#define TAG_CLIENTID ((unsigned char) 61)
-#define TAG_USER_CLASS ((unsigned char) 77)
+#define TAG_REQ_ADDR ((unsigned char) 50)
+#define TAG_LEASETIME ((unsigned char) 51)
+#define TAG_OVERLOAD ((unsigned char) 52)
+#define TAG_DHCP_MSGTYPE ((unsigned char) 53)
+#define TAG_SERVERID ((unsigned char) 54)
+#define TAG_PARAM_REQ ((unsigned char) 55)
+#define TAG_MSG ((unsigned char) 56)
+#define TAG_MAXSIZE ((unsigned char) 57)
+#define TAG_T1 ((unsigned char) 58)
+#define TAG_T2 ((unsigned char) 59)
+#define TAG_CLASSID ((unsigned char) 60)
+#define TAG_CLIENTID ((unsigned char) 61)
+#define TAG_USER_CLASS ((unsigned char) 77)
#endif
-#define TAG_END ((unsigned char) 255)
+#define TAG_END ((unsigned char) 255)
#ifdef SUPPORT_DHCP
-#define DHCPDISCOVER 1
-#define DHCPOFFER 2
-#define DHCPREQUEST 3
-#define DHCPDECLINE 4
-#define DHCPACK 5
-#define DHCPNAK 6
-#define DHCPRELEASE 7
+#define DHCPDISCOVER 1
+#define DHCPOFFER 2
+#define DHCPREQUEST 3
+#define DHCPDECLINE 4
+#define DHCPACK 5
+#define DHCPNAK 6
+#define DHCPRELEASE 7
#endif
/*
@@ -138,7 +136,7 @@ struct cmu_vend {
/* v_flags values */
-#define VF_SMASK 1 /* Subnet mask field contains valid data */
+#define VF_SMASK 1 /* Subnet mask field contains valid data */
/* cached bootp response/dhcp ack */
extern struct bootp *bootp_response;
diff --git a/usr/src/boot/lib/libstand/cd9660.c b/usr/src/boot/lib/libstand/cd9660.c
index 9a780b44f7..3b28e20485 100644
--- a/usr/src/boot/lib/libstand/cd9660.c
+++ b/usr/src/boot/lib/libstand/cd9660.c
@@ -55,10 +55,10 @@
typedef struct {
ISO_SUSP_HEADER h;
- u_char signature [ISODCL ( 5, 6)];
- u_char len_skp [ISODCL ( 7, 7)]; /* 711 */
+ uchar_t signature [ISODCL(5, 6)];
+ uchar_t len_skp [ISODCL(7, 7)]; /* 711 */
} ISO_SUSP_PRESENT;
-
+
static int buf_read_file(struct open_file *f, char **buf_p,
size_t *size_p);
static int cd9660_open(const char *path, struct open_file *f);
@@ -79,14 +79,14 @@ static ISO_SUSP_HEADER *susp_lookup_record(struct open_file *f,
int lenskip);
struct fs_ops cd9660_fsops = {
- "cd9660",
- cd9660_open,
- cd9660_close,
- cd9660_read,
- null_write,
- cd9660_seek,
- cd9660_stat,
- cd9660_readdir
+ .fs_name = "cd9660",
+ .fo_open = cd9660_open,
+ .fo_close = cd9660_close,
+ .fo_read = cd9660_read,
+ .fo_write = null_write,
+ .fo_seek = cd9660_seek,
+ .fo_stat = cd9660_stat,
+ .fo_readdir = cd9660_readdir
};
#define F_ISDIR 0x0001 /* Directory */
@@ -94,20 +94,20 @@ struct fs_ops cd9660_fsops = {
#define F_RR 0x0004 /* Rock Ridge on this volume */
struct file {
- int f_flags; /* file flags */
- off_t f_off; /* Current offset within file */
- daddr_t f_bno; /* Starting block number */
- off_t f_size; /* Size of file */
- daddr_t f_buf_blkno; /* block number of data block */
+ int f_flags; /* file flags */
+ off_t f_off; /* Current offset within file */
+ daddr_t f_bno; /* Starting block number */
+ off_t f_size; /* Size of file */
+ daddr_t f_buf_blkno; /* block number of data block */
char *f_buf; /* buffer for data block */
int f_susp_skip; /* len_skip for SUSP records */
};
struct ptable_ent {
- char namlen [ISODCL( 1, 1)]; /* 711 */
- char extlen [ISODCL( 2, 2)]; /* 711 */
- char block [ISODCL( 3, 6)]; /* 732 */
- char parent [ISODCL( 7, 8)]; /* 722 */
+ char namlen [ISODCL(1, 1)]; /* 711 */
+ char extlen [ISODCL(2, 2)]; /* 711 */
+ char block [ISODCL(3, 6)]; /* 732 */
+ char parent [ISODCL(7, 8)]; /* 722 */
char name [1];
};
#define PTFIXSZ 8
@@ -205,7 +205,7 @@ rrip_check(struct open_file *f, struct iso_directory_record *dp, int *lenskip)
sp = (ISO_SUSP_PRESENT *)p;
if (bcmp(sp->h.type, SUSP_PRESENT, 2) != 0)
return (0);
- if (isonum_711(sp->h.length) != sizeof(ISO_SUSP_PRESENT))
+ if (isonum_711(sp->h.length) != sizeof (ISO_SUSP_PRESENT))
return (0);
if (sp->signature[0] != 0xbe || sp->signature[1] != 0xef)
return (0);
@@ -247,10 +247,10 @@ dirmatch(struct open_file *f, const char *path, struct iso_directory_record *dp,
continue;
if (!icase && toupper(*path) == *cp)
continue;
- return 0;
+ return (0);
}
if (*path && *path != '/')
- return 0;
+ return (0);
/*
* Allow stripping of trailing dots and the version number.
* Note that this will find the first instead of the last version
@@ -259,12 +259,12 @@ dirmatch(struct open_file *f, const char *path, struct iso_directory_record *dp,
if (i >= 0 && (*cp == ';' || *cp == '.')) {
/* This is to prevent matching of numeric extensions */
if (*cp == '.' && cp[1] != ';')
- return 0;
+ return (0);
while (--i >= 0)
if (*++cp != ';' && (*cp < '0' || *cp > '9'))
- return 0;
+ return (0);
}
- return 1;
+ return (1);
}
static int
@@ -282,7 +282,7 @@ cd9660_open(const char *path, struct open_file *f)
/* First find the volume descriptor */
buf = malloc(buf_size = ISO_DEFAULT_BLOCK_SIZE);
vd = buf;
- for (bno = 16;; bno++) {
+ for (bno = 16; ; bno++) {
twiddle(1);
rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno),
ISO_DEFAULT_BLOCK_SIZE, buf, &read);
@@ -293,7 +293,7 @@ cd9660_open(const char *path, struct open_file *f)
goto out;
}
rc = EINVAL;
- if (bcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0)
+ if (bcmp(vd->id, ISO_STANDARD_ID, sizeof (vd->id)) != 0)
goto out;
if (isonum_711(vd->type) == ISO_VD_END)
goto out;
@@ -317,11 +317,10 @@ cd9660_open(const char *path, struct open_file *f)
while (off < dsize) {
if ((off % ISO_DEFAULT_BLOCK_SIZE) == 0) {
twiddle(1);
- rc = f->f_dev->dv_strategy
- (f->f_devdata, F_READ,
- cdb2devb(bno + boff),
- ISO_DEFAULT_BLOCK_SIZE,
- buf, &read);
+ rc = f->f_dev->dv_strategy(f->f_devdata, F_READ,
+ cdb2devb(bno + boff),
+ ISO_DEFAULT_BLOCK_SIZE,
+ buf, &read);
if (rc)
goto out;
if (read != ISO_DEFAULT_BLOCK_SIZE) {
@@ -329,12 +328,12 @@ cd9660_open(const char *path, struct open_file *f)
goto out;
}
boff++;
- dp = (struct iso_directory_record *) buf;
+ dp = (struct iso_directory_record *)buf;
}
if (isonum_711(dp->length) == 0) {
- /* skip to next block, if any */
- off = boff * ISO_DEFAULT_BLOCK_SIZE;
- continue;
+ /* skip to next block, if any */
+ off = boff * ISO_DEFAULT_BLOCK_SIZE;
+ continue;
}
/* See if RRIP is in use. */
@@ -342,14 +341,14 @@ cd9660_open(const char *path, struct open_file *f)
use_rrip = rrip_check(f, dp, &lenskip);
if (dirmatch(f, path, dp, use_rrip,
- first ? 0 : lenskip)) {
+ first ? 0 : lenskip)) {
first = 0;
break;
} else
first = 0;
dp = (struct iso_directory_record *)
- ((char *) dp + isonum_711(dp->length));
+ ((char *)dp + isonum_711(dp->length));
/* If the new block has zero length, it is padding. */
if (isonum_711(dp->length) == 0) {
/* Skip to next block, if any. */
@@ -370,8 +369,8 @@ cd9660_open(const char *path, struct open_file *f)
}
/* allocate file system specific data structure */
- fp = malloc(sizeof(struct file));
- bzero(fp, sizeof(struct file));
+ fp = malloc(sizeof (struct file));
+ bzero(fp, sizeof (struct file));
f->f_fsdata = (void *)fp;
if ((isonum_711(rec.flags) & 2) != 0) {
@@ -403,14 +402,14 @@ cd9660_open(const char *path, struct open_file *f)
fp->f_size = isonum_733(rec.size);
free(buf);
- return 0;
+ return (0);
out:
if (fp)
free(fp);
free(buf);
- return rc;
+ return (rc);
}
static int
@@ -421,7 +420,7 @@ cd9660_close(struct open_file *f)
f->f_fsdata = NULL;
free(fp);
- return 0;
+ return (0);
}
static int
@@ -508,7 +507,7 @@ again:
if (isonum_711(ep->length) == 0) {
daddr_t blkno;
-
+
/* skip to next block, if any */
blkno = fp->f_off / ISO_DEFAULT_BLOCK_SIZE;
fp->f_off = (blkno + 1) * ISO_DEFAULT_BLOCK_SIZE;
@@ -535,7 +534,7 @@ again:
}
}
}
- reclen = sizeof(struct dirent) - (MAXNAMLEN+1) + namelen + 1;
+ reclen = sizeof (struct dirent) - (MAXNAMLEN+1) + namelen + 1;
reclen = (reclen + 3) & ~3;
d->d_fileno = isonum_733(ep->extent);
@@ -569,9 +568,9 @@ cd9660_seek(struct open_file *f, off_t offset, int where)
fp->f_off = fp->f_size - offset;
break;
default:
- return -1;
+ return (-1);
}
- return fp->f_off;
+ return (fp->f_off);
}
static int
@@ -587,5 +586,5 @@ cd9660_stat(struct open_file *f, struct stat *sb)
sb->st_mode |= S_IFREG;
sb->st_uid = sb->st_gid = 0;
sb->st_size = fp->f_size;
- return 0;
+ return (0);
}
diff --git a/usr/src/boot/lib/libstand/dosfs.c b/usr/src/boot/lib/libstand/dosfs.c
index 8d5adb4cc9..1732511b07 100644
--- a/usr/src/boot/lib/libstand/dosfs.c
+++ b/usr/src/boot/lib/libstand/dosfs.c
@@ -41,138 +41,138 @@
#include "dosfs.h"
-static int dos_open(const char *path, struct open_file *fd);
-static int dos_close(struct open_file *fd);
-static int dos_read(struct open_file *fd, void *buf, size_t size, size_t *resid);
-static off_t dos_seek(struct open_file *fd, off_t offset, int whence);
-static int dos_stat(struct open_file *fd, struct stat *sb);
-static int dos_readdir(struct open_file *fd, struct dirent *d);
+static int dos_open(const char *, struct open_file *);
+static int dos_close(struct open_file *);
+static int dos_read(struct open_file *, void *, size_t, size_t *);
+static off_t dos_seek(struct open_file *, off_t offset, int);
+static int dos_stat(struct open_file *, struct stat *);
+static int dos_readdir(struct open_file *, struct dirent *);
struct fs_ops dosfs_fsops = {
- "dosfs",
- dos_open,
- dos_close,
- dos_read,
- null_write,
- dos_seek,
- dos_stat,
- dos_readdir
+ .fs_name = "dosfs",
+ .fo_open = dos_open,
+ .fo_close = dos_close,
+ .fo_read = dos_read,
+ .fo_write = null_write,
+ .fo_seek = dos_seek,
+ .fo_stat = dos_stat,
+ .fo_readdir = dos_readdir
};
-#define SECSIZ 512 /* sector size */
-#define SSHIFT 9 /* SECSIZ shift */
-#define DEPSEC 16 /* directory entries per sector */
-#define DSHIFT 4 /* DEPSEC shift */
-#define LOCLUS 2 /* lowest cluster number */
-#define FATBLKSZ 0x20000 /* size of block in the FAT cache buffer */
+#define SECSIZ 512 /* sector size */
+#define SSHIFT 9 /* SECSIZ shift */
+#define DEPSEC 16 /* directory entries per sector */
+#define DSHIFT 4 /* DEPSEC shift */
+#define LOCLUS 2 /* lowest cluster number */
+#define FATBLKSZ 0x20000 /* size of block in the FAT cache buffer */
/* DOS "BIOS Parameter Block" */
typedef struct {
- u_char secsiz[2]; /* sector size */
- u_char spc; /* sectors per cluster */
- u_char ressec[2]; /* reserved sectors */
- u_char fats; /* FATs */
- u_char dirents[2]; /* root directory entries */
- u_char secs[2]; /* total sectors */
- u_char media; /* media descriptor */
- u_char spf[2]; /* sectors per FAT */
- u_char spt[2]; /* sectors per track */
- u_char heads[2]; /* drive heads */
- u_char hidsec[4]; /* hidden sectors */
- u_char lsecs[4]; /* huge sectors */
- u_char lspf[4]; /* huge sectors per FAT */
- u_char xflg[2]; /* flags */
- u_char vers[2]; /* filesystem version */
- u_char rdcl[4]; /* root directory start cluster */
- u_char infs[2]; /* filesystem info sector */
- u_char bkbs[2]; /* backup boot sector */
+ uchar_t secsiz[2]; /* sector size */
+ uchar_t spc; /* sectors per cluster */
+ uchar_t ressec[2]; /* reserved sectors */
+ uchar_t fats; /* FATs */
+ uchar_t dirents[2]; /* root directory entries */
+ uchar_t secs[2]; /* total sectors */
+ uchar_t media; /* media descriptor */
+ uchar_t spf[2]; /* sectors per FAT */
+ uchar_t spt[2]; /* sectors per track */
+ uchar_t heads[2]; /* drive heads */
+ uchar_t hidsec[4]; /* hidden sectors */
+ uchar_t lsecs[4]; /* huge sectors */
+ uchar_t lspf[4]; /* huge sectors per FAT */
+ uchar_t xflg[2]; /* flags */
+ uchar_t vers[2]; /* filesystem version */
+ uchar_t rdcl[4]; /* root directory start cluster */
+ uchar_t infs[2]; /* filesystem info sector */
+ uchar_t bkbs[2]; /* backup boot sector */
} DOS_BPB;
/* Initial portion of DOS boot sector */
typedef struct {
- u_char jmp[3]; /* usually 80x86 'jmp' opcode */
- u_char oem[8]; /* OEM name and version */
- DOS_BPB bpb; /* BPB */
+ uchar_t jmp[3]; /* usually 80x86 'jmp' opcode */
+ uchar_t oem[8]; /* OEM name and version */
+ DOS_BPB bpb; /* BPB */
} DOS_BS;
/* Supply missing "." and ".." root directory entries */
static const char *const dotstr[2] = {".", ".."};
static DOS_DE dot[2] = {
- {". ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
- {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}},
- {".. ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
- {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}}
+ {". ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
+ {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}},
+ {".. ", " ", FA_DIR, {0, 0, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
+ {0, 0}, {0x21, 0}, {0, 0}, {0, 0, 0, 0}}
};
/* The usual conversion macros to avoid multiplication and division */
-#define bytsec(n) ((n) >> SSHIFT)
-#define secbyt(s) ((s) << SSHIFT)
-#define entsec(e) ((e) >> DSHIFT)
-#define bytblk(fs, n) ((n) >> (fs)->bshift)
-#define blkbyt(fs, b) ((b) << (fs)->bshift)
-#define secblk(fs, s) ((s) >> ((fs)->bshift - SSHIFT))
-#define blksec(fs, b) ((b) << ((fs)->bshift - SSHIFT))
+#define bytsec(n) ((n) >> SSHIFT)
+#define secbyt(s) ((s) << SSHIFT)
+#define entsec(e) ((e) >> DSHIFT)
+#define bytblk(fs, n) ((n) >> (fs)->bshift)
+#define blkbyt(fs, b) ((b) << (fs)->bshift)
+#define secblk(fs, s) ((s) >> ((fs)->bshift - SSHIFT))
+#define blksec(fs, b) ((b) << ((fs)->bshift - SSHIFT))
/* Convert cluster number to offset within filesystem */
-#define blkoff(fs, b) (secbyt((fs)->lsndta) + blkbyt(fs, (b) - LOCLUS))
+#define blkoff(fs, b) (secbyt((fs)->lsndta) + blkbyt(fs, (b) - LOCLUS))
/* Convert cluster number to logical sector number */
-#define blklsn(fs, b) ((fs)->lsndta + blksec(fs, (b) - LOCLUS))
+#define blklsn(fs, b) ((fs)->lsndta + blksec(fs, (b) - LOCLUS))
/* Convert cluster number to offset within FAT */
-#define fatoff(sz, c) ((sz) == 12 ? (c) + ((c) >> 1) : \
- (sz) == 16 ? (c) << 1 : \
+#define fatoff(sz, c) ((sz) == 12 ? (c) + ((c) >> 1) : \
+ (sz) == 16 ? (c) << 1 : \
(c) << 2)
/* Does cluster number reference a valid data cluster? */
-#define okclus(fs, c) ((c) >= LOCLUS && (c) <= (fs)->xclus)
+#define okclus(fs, c) ((c) >= LOCLUS && (c) <= (fs)->xclus)
/* Get start cluster from directory entry */
-#define stclus(sz, de) ((sz) != 32 ? cv2((de)->clus) : \
- ((u_int)cv2((de)->dex.h_clus) << 16) | \
- cv2((de)->clus))
+#define stclus(sz, de) ((sz) != 32 ? cv2((de)->clus) : \
+ ((uint_t)cv2((de)->dex.h_clus) << 16) | \
+ cv2((de)->clus))
static int parsebs(DOS_FS *, DOS_BS *);
static int namede(DOS_FS *, const char *, DOS_DE **);
-static int lookup(DOS_FS *, u_int, const char *, DOS_DE **);
-static void cp_xdnm(u_char *, DOS_XDE *);
-static void cp_sfn(u_char *, DOS_DE *);
+static int lookup(DOS_FS *, uint_t, const char *, DOS_DE **);
+static void cp_xdnm(uchar_t *, DOS_XDE *);
+static void cp_sfn(uchar_t *, DOS_DE *);
static off_t fsize(DOS_FS *, DOS_DE *);
-static int fatcnt(DOS_FS *, u_int);
-static int fatget(DOS_FS *, u_int *);
-static int fatend(u_int, u_int);
-static int ioread(DOS_FS *, u_int, void *, size_t);
+static int fatcnt(DOS_FS *, uint_t);
+static int fatget(DOS_FS *, uint_t *);
+static int fatend(uint_t, uint_t);
+static int ioread(DOS_FS *, uint_t, void *, size_t);
static int ioget(struct open_file *, daddr_t, void *, size_t);
static int
-dos_read_fatblk(DOS_FS *fs, struct open_file *fd, u_int blknum)
+dos_read_fatblk(DOS_FS *fs, struct open_file *fd, uint_t blknum)
{
- int err;
- size_t io_size;
- daddr_t offset_in_fat, max_offset_in_fat;
-
- offset_in_fat = ((daddr_t)blknum) * FATBLKSZ;
- max_offset_in_fat = secbyt(fs->spf);
- io_size = FATBLKSZ;
- if (offset_in_fat > max_offset_in_fat)
- offset_in_fat = max_offset_in_fat;
- if (offset_in_fat + io_size > max_offset_in_fat)
- io_size = ((size_t)(max_offset_in_fat - offset_in_fat));
-
- if (io_size != 0) {
- err = ioget(fd, fs->lsnfat + bytsec(offset_in_fat),
- fs->fatbuf, io_size);
- if (err != 0) {
- fs->fatbuf_blknum = ((u_int)(-1));
- return (err);
+ int err;
+ size_t io_size;
+ daddr_t offset_in_fat, max_offset_in_fat;
+
+ offset_in_fat = ((daddr_t)blknum) * FATBLKSZ;
+ max_offset_in_fat = secbyt(fs->spf);
+ io_size = FATBLKSZ;
+ if (offset_in_fat > max_offset_in_fat)
+ offset_in_fat = max_offset_in_fat;
+ if (offset_in_fat + io_size > max_offset_in_fat)
+ io_size = ((size_t)(max_offset_in_fat - offset_in_fat));
+
+ if (io_size != 0) {
+ err = ioget(fd, fs->lsnfat + bytsec(offset_in_fat),
+ fs->fatbuf, io_size);
+ if (err != 0) {
+ fs->fatbuf_blknum = ((uint_t)(-1));
+ return (err);
+ }
}
- }
- if (io_size < FATBLKSZ)
- memset(fs->fatbuf + io_size, 0, FATBLKSZ - io_size);
+ if (io_size < FATBLKSZ)
+ memset(fs->fatbuf + io_size, 0, FATBLKSZ - io_size);
- fs->fatbuf_blknum = blknum;
- return (0);
+ fs->fatbuf_blknum = blknum;
+ return (0);
}
/*
@@ -181,38 +181,38 @@ dos_read_fatblk(DOS_FS *fs, struct open_file *fd, u_int blknum)
static int
dos_mount(DOS_FS *fs, struct open_file *fd)
{
- int err;
- u_char *buf;
+ int err;
+ uchar_t *buf;
+
+ bzero(fs, sizeof (DOS_FS));
+ fs->fd = fd;
+
+ if ((buf = malloc(secbyt(1))) == NULL)
+ return (errno);
+ if ((err = ioget(fs->fd, 0, buf, secbyt(1))) ||
+ (err = parsebs(fs, (DOS_BS *)buf))) {
+ free(buf);
+ return (err);
+ }
+ free(buf);
- bzero(fs, sizeof(DOS_FS));
- fs->fd = fd;
+ if ((fs->fatbuf = malloc(FATBLKSZ)) == NULL)
+ return (errno);
+ err = dos_read_fatblk(fs, fd, 0);
+ if (err != 0) {
+ free(fs->fatbuf);
+ return (err);
+ }
- if ((buf = malloc(secbyt(1))) == NULL)
- return (errno);
- if ((err = ioget(fs->fd, 0, buf, secbyt(1))) ||
- (err = parsebs(fs, (DOS_BS *)buf))) {
- free(buf);
- return (err);
- }
- free(buf);
-
- if ((fs->fatbuf = malloc(FATBLKSZ)) == NULL)
- return (errno);
- err = dos_read_fatblk(fs, fd, 0);
- if (err != 0) {
- free(fs->fatbuf);
- return (err);
- }
-
- fs->root = dot[0];
- fs->root.name[0] = ' ';
- if (fs->fatsz == 32) {
- fs->root.clus[0] = fs->rdcl & 0xff;
- fs->root.clus[1] = (fs->rdcl >> 8) & 0xff;
- fs->root.dex.h_clus[0] = (fs->rdcl >> 16) & 0xff;
- fs->root.dex.h_clus[1] = (fs->rdcl >> 24) & 0xff;
- }
- return (0);
+ fs->root = dot[0];
+ fs->root.name[0] = ' ';
+ if (fs->fatsz == 32) {
+ fs->root.clus[0] = fs->rdcl & 0xff;
+ fs->root.clus[1] = (fs->rdcl >> 8) & 0xff;
+ fs->root.dex.h_clus[0] = (fs->rdcl >> 16) & 0xff;
+ fs->root.dex.h_clus[1] = (fs->rdcl >> 24) & 0xff;
+ }
+ return (0);
}
/*
@@ -221,11 +221,11 @@ dos_mount(DOS_FS *fs, struct open_file *fd)
static int
dos_unmount(DOS_FS *fs)
{
- if (fs->links)
- return (EBUSY);
- free(fs->fatbuf);
- free(fs);
- return (0);
+ if (fs->links)
+ return (EBUSY);
+ free(fs->fatbuf);
+ free(fs);
+ return (0);
}
/*
@@ -234,45 +234,45 @@ dos_unmount(DOS_FS *fs)
static int
dos_open(const char *path, struct open_file *fd)
{
- DOS_DE *de;
- DOS_FILE *f;
- DOS_FS *fs;
- u_int size, clus;
- int err;
-
- /* Allocate mount structure, associate with open */
- if ((fs = malloc(sizeof(DOS_FS))) == NULL)
- return (errno);
- if ((err = dos_mount(fs, fd))) {
- free(fs);
- return (err);
- }
+ DOS_DE *de;
+ DOS_FILE *f;
+ DOS_FS *fs;
+ uint_t size, clus;
+ int err;
+
+ /* Allocate mount structure, associate with open */
+ if ((fs = malloc(sizeof (DOS_FS))) == NULL)
+ return (errno);
+ if ((err = dos_mount(fs, fd))) {
+ free(fs);
+ return (err);
+ }
- if ((err = namede(fs, path, &de))) {
- dos_unmount(fs);
- return (err);
- }
+ if ((err = namede(fs, path, &de))) {
+ dos_unmount(fs);
+ return (err);
+ }
- clus = stclus(fs->fatsz, de);
- size = cv4(de->size);
+ clus = stclus(fs->fatsz, de);
+ size = cv4(de->size);
- if ((!(de->attr & FA_DIR) && (!clus != !size)) ||
- ((de->attr & FA_DIR) && size) ||
- (clus && !okclus(fs, clus))) {
- dos_unmount(fs);
- return (EINVAL);
- }
- if ((f = malloc(sizeof(DOS_FILE))) == NULL) {
- err = errno;
- dos_unmount(fs);
- return (err);
- }
- bzero(f, sizeof(DOS_FILE));
- f->fs = fs;
- fs->links++;
- f->de = *de;
- fd->f_fsdata = (void *)f;
- return (0);
+ if ((!(de->attr & FA_DIR) && (!clus != !size)) ||
+ ((de->attr & FA_DIR) && size) ||
+ (clus && !okclus(fs, clus))) {
+ dos_unmount(fs);
+ return (EINVAL);
+ }
+ if ((f = malloc(sizeof (DOS_FILE))) == NULL) {
+ err = errno;
+ dos_unmount(fs);
+ return (err);
+ }
+ bzero(f, sizeof (DOS_FILE));
+ f->fs = fs;
+ fs->links++;
+ f->de = *de;
+ fd->f_fsdata = f;
+ return (0);
}
/*
@@ -281,57 +281,58 @@ dos_open(const char *path, struct open_file *fd)
static int
dos_read(struct open_file *fd, void *buf, size_t nbyte, size_t *resid)
{
- off_t size;
- u_int nb, off, clus, c, cnt, n;
- DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
- int err = 0;
-
- /*
- * as ioget() can be called *a lot*, use twiddle here.
- * also 4 seems to be good value not to slow loading down too much:
- * with 270MB file (~540k ioget() calls, twiddle can easily waste 4-5sec.
- */
- twiddle(4);
- nb = (u_int)nbyte;
- if ((size = fsize(f->fs, &f->de)) == -1)
- return (EINVAL);
- if (nb > (n = size - f->offset))
- nb = n;
- off = f->offset;
- if ((clus = stclus(f->fs->fatsz, &f->de)))
- off &= f->fs->bsize - 1;
- c = f->c;
- cnt = nb;
- while (cnt) {
- n = 0;
- if (!c) {
- if ((c = clus))
- n = bytblk(f->fs, f->offset);
- } else if (!off)
- n++;
- while (n--) {
- if ((err = fatget(f->fs, &c)))
- goto out;
- if (!okclus(f->fs, c)) {
- err = EINVAL;
- goto out;
- }
+ off_t size;
+ uint_t nb, off, clus, c, cnt, n;
+ DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
+ int err = 0;
+
+ /*
+ * as ioget() can be called *a lot*, use twiddle here.
+ * also 4 seems to be good value not to slow loading down too much:
+ * with 270MB file (~540k ioget() calls, twiddle can easily waste
+ * 4-5 sec.
+ */
+ twiddle(4);
+ nb = (uint_t)nbyte;
+ if ((size = fsize(f->fs, &f->de)) == -1)
+ return (EINVAL);
+ if (nb > (n = size - f->offset))
+ nb = n;
+ off = f->offset;
+ if ((clus = stclus(f->fs->fatsz, &f->de)))
+ off &= f->fs->bsize - 1;
+ c = f->c;
+ cnt = nb;
+ while (cnt) {
+ n = 0;
+ if (!c) {
+ if ((c = clus))
+ n = bytblk(f->fs, f->offset);
+ } else if (!off)
+ n++;
+ while (n--) {
+ if ((err = fatget(f->fs, &c)))
+ goto out;
+ if (!okclus(f->fs, c)) {
+ err = EINVAL;
+ goto out;
+ }
+ }
+ if (!clus || (n = f->fs->bsize - off) > cnt)
+ n = cnt;
+ if ((err = ioread(f->fs, (c ? blkoff(f->fs, c) :
+ secbyt(f->fs->lsndir)) + off, buf, n)))
+ goto out;
+ f->offset += n;
+ f->c = c;
+ off = 0;
+ buf = (char *)buf + n;
+ cnt -= n;
}
- if (!clus || (n = f->fs->bsize - off) > cnt)
- n = cnt;
- if ((err = ioread(f->fs, (c ? blkoff(f->fs, c) :
- secbyt(f->fs->lsndir)) + off, buf, n)))
- goto out;
- f->offset += n;
- f->c = c;
- off = 0;
- buf = (char *)buf + n;
- cnt -= n;
- }
- out:
- if (resid)
- *resid = nbyte - nb + cnt;
- return (err);
+out:
+ if (resid)
+ *resid = nbyte - nb + cnt;
+ return (err);
}
/*
@@ -340,33 +341,33 @@ dos_read(struct open_file *fd, void *buf, size_t nbyte, size_t *resid)
static off_t
dos_seek(struct open_file *fd, off_t offset, int whence)
{
- off_t off;
- u_int size;
- DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
-
- size = cv4(f->de.size);
- switch (whence) {
- case SEEK_SET:
- off = 0;
- break;
- case SEEK_CUR:
- off = f->offset;
- break;
- case SEEK_END:
- off = size;
- break;
- default:
- errno = EINVAL;
- return (-1);
- }
- off += offset;
- if (off < 0 || off > size) {
- errno = EINVAL;
- return (-1);
- }
- f->offset = (u_int)off;
- f->c = 0;
- return (off);
+ off_t off;
+ uint_t size;
+ DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
+
+ size = cv4(f->de.size);
+ switch (whence) {
+ case SEEK_SET:
+ off = 0;
+ break;
+ case SEEK_CUR:
+ off = f->offset;
+ break;
+ case SEEK_END:
+ off = size;
+ break;
+ default:
+ errno = EINVAL;
+ return (-1);
+ }
+ off += offset;
+ if (off < 0 || off > size) {
+ errno = EINVAL;
+ return (-1);
+ }
+ f->offset = (uint_t)off;
+ f->c = 0;
+ return (off);
}
/*
@@ -375,13 +376,13 @@ dos_seek(struct open_file *fd, off_t offset, int whence)
static int
dos_close(struct open_file *fd)
{
- DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
- DOS_FS *fs = f->fs;
+ DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
+ DOS_FS *fs = f->fs;
- f->fs->links--;
- free(f);
- dos_unmount(fs);
- return (0);
+ f->fs->links--;
+ free(f);
+ dos_unmount(fs);
+ return (0);
}
/*
@@ -390,105 +391,105 @@ dos_close(struct open_file *fd)
static int
dos_stat(struct open_file *fd, struct stat *sb)
{
- DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
-
- /* only important stuff */
- sb->st_mode = f->de.attr & FA_DIR ? S_IFDIR | 0555 : S_IFREG | 0444;
- sb->st_nlink = 1;
- sb->st_uid = 0;
- sb->st_gid = 0;
- if ((sb->st_size = fsize(f->fs, &f->de)) == -1)
- return (EINVAL);
- return (0);
+ DOS_FILE *f = (DOS_FILE *)fd->f_fsdata;
+
+ /* only important stuff */
+ sb->st_mode = f->de.attr & FA_DIR ? S_IFDIR | 0555 : S_IFREG | 0444;
+ sb->st_nlink = 1;
+ sb->st_uid = 0;
+ sb->st_gid = 0;
+ if ((sb->st_size = fsize(f->fs, &f->de)) == -1)
+ return (EINVAL);
+ return (0);
}
static int
dos_checksum(unsigned char *name, unsigned char *ext)
{
- int x, i;
- char buf[11];
-
- bcopy(name, buf, 8);
- bcopy(ext, buf+8, 3);
- x = 0;
- for (i = 0; i < 11; i++) {
- x = ((x & 1) << 7) | (x >> 1);
- x += buf[i];
- x &= 0xff;
- }
- return (x);
+ int x, i;
+ char buf[11];
+
+ bcopy(name, buf, 8);
+ bcopy(ext, buf+8, 3);
+ x = 0;
+ for (i = 0; i < 11; i++) {
+ x = ((x & 1) << 7) | (x >> 1);
+ x += buf[i];
+ x &= 0xff;
+ }
+ return (x);
}
static int
dos_readdir(struct open_file *fd, struct dirent *d)
{
- /* DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; */
- u_char fn[261];
- DOS_DIR dd;
- size_t res;
- u_int chk, x, xdn;
- int err;
-
- x = chk = 0;
- while (1) {
- xdn = x;
- x = 0;
- err = dos_read(fd, &dd, sizeof(dd), &res);
- if (err)
- return (err);
- if (res == sizeof(dd))
- return (ENOENT);
- if (dd.de.name[0] == 0)
- return (ENOENT);
-
- /* Skip deleted entries */
- if (dd.de.name[0] == 0xe5)
- continue;
-
- /* Check if directory entry is volume label */
- if (dd.de.attr & FA_LABEL) {
- /*
- * If volume label set, check if the current entry is
- * extended entry (FA_XDE) for long file names.
- */
- if ((dd.de.attr & FA_MASK) == FA_XDE) {
- /*
- * Read through all following extended entries
- * to get the long file name. 0x40 marks the
- * last entry containing part of long file name.
- */
- if (dd.xde.seq & 0x40)
- chk = dd.xde.chk;
- else if (dd.xde.seq != xdn - 1 || dd.xde.chk != chk)
- continue;
- x = dd.xde.seq & ~0x40;
- if (x < 1 || x > 20) {
- x = 0;
- continue;
+ uchar_t fn[261];
+ DOS_DIR dd;
+ size_t res;
+ uint_t chk, x, xdn;
+ int err;
+
+ x = chk = 0;
+ while (1) {
+ xdn = x;
+ x = 0;
+ err = dos_read(fd, &dd, sizeof (dd), &res);
+ if (err)
+ return (err);
+ if (res == sizeof (dd))
+ return (ENOENT);
+ if (dd.de.name[0] == 0)
+ return (ENOENT);
+
+ /* Skip deleted entries */
+ if (dd.de.name[0] == 0xe5)
+ continue;
+
+ /* Check if directory entry is volume label */
+ if (dd.de.attr & FA_LABEL) {
+ /*
+ * If volume label set, check if the current entry is
+ * extended entry (FA_XDE) for long file names.
+ */
+ if ((dd.de.attr & FA_MASK) == FA_XDE) {
+ /*
+ * Read through all following extended entries
+ * to get the long file name. 0x40 marks the
+ * last entry containing part of long file name.
+ */
+ if (dd.xde.seq & 0x40)
+ chk = dd.xde.chk;
+ else if (dd.xde.seq != xdn - 1 ||
+ dd.xde.chk != chk)
+ continue;
+ x = dd.xde.seq & ~0x40;
+ if (x < 1 || x > 20) {
+ x = 0;
+ continue;
+ }
+ cp_xdnm(fn, &dd.xde);
+ } else {
+ /* skip only volume label entries */
+ continue;
+ }
+ } else {
+ if (xdn == 1) {
+ x = dos_checksum(dd.de.name, dd.de.ext);
+ if (x == chk)
+ break;
+ } else {
+ cp_sfn(fn, &dd.de);
+ break;
+ }
+ x = 0;
}
- cp_xdnm(fn, &dd.xde);
- } else {
- /* skip only volume label entries */
- continue;
- }
- } else {
- if (xdn == 1) {
- x = dos_checksum(dd.de.name, dd.de.ext);
- if (x == chk)
- break;
- } else {
- cp_sfn(fn, &dd.de);
- break;
- }
- x = 0;
}
- }
- d->d_fileno = (dd.de.clus[1] << 8) + dd.de.clus[0];
- d->d_reclen = sizeof(*d);
- d->d_type = (dd.de.attr & FA_DIR) ? DT_DIR : DT_REG;
- memcpy(d->d_name, fn, sizeof(d->d_name));
- return (0);
+ d->d_fileno = (dd.de.clus[1] << 8) + dd.de.clus[0];
+ d->d_reclen = sizeof (*d);
+ d->d_type = (dd.de.attr & FA_DIR) ? DT_DIR : DT_REG;
+ memcpy(d->d_name, fn, sizeof (d->d_name));
+ return (0);
}
/*
@@ -497,47 +498,47 @@ dos_readdir(struct open_file *fd, struct dirent *d)
static int
parsebs(DOS_FS *fs, DOS_BS *bs)
{
- u_int sc;
-
- if ((bs->jmp[0] != 0x69 &&
- bs->jmp[0] != 0xe9 &&
- (bs->jmp[0] != 0xeb || bs->jmp[2] != 0x90)) ||
- bs->bpb.media < 0xf0)
- return (EINVAL);
- if (cv2(bs->bpb.secsiz) != SECSIZ)
- return (EINVAL);
- if (!(fs->spc = bs->bpb.spc) || fs->spc & (fs->spc - 1))
- return (EINVAL);
- fs->bsize = secbyt(fs->spc);
- fs->bshift = ffs(fs->bsize) - 1;
- if ((fs->spf = cv2(bs->bpb.spf))) {
- if (bs->bpb.fats != 2)
- return (EINVAL);
- if (!(fs->dirents = cv2(bs->bpb.dirents)))
- return (EINVAL);
- } else {
- if (!(fs->spf = cv4(bs->bpb.lspf)))
- return (EINVAL);
- if (!bs->bpb.fats || bs->bpb.fats > 16)
- return (EINVAL);
- if ((fs->rdcl = cv4(bs->bpb.rdcl)) < LOCLUS)
- return (EINVAL);
- }
- if (!(fs->lsnfat = cv2(bs->bpb.ressec)))
- return (EINVAL);
- fs->lsndir = fs->lsnfat + fs->spf * bs->bpb.fats;
- fs->lsndta = fs->lsndir + entsec(fs->dirents);
- if (!(sc = cv2(bs->bpb.secs)) && !(sc = cv4(bs->bpb.lsecs)))
- return (EINVAL);
- if (fs->lsndta > sc)
- return (EINVAL);
- if ((fs->xclus = secblk(fs, sc - fs->lsndta) + 1) < LOCLUS)
- return (EINVAL);
- fs->fatsz = fs->dirents ? fs->xclus < 0xff6 ? 12 : 16 : 32;
- sc = (secbyt(fs->spf) << 1) / (fs->fatsz >> 2) - 1;
- if (fs->xclus > sc)
- fs->xclus = sc;
- return (0);
+ uint_t sc;
+
+ if ((bs->jmp[0] != 0x69 &&
+ bs->jmp[0] != 0xe9 &&
+ (bs->jmp[0] != 0xeb || bs->jmp[2] != 0x90)) ||
+ bs->bpb.media < 0xf0)
+ return (EINVAL);
+ if (cv2(bs->bpb.secsiz) != SECSIZ)
+ return (EINVAL);
+ if (!(fs->spc = bs->bpb.spc) || fs->spc & (fs->spc - 1))
+ return (EINVAL);
+ fs->bsize = secbyt(fs->spc);
+ fs->bshift = ffs(fs->bsize) - 1;
+ if ((fs->spf = cv2(bs->bpb.spf))) {
+ if (bs->bpb.fats != 2)
+ return (EINVAL);
+ if (!(fs->dirents = cv2(bs->bpb.dirents)))
+ return (EINVAL);
+ } else {
+ if (!(fs->spf = cv4(bs->bpb.lspf)))
+ return (EINVAL);
+ if (!bs->bpb.fats || bs->bpb.fats > 16)
+ return (EINVAL);
+ if ((fs->rdcl = cv4(bs->bpb.rdcl)) < LOCLUS)
+ return (EINVAL);
+ }
+ if (!(fs->lsnfat = cv2(bs->bpb.ressec)))
+ return (EINVAL);
+ fs->lsndir = fs->lsnfat + fs->spf * bs->bpb.fats;
+ fs->lsndta = fs->lsndir + entsec(fs->dirents);
+ if (!(sc = cv2(bs->bpb.secs)) && !(sc = cv4(bs->bpb.lsecs)))
+ return (EINVAL);
+ if (fs->lsndta > sc)
+ return (EINVAL);
+ if ((fs->xclus = secblk(fs, sc - fs->lsndta) + 1) < LOCLUS)
+ return (EINVAL);
+ fs->fatsz = fs->dirents ? fs->xclus < 0xff6 ? 12 : 16 : 32;
+ sc = (secbyt(fs->spf) << 1) / (fs->fatsz >> 2) - 1;
+ if (fs->xclus > sc)
+ fs->xclus = sc;
+ return (0);
}
/*
@@ -546,169 +547,180 @@ parsebs(DOS_FS *fs, DOS_BS *bs)
static int
namede(DOS_FS *fs, const char *path, DOS_DE **dep)
{
- char name[256];
- DOS_DE *de;
- char *s;
- size_t n;
- int err;
-
- err = 0;
- de = &fs->root;
- while (*path) {
- while (*path == '/')
- path++;
- if (*path == '\0')
- break;
- if (!(s = strchr(path, '/')))
- s = strchr(path, 0);
- if ((n = s - path) > 255)
- return (ENAMETOOLONG);
- memcpy(name, path, n);
- name[n] = 0;
- path = s;
- if (!(de->attr & FA_DIR))
- return (ENOTDIR);
- if ((err = lookup(fs, stclus(fs->fatsz, de), name, &de)))
- return (err);
- }
- *dep = de;
- return (0);
+ char name[256];
+ DOS_DE *de;
+ char *s;
+ size_t n;
+ int err;
+
+ err = 0;
+ de = &fs->root;
+ while (*path) {
+ while (*path == '/')
+ path++;
+ if (*path == '\0')
+ break;
+ if (!(s = strchr(path, '/')))
+ s = strchr(path, 0);
+ if ((n = s - path) > 255)
+ return (ENAMETOOLONG);
+ memcpy(name, path, n);
+ name[n] = 0;
+ path = s;
+ if (!(de->attr & FA_DIR))
+ return (ENOTDIR);
+ if ((err = lookup(fs, stclus(fs->fatsz, de), name, &de)))
+ return (err);
+ }
+ *dep = de;
+ return (0);
}
/*
* Lookup path segment
*/
static int
-lookup(DOS_FS *fs, u_int clus, const char *name, DOS_DE **dep)
+lookup(DOS_FS *fs, uint_t clus, const char *name, DOS_DE **dep)
{
- static DOS_DIR dir[DEPSEC];
- u_char lfn[261];
- u_char sfn[13];
- u_int nsec, lsec, xdn, chk, sec, ent, x;
- int err, ok;
-
- if (!clus)
- for (ent = 0; ent < 2; ent++)
- if (!strcasecmp(name, dotstr[ent])) {
- *dep = dot + ent;
- return (0);
- }
- if (!clus && fs->fatsz == 32)
- clus = fs->rdcl;
- nsec = !clus ? entsec(fs->dirents) : fs->spc;
- lsec = 0;
- xdn = chk = 0;
- for (;;) {
- if (!clus && !lsec)
- lsec = fs->lsndir;
- else if (okclus(fs, clus))
- lsec = blklsn(fs, clus);
- else
- return (EINVAL);
- for (sec = 0; sec < nsec; sec++) {
- if ((err = ioget(fs->fd, lsec + sec, dir, secbyt(1))))
- return (err);
- for (ent = 0; ent < DEPSEC; ent++) {
- if (!*dir[ent].de.name)
- return (ENOENT);
- if (*dir[ent].de.name != 0xe5) {
- if ((dir[ent].de.attr & FA_MASK) == FA_XDE) {
- x = dir[ent].xde.seq;
- if (x & 0x40 || (x + 1 == xdn &&
- dir[ent].xde.chk == chk)) {
- if (x & 0x40) {
- chk = dir[ent].xde.chk;
- x &= ~0x40;
- }
- if (x >= 1 && x <= 20) {
- cp_xdnm(lfn, &dir[ent].xde);
- xdn = x;
- continue;
- }
- }
- } else if (!(dir[ent].de.attr & FA_LABEL)) {
- if ((ok = xdn == 1)) {
- x = dos_checksum(dir[ent].de.name, dir[ent].de.ext);
- ok = chk == x &&
- !strcasecmp(name, (const char *)lfn);
- }
- if (!ok) {
- cp_sfn(sfn, &dir[ent].de);
- ok = !strcasecmp(name, (const char *)sfn);
- }
- if (ok) {
- *dep = &dir[ent].de;
- return (0);
- }
- }
+ static DOS_DIR dir[DEPSEC];
+ uchar_t lfn[261];
+ uchar_t sfn[13];
+ uint_t nsec, lsec, xdn, chk, sec, ent, x;
+ int err, ok;
+
+ if (!clus)
+ for (ent = 0; ent < 2; ent++)
+ if (!strcasecmp(name, dotstr[ent])) {
+ *dep = dot + ent;
+ return (0);
+ }
+ if (!clus && fs->fatsz == 32)
+ clus = fs->rdcl;
+ nsec = !clus ? entsec(fs->dirents) : fs->spc;
+ lsec = 0;
+ xdn = chk = 0;
+ for (;;) {
+ if (!clus && !lsec)
+ lsec = fs->lsndir;
+ else if (okclus(fs, clus))
+ lsec = blklsn(fs, clus);
+ else
+ return (EINVAL);
+
+ for (sec = 0; sec < nsec; sec++) {
+ if ((err = ioget(fs->fd, lsec + sec, dir, secbyt(1))))
+ return (err);
+ for (ent = 0; ent < DEPSEC; ent++) {
+ if (dir[ent].de.name[0] == 0)
+ return (ENOENT);
+ if (dir[ent].de.name[0] == 0xe5) {
+ xdn = 0;
+ continue;
+ }
+ if ((dir[ent].de.attr & FA_MASK) == FA_XDE) {
+ x = dir[ent].xde.seq;
+ if (x & 0x40 ||
+ (x + 1 == xdn &&
+ dir[ent].xde.chk == chk)) {
+ if (x & 0x40) {
+ chk = dir[ent].xde.chk;
+ x &= ~0x40;
+ }
+ if (x >= 1 && x <= 20) {
+ cp_xdnm(lfn,
+ &dir[ent].xde);
+ xdn = x;
+ continue;
+ }
+ }
+ } else if (!(dir[ent].de.attr & FA_LABEL)) {
+ if ((ok = xdn == 1)) {
+ x = dos_checksum(
+ dir[ent].de.name,
+ dir[ent].de.ext);
+ ok = chk == x &&
+ !strcasecmp(name,
+ (const char *)lfn);
+ }
+ if (!ok) {
+ cp_sfn(sfn, &dir[ent].de);
+ ok = !strcasecmp(name,
+ (const char *)sfn);
+ }
+ if (ok) {
+ *dep = &dir[ent].de;
+ return (0);
+ }
+ }
+ xdn = 0;
+ }
}
- xdn = 0;
- }
- }
- if (!clus)
- break;
- if ((err = fatget(fs, &clus)))
- return (err);
- if (fatend(fs->fatsz, clus))
- break;
- }
- return (ENOENT);
+ if (!clus)
+ break;
+ if ((err = fatget(fs, &clus)))
+ return (err);
+ if (fatend(fs->fatsz, clus))
+ break;
+ }
+ return (ENOENT);
}
/*
* Copy name from extended directory entry
*/
static void
-cp_xdnm(u_char *lfn, DOS_XDE *xde)
+cp_xdnm(uchar_t *lfn, DOS_XDE *xde)
{
- static struct {
- u_int off;
- u_int dim;
- } ix[3] = {
- {offsetof(DOS_XDE, name1), sizeof(xde->name1) / 2},
- {offsetof(DOS_XDE, name2), sizeof(xde->name2) / 2},
- {offsetof(DOS_XDE, name3), sizeof(xde->name3) / 2}
- };
- u_char *p;
- u_int n, x, c;
-
- lfn += 13 * ((xde->seq & ~0x40) - 1);
- for (n = 0; n < 3; n++)
- for (p = (u_char *)xde + ix[n].off, x = ix[n].dim; x;
- p += 2, x--) {
- if ((c = cv2(p)) && (c < 32 || c > 127))
- c = '?';
- if (!(*lfn++ = c))
- return;
- }
- if (xde->seq & 0x40)
- *lfn = 0;
+ static struct {
+ uint_t off;
+ uint_t dim;
+ } ix[3] = {
+ { offsetof(DOS_XDE, name1), sizeof (xde->name1) / 2},
+ { offsetof(DOS_XDE, name2), sizeof (xde->name2) / 2},
+ { offsetof(DOS_XDE, name3), sizeof (xde->name3) / 2}
+ };
+ uchar_t *p;
+ uint_t n, x, c;
+
+ lfn += 13 * ((xde->seq & ~0x40) - 1);
+ for (n = 0; n < 3; n++)
+ for (p = (uchar_t *)xde + ix[n].off, x = ix[n].dim; x;
+ p += 2, x--) {
+ if ((c = cv2(p)) && (c < 32 || c > 127))
+ c = '?';
+ if (!(*lfn++ = c))
+ return;
+ }
+ if (xde->seq & 0x40)
+ *lfn = 0;
}
/*
* Copy short filename
*/
static void
-cp_sfn(u_char *sfn, DOS_DE *de)
+cp_sfn(uchar_t *sfn, DOS_DE *de)
{
- u_char *p;
- int j, i;
-
- p = sfn;
- if (*de->name != ' ') {
- for (j = 7; de->name[j] == ' '; j--);
- for (i = 0; i <= j; i++)
- *p++ = de->name[i];
- if (*de->ext != ' ') {
- *p++ = '.';
- for (j = 2; de->ext[j] == ' '; j--);
- for (i = 0; i <= j; i++)
- *p++ = de->ext[i];
- }
- }
- *p = 0;
- if (*sfn == 5)
- *sfn = 0xe5;
+ uchar_t *p;
+ int j, i;
+
+ p = sfn;
+ if (*de->name != ' ') {
+ for (j = 7; de->name[j] == ' '; j--)
+ ;
+ for (i = 0; i <= j; i++)
+ *p++ = de->name[i];
+ if (*de->ext != ' ') {
+ *p++ = '.';
+ for (j = 2; de->ext[j] == ' '; j--)
+ ;
+ for (i = 0; i <= j; i++)
+ *p++ = de->ext[i];
+ }
+ }
+ *p = '\0';
+ if (*sfn == 5)
+ *sfn = 0xe5;
}
/*
@@ -717,34 +729,34 @@ cp_sfn(u_char *sfn, DOS_DE *de)
static off_t
fsize(DOS_FS *fs, DOS_DE *de)
{
- u_long size;
- u_int c;
- int n;
-
- if (!(size = cv4(de->size)) && de->attr & FA_DIR) {
- if (!(c = cv2(de->clus)))
- size = fs->dirents * sizeof(DOS_DE);
- else {
- if ((n = fatcnt(fs, c)) == -1)
- return (n);
- size = blkbyt(fs, n);
- }
- }
- return (size);
+ ulong_t size;
+ uint_t c;
+ int n;
+
+ if (!(size = cv4(de->size)) && de->attr & FA_DIR) {
+ if (!(c = cv2(de->clus)))
+ size = fs->dirents * sizeof (DOS_DE);
+ else {
+ if ((n = fatcnt(fs, c)) == -1)
+ return (n);
+ size = blkbyt(fs, n);
+ }
+ }
+ return (size);
}
/*
* Count number of clusters in chain
*/
static int
-fatcnt(DOS_FS *fs, u_int c)
+fatcnt(DOS_FS *fs, uint_t c)
{
- int n;
+ int n;
- for (n = 0; okclus(fs, c); n++)
- if (fatget(fs, &c))
- return (-1);
- return (fatend(fs->fatsz, c) ? n : -1);
+ for (n = 0; okclus(fs, c); n++)
+ if (fatget(fs, &c))
+ return (-1);
+ return (fatend(fs->fatsz, c) ? n : -1);
}
/*
@@ -752,101 +764,105 @@ fatcnt(DOS_FS *fs, u_int c)
* the number of current 128K block in FAT has changed.
*/
static int
-fatget(DOS_FS *fs, u_int *c)
+fatget(DOS_FS *fs, uint_t *c)
{
- u_int val_in, val_out, offset, blknum, nbyte;
- const u_char *p_entry;
- int err;
-
- /* check input value to prevent overflow in fatoff() */
- val_in = *c;
- if (val_in & 0xf0000000)
- return (EINVAL);
-
- /* ensure that current 128K FAT block is cached */
- offset = fatoff(fs->fatsz, val_in);
- nbyte = fs->fatsz != 32 ? 2 : 4;
- if (offset + nbyte > secbyt(fs->spf))
- return (EINVAL);
- blknum = offset / FATBLKSZ;
- offset %= FATBLKSZ;
- if (offset + nbyte > FATBLKSZ)
- return (EINVAL);
- if (blknum != fs->fatbuf_blknum) {
- err = dos_read_fatblk(fs, fs->fd, blknum);
- if (err != 0)
- return (err);
- }
- p_entry = fs->fatbuf + offset;
-
- /* extract cluster number from FAT entry */
- switch (fs->fatsz) {
- case 32:
- val_out = cv4(p_entry);
- val_out &= 0x0fffffff;
- break;
- case 16:
- val_out = cv2(p_entry);
- break;
- case 12:
- val_out = cv2(p_entry);
- if (val_in & 1)
- val_out >>= 4;
- else
- val_out &= 0xfff;
- break;
- default:
- return (EINVAL);
- }
- *c = val_out;
- return (0);
+ uint_t val_in, val_out, offset, blknum, nbyte;
+ const uchar_t *p_entry;
+ int err;
+
+ /* check input value to prevent overflow in fatoff() */
+ val_in = *c;
+ if (val_in & 0xf0000000)
+ return (EINVAL);
+
+ /* ensure that current 128K FAT block is cached */
+ offset = fatoff(fs->fatsz, val_in);
+ nbyte = fs->fatsz != 32 ? 2 : 4;
+ if (offset + nbyte > secbyt(fs->spf))
+ return (EINVAL);
+ blknum = offset / FATBLKSZ;
+ offset %= FATBLKSZ;
+ if (offset + nbyte > FATBLKSZ)
+ return (EINVAL);
+ if (blknum != fs->fatbuf_blknum) {
+ err = dos_read_fatblk(fs, fs->fd, blknum);
+ if (err != 0)
+ return (err);
+ }
+ p_entry = fs->fatbuf + offset;
+
+ /* extract cluster number from FAT entry */
+ switch (fs->fatsz) {
+ case 32:
+ val_out = cv4(p_entry);
+ val_out &= 0x0fffffff;
+ break;
+ case 16:
+ val_out = cv2(p_entry);
+ break;
+ case 12:
+ val_out = cv2(p_entry);
+ if (val_in & 1)
+ val_out >>= 4;
+ else
+ val_out &= 0xfff;
+ break;
+ default:
+ return (EINVAL);
+ }
+ *c = val_out;
+ return (0);
}
/*
* Is cluster an end-of-chain marker?
*/
static int
-fatend(u_int sz, u_int c)
+fatend(uint_t sz, uint_t c)
{
- return (c > (sz == 12 ? 0xff7U : sz == 16 ? 0xfff7U : 0xffffff7));
+ return (c > (sz == 12 ? 0xff7U : sz == 16 ? 0xfff7U : 0xffffff7));
}
/*
* Offset-based I/O primitive
*/
static int
-ioread(DOS_FS *fs, u_int offset, void *buf, size_t nbyte)
+ioread(DOS_FS *fs, uint_t offset, void *buf, size_t nbyte)
{
- char *s;
- u_int off, n;
- int err;
- u_char local_buf[SECSIZ];
-
- s = buf;
- if ((off = offset & (SECSIZ - 1))) {
- offset -= off;
- if ((n = SECSIZ - off) > nbyte)
- n = nbyte;
- if ((err = ioget(fs->fd, bytsec(offset), local_buf, sizeof(local_buf))))
- return (err);
- memcpy(s, local_buf + off, n);
- offset += SECSIZ;
- s += n;
- nbyte -= n;
- }
- n = nbyte & (SECSIZ - 1);
- if (nbyte -= n) {
- if ((err = ioget(fs->fd, bytsec(offset), s, nbyte)))
- return (err);
- offset += nbyte;
- s += nbyte;
- }
- if (n) {
- if ((err = ioget(fs->fd, bytsec(offset), local_buf, sizeof(local_buf))))
- return (err);
- memcpy(s, local_buf, n);
- }
- return (0);
+ char *s;
+ uint_t off, n;
+ int err;
+ uchar_t local_buf[SECSIZ];
+
+ s = buf;
+ if ((off = offset & (SECSIZ - 1))) {
+ offset -= off;
+ if ((n = SECSIZ - off) > nbyte)
+ n = nbyte;
+ err = ioget(fs->fd, bytsec(offset), local_buf,
+ sizeof (local_buf));
+ if (err != 0)
+ return (err);
+ memcpy(s, local_buf + off, n);
+ offset += SECSIZ;
+ s += n;
+ nbyte -= n;
+ }
+ n = nbyte & (SECSIZ - 1);
+ if (nbyte -= n) {
+ if ((err = ioget(fs->fd, bytsec(offset), s, nbyte)))
+ return (err);
+ offset += nbyte;
+ s += nbyte;
+ }
+ if (n != 0) {
+ err = ioget(fs->fd, bytsec(offset), local_buf,
+ sizeof (local_buf));
+ if (err != 0)
+ return (err);
+ memcpy(s, local_buf, n);
+ }
+ return (0);
}
/*
@@ -855,14 +871,14 @@ ioread(DOS_FS *fs, u_int offset, void *buf, size_t nbyte)
static int
ioget(struct open_file *fd, daddr_t lsec, void *buf, size_t size)
{
- size_t rsize;
- int rv;
-
- /* Make sure we get full read or error. */
- rsize = 0;
- rv = (fd->f_dev->dv_strategy)(fd->f_devdata, F_READ, lsec,
- size, buf, &rsize);
- if ((rv == 0) && (size != rsize))
- rv = EIO;
- return (rv);
+ size_t rsize;
+ int rv;
+
+ /* Make sure we get full read or error. */
+ rsize = 0;
+ rv = (fd->f_dev->dv_strategy)(fd->f_devdata, F_READ, lsec,
+ size, buf, &rsize);
+ if ((rv == 0) && (size != rsize))
+ rv = EIO;
+ return (rv);
}
diff --git a/usr/src/boot/lib/libstand/gzipfs.c b/usr/src/boot/lib/libstand/gzipfs.c
index a658f90755..c6c7b206e6 100644
--- a/usr/src/boot/lib/libstand/gzipfs.c
+++ b/usr/src/boot/lib/libstand/gzipfs.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 1998 Michael Smith.
* All rights reserved.
*
@@ -32,57 +32,58 @@
#include <string.h>
#include <zlib.h>
-#define Z_BUFSIZE 2048 /* XXX larger? */
+#define Z_BUFSIZE 2048 /* XXX larger? */
struct z_file
{
- int zf_rawfd;
- off_t zf_dataoffset;
- z_stream zf_zstream;
- unsigned char zf_buf[Z_BUFSIZE];
- int zf_endseen;
+ int zf_rawfd;
+ off_t zf_dataoffset;
+ z_stream zf_zstream;
+ unsigned char zf_buf[Z_BUFSIZE];
+ int zf_endseen;
};
-static int zf_fill(struct z_file *z);
-static int zf_open(const char *path, struct open_file *f);
-static int zf_close(struct open_file *f);
-static int zf_read(struct open_file *f, void *buf, size_t size, size_t *resid);
-static off_t zf_seek(struct open_file *f, off_t offset, int where);
-static int zf_stat(struct open_file *f, struct stat *sb);
+static int zf_fill(struct z_file *z);
+static int zf_open(const char *path, struct open_file *f);
+static int zf_close(struct open_file *f);
+static int zf_read(struct open_file *f, void *buf, size_t size, size_t *resid);
+static off_t zf_seek(struct open_file *f, off_t offset, int where);
+static int zf_stat(struct open_file *f, struct stat *sb);
struct fs_ops gzipfs_fsops = {
- "zip",
- zf_open,
- zf_close,
- zf_read,
- null_write,
- zf_seek,
- zf_stat,
- null_readdir
+ .fs_name = "zip",
+ .fo_open = zf_open,
+ .fo_close = zf_close,
+ .fo_read = zf_read,
+ .fo_write = null_write,
+ .fo_seek = zf_seek,
+ .fo_stat = zf_stat,
+ .fo_readdir = null_readdir
};
static int
zf_fill(struct z_file *zf)
{
- int result;
- int req;
-
- req = Z_BUFSIZE - zf->zf_zstream.avail_in;
- result = 0;
-
- /* If we need more */
- if (req > 0) {
- /* move old data to bottom of buffer */
- if (req < Z_BUFSIZE)
- bcopy(zf->zf_buf + req, zf->zf_buf, Z_BUFSIZE - req);
-
- /* read to fill buffer and update availibility data */
- result = read(zf->zf_rawfd, zf->zf_buf + zf->zf_zstream.avail_in, req);
- zf->zf_zstream.next_in = zf->zf_buf;
- if (result >= 0)
- zf->zf_zstream.avail_in += result;
- }
- return(result);
+ int result;
+ int req;
+
+ req = Z_BUFSIZE - zf->zf_zstream.avail_in;
+ result = 0;
+
+ /* If we need more */
+ if (req > 0) {
+ /* move old data to bottom of buffer */
+ if (req < Z_BUFSIZE)
+ bcopy(zf->zf_buf + req, zf->zf_buf, Z_BUFSIZE - req);
+
+ /* read to fill buffer and update availibility data */
+ result = read(zf->zf_rawfd,
+ zf->zf_buf + zf->zf_zstream.avail_in, req);
+ zf->zf_zstream.next_in = zf->zf_buf;
+ if (result >= 0)
+ zf->zf_zstream.avail_in += result;
+ }
+ return (result);
}
/*
@@ -93,257 +94,264 @@ zf_fill(struct z_file *zf)
static int
get_byte(struct z_file *zf, off_t *curoffp)
{
- if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1))
- return(-1);
- zf->zf_zstream.avail_in--;
- ++*curoffp;
- return(*(zf->zf_zstream.next_in)++);
+ if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1))
+ return (-1);
+ zf->zf_zstream.avail_in--;
+ ++*curoffp;
+ return (*(zf->zf_zstream.next_in)++);
}
static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define RESERVED 0xE0 /* bits 5..7: reserved */
+#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
+#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
+#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
+#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
+#define COMMENT 0x10 /* bit 4 set: file comment present */
+#define RESERVED 0xE0 /* bits 5..7: reserved */
static int
check_header(struct z_file *zf)
{
- int method; /* method byte */
- int flags; /* flags byte */
- uInt len;
- int c;
-
- zf->zf_dataoffset = 0;
- /* Check the gzip magic header */
- for (len = 0; len < 2; len++) {
- c = get_byte(zf, &zf->zf_dataoffset);
- if (c != gz_magic[len]) {
- return(1);
+ int method; /* method byte */
+ int flags; /* flags byte */
+ uInt len;
+ int c;
+
+ zf->zf_dataoffset = 0;
+ /* Check the gzip magic header */
+ for (len = 0; len < 2; len++) {
+ c = get_byte(zf, &zf->zf_dataoffset);
+ if (c != gz_magic[len]) {
+ return (1);
+ }
+ }
+ method = get_byte(zf, &zf->zf_dataoffset);
+ flags = get_byte(zf, &zf->zf_dataoffset);
+ if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
+ return (1);
+ }
+
+ /* Discard time, xflags and OS code: */
+ for (len = 0; len < 6; len++)
+ (void) get_byte(zf, &zf->zf_dataoffset);
+
+ if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
+ len = (uInt)get_byte(zf, &zf->zf_dataoffset);
+ len += ((uInt)get_byte(zf, &zf->zf_dataoffset))<<8;
+ /* len is garbage if EOF but the loop below will quit anyway */
+ while (len-- != 0 && get_byte(zf, &zf->zf_dataoffset) != -1)
+ ;
+ }
+ if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
+ while ((c = get_byte(zf, &zf->zf_dataoffset)) != 0 && c != -1)
+ ;
+ }
+ if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
+ while ((c = get_byte(zf, &zf->zf_dataoffset)) != 0 && c != -1)
+ ;
}
- }
- method = get_byte(zf, &zf->zf_dataoffset);
- flags = get_byte(zf, &zf->zf_dataoffset);
- if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- return(1);
- }
-
- /* Discard time, xflags and OS code: */
- for (len = 0; len < 6; len++) (void)get_byte(zf, &zf->zf_dataoffset);
-
- if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
- len = (uInt)get_byte(zf, &zf->zf_dataoffset);
- len += ((uInt)get_byte(zf, &zf->zf_dataoffset))<<8;
- /* len is garbage if EOF but the loop below will quit anyway */
- while (len-- != 0 && get_byte(zf, &zf->zf_dataoffset) != -1) ;
- }
- if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
- while ((c = get_byte(zf, &zf->zf_dataoffset)) != 0 && c != -1) ;
- }
- if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
- while ((c = get_byte(zf, &zf->zf_dataoffset)) != 0 && c != -1) ;
- }
- if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
- for (len = 0; len < 2; len++) c = get_byte(zf, &zf->zf_dataoffset);
- }
- /* if there's data left, we're in business */
- return((c == -1) ? 1 : 0);
+ if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
+ for (len = 0; len < 2; len++)
+ c = get_byte(zf, &zf->zf_dataoffset);
+ }
+ /* if there's data left, we're in business */
+ return ((c == -1) ? 1 : 0);
}
-
+
static int
zf_open(const char *fname, struct open_file *f)
{
- char *zfname;
- int rawfd;
- struct z_file *zf;
- char *cp;
- int error;
- struct stat sb;
-
- /* Have to be in "just read it" mode */
- if (f->f_flags != F_READ)
- return(EPERM);
-
- /* If the name already ends in .gz or .bz2, ignore it */
- if ((cp = strrchr(fname, '.')) && (!strcmp(cp, ".gz")
- || !strcmp(cp, ".bz2") || !strcmp(cp, ".split")))
- return(ENOENT);
-
- /* Try to open the compressed datafile */
- rawfd = open(fname, O_RDONLY | F_GZIP);
- if (rawfd == -1) {
- /* add .gz sufix and try again */
- zfname = malloc(strlen(fname) + 4);
- if (zfname == NULL)
- return(ENOMEM);
- sprintf(zfname, "%s.gz", fname);
- rawfd = open(zfname, O_RDONLY);
- free(zfname);
- if (rawfd == -1)
- return(ENOENT);
- }
-
- if (fstat(rawfd, &sb) < 0) {
- printf("zf_open: stat failed\n");
- close(rawfd);
- return(ENOENT);
- }
- if (!S_ISREG(sb.st_mode)) {
- close(rawfd);
- return(EISDIR); /* best guess */
- }
-
- /* Allocate a z_file structure, populate it */
- zf = malloc(sizeof(struct z_file));
- if (zf == NULL)
- return(ENOMEM);
- bzero(zf, sizeof(struct z_file));
- zf->zf_rawfd = rawfd;
-
- /* Verify that the file is gzipped */
- if (check_header(zf)) {
- close(zf->zf_rawfd);
- free(zf);
- return(EFTYPE);
- }
+ char *zfname;
+ int rawfd;
+ struct z_file *zf;
+ char *cp;
+ int error;
+ struct stat sb;
+
+ /* Have to be in "just read it" mode */
+ if (f->f_flags != F_READ)
+ return (EPERM);
+
+ /* If the name already ends in .gz or .bz2, ignore it */
+ if ((cp = strrchr(fname, '.')) && (strcmp(cp, ".gz") == 0 ||
+ strcmp(cp, ".bz2") == 0 || strcmp(cp, ".split") == 0))
+ return (ENOENT);
+
+ /* Try to open the compressed datafile */
+ rawfd = open(fname, O_RDONLY | F_GZIP);
+ if (rawfd == -1) {
+ /* add .gz sufix and try again */
+ zfname = malloc(strlen(fname) + 4);
+ if (zfname == NULL)
+ return (ENOMEM);
+ sprintf(zfname, "%s.gz", fname);
+ rawfd = open(zfname, O_RDONLY);
+ free(zfname);
+ if (rawfd == -1)
+ return (ENOENT);
+ }
- /* Initialise the inflation engine */
- if ((error = inflateInit2(&(zf->zf_zstream), -15)) != Z_OK) {
- printf("zf_open: inflateInit returned %d : %s\n", error, zf->zf_zstream.msg);
- close(zf->zf_rawfd);
- free(zf);
- return(EIO);
- }
+ if (fstat(rawfd, &sb) < 0) {
+ printf("zf_open: stat failed\n");
+ close(rawfd);
+ return (ENOENT);
+ }
+ if (!S_ISREG(sb.st_mode)) {
+ close(rawfd);
+ return (EISDIR); /* best guess */
+ }
+
+ /* Allocate a z_file structure, populate it */
+ zf = malloc(sizeof (struct z_file));
+ if (zf == NULL)
+ return (ENOMEM);
+ bzero(zf, sizeof (struct z_file));
+ zf->zf_rawfd = rawfd;
+
+ /* Verify that the file is gzipped */
+ if (check_header(zf)) {
+ close(zf->zf_rawfd);
+ free(zf);
+ return (EFTYPE);
+ }
- /* Looks OK, we'll take it */
- f->f_fsdata = zf;
- return(0);
+ /* Initialise the inflation engine */
+ if ((error = inflateInit2(&(zf->zf_zstream), -15)) != Z_OK) {
+ printf("zf_open: inflateInit returned %d : %s\n", error,
+ zf->zf_zstream.msg);
+ close(zf->zf_rawfd);
+ free(zf);
+ return (EIO);
+ }
+
+ /* Looks OK, we'll take it */
+ f->f_fsdata = zf;
+ return (0);
}
static int
zf_close(struct open_file *f)
{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
-
- inflateEnd(&(zf->zf_zstream));
- close(zf->zf_rawfd);
- free(zf);
- return(0);
+ struct z_file *zf = (struct z_file *)f->f_fsdata;
+
+ inflateEnd(&(zf->zf_zstream));
+ close(zf->zf_rawfd);
+ free(zf);
+ return (0);
}
-
-static int
+
+static int
zf_read(struct open_file *f, void *buf, size_t size, size_t *resid)
{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
- int error;
-
- zf->zf_zstream.next_out = buf; /* where and how much */
- zf->zf_zstream.avail_out = size;
-
- while (zf->zf_zstream.avail_out && zf->zf_endseen == 0) {
- if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) {
- printf("zf_read: fill error\n");
- return(EIO);
+ struct z_file *zf = (struct z_file *)f->f_fsdata;
+ int error;
+
+ zf->zf_zstream.next_out = buf; /* where and how much */
+ zf->zf_zstream.avail_out = size;
+
+ while (zf->zf_zstream.avail_out && zf->zf_endseen == 0) {
+ if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) {
+ printf("zf_read: fill error\n");
+ return (EIO);
+ }
+ if (zf->zf_zstream.avail_in == 0) { /* oops, unexpected EOF */
+ printf("zf_read: unexpected EOF\n");
+ if (zf->zf_zstream.avail_out == size)
+ return (EIO);
+ break;
+ }
+
+ /* decompression pass */
+ error = inflate(&zf->zf_zstream, Z_SYNC_FLUSH);
+ if (error == Z_STREAM_END) { /* EOF, all done */
+ zf->zf_endseen = 1;
+ break;
+ }
+ if (error != Z_OK) { /* argh, decompression error */
+ printf("inflate: %s\n", zf->zf_zstream.msg);
+ return (EIO);
+ }
}
- if (zf->zf_zstream.avail_in == 0) { /* oops, unexpected EOF */
- printf("zf_read: unexpected EOF\n");
- if (zf->zf_zstream.avail_out == size)
- return(EIO);
- break;
- }
-
- error = inflate(&zf->zf_zstream, Z_SYNC_FLUSH); /* decompression pass */
- if (error == Z_STREAM_END) { /* EOF, all done */
- zf->zf_endseen = 1;
- break;
- }
- if (error != Z_OK) { /* argh, decompression error */
- printf("inflate: %s\n", zf->zf_zstream.msg);
- return(EIO);
- }
- }
- if (resid != NULL)
- *resid = zf->zf_zstream.avail_out;
- return(0);
+ if (resid != NULL)
+ *resid = zf->zf_zstream.avail_out;
+ return (0);
}
static int
zf_rewind(struct open_file *f)
{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
+ struct z_file *zf = (struct z_file *)f->f_fsdata;
- if (lseek(zf->zf_rawfd, zf->zf_dataoffset, SEEK_SET) == -1)
- return(-1);
- zf->zf_zstream.avail_in = 0;
- zf->zf_zstream.next_in = NULL;
- zf->zf_endseen = 0;
- (void)inflateReset(&zf->zf_zstream);
+ if (lseek(zf->zf_rawfd, zf->zf_dataoffset, SEEK_SET) == -1)
+ return (-1);
+ zf->zf_zstream.avail_in = 0;
+ zf->zf_zstream.next_in = NULL;
+ zf->zf_endseen = 0;
+ (void) inflateReset(&zf->zf_zstream);
- return(0);
+ return (0);
}
static off_t
zf_seek(struct open_file *f, off_t offset, int where)
{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
- off_t target;
- char discard[16];
-
- switch (where) {
- case SEEK_SET:
- target = offset;
- break;
- case SEEK_CUR:
- target = offset + zf->zf_zstream.total_out;
- break;
- default:
- errno = EINVAL;
- return(-1);
- }
-
- /* rewind if required */
- if (target < zf->zf_zstream.total_out && zf_rewind(f) != 0)
- return(-1);
-
- /* skip forwards if required */
- while (target > zf->zf_zstream.total_out) {
- errno = zf_read(f, discard, min(sizeof(discard),
- target - zf->zf_zstream.total_out), NULL);
- if (errno)
- return(-1);
- }
- /* This is where we are (be honest if we overshot) */
- return(zf->zf_zstream.total_out);
+ struct z_file *zf = (struct z_file *)f->f_fsdata;
+ off_t target;
+ char discard[16];
+
+ switch (where) {
+ case SEEK_SET:
+ target = offset;
+ break;
+ case SEEK_CUR:
+ target = offset + zf->zf_zstream.total_out;
+ break;
+ default:
+ errno = EINVAL;
+ return (-1);
+ }
+
+ /* rewind if required */
+ if (target < zf->zf_zstream.total_out && zf_rewind(f) != 0)
+ return (-1);
+
+ /* skip forwards if required */
+ while (target > zf->zf_zstream.total_out) {
+ errno = zf_read(f, discard, min(sizeof (discard),
+ target - zf->zf_zstream.total_out), NULL);
+ if (errno != 0)
+ return (-1);
+ }
+ /* This is where we are (be honest if we overshot) */
+ return (zf->zf_zstream.total_out);
}
static int
zf_stat(struct open_file *f, struct stat *sb)
{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
- int result;
- off_t pos1, pos2;
- uint32_t size;
-
- /* stat as normal, but indicate that size is unknown */
- if ((result = fstat(zf->zf_rawfd, sb)) == 0) {
- if (sb->st_size == -1)
- return (result);
- pos1 = lseek(zf->zf_rawfd, 0, SEEK_CUR);
- pos2 = lseek(zf->zf_rawfd, sb->st_size - 4, SEEK_SET);
- if (pos2 != -1) {
- if (read(zf->zf_rawfd, &size, 4) == 4)
- sb->st_size = (off_t) size;
- else
- sb->st_size = -1;
- } else
- sb->st_size = -1;
-
- pos1 = lseek(zf->zf_rawfd, pos1, SEEK_SET);
- }
- return(result);
+ struct z_file *zf = (struct z_file *)f->f_fsdata;
+ int result;
+ off_t pos1, pos2;
+ uint32_t size;
+
+ /* stat as normal, but indicate that size is unknown */
+ if ((result = fstat(zf->zf_rawfd, sb)) == 0) {
+ if (sb->st_size == -1)
+ return (result);
+ pos1 = lseek(zf->zf_rawfd, 0, SEEK_CUR);
+ pos2 = lseek(zf->zf_rawfd, sb->st_size - 4, SEEK_SET);
+ if (pos2 != -1) {
+ if (read(zf->zf_rawfd, &size, 4) == 4)
+ sb->st_size = (off_t)size;
+ else
+ sb->st_size = -1;
+ } else
+ sb->st_size = -1;
+
+ pos1 = lseek(zf->zf_rawfd, pos1, SEEK_SET);
+ }
+ return (result);
}
diff --git a/usr/src/boot/lib/libstand/netif.c b/usr/src/boot/lib/libstand/netif.c
index 51bc5aa125..8f46a29668 100644
--- a/usr/src/boot/lib/libstand/netif.c
+++ b/usr/src/boot/lib/libstand/netif.c
@@ -62,7 +62,7 @@ netif_init(void)
{
struct netif_driver *drv;
int d, i;
-
+
#ifdef NETIF_DEBUG
if (netif_debug)
printf("netif_init: called\n");
@@ -84,7 +84,7 @@ netif_match(struct netif *nif, void *machdep_hint)
printf("%s%d: netif_match (%d)\n", drv->netif_bname,
nif->nif_unit, nif->nif_sel);
#endif
- return drv->netif_match(nif, machdep_hint);
+ return (drv->netif_match(nif, machdep_hint));
}
struct netif *
@@ -141,7 +141,7 @@ netif_select(void *machdep_hint)
}
if (best_if.nif_driver == NULL)
- return NULL;
+ return (NULL);
best_if.nif_driver->
netif_ifs[best_if.nif_unit].dif_used |= (1 << best_if.nif_sel);
@@ -149,10 +149,10 @@ netif_select(void *machdep_hint)
#ifdef NETIF_DEBUG
if (netif_debug)
printf("netif_select: %s%d(%d) wins\n",
- best_if.nif_driver->netif_bname,
- best_if.nif_unit, best_if.nif_sel);
+ best_if.nif_driver->netif_bname,
+ best_if.nif_unit, best_if.nif_sel);
#endif
- return &best_if;
+ return (&best_if);
}
int
@@ -164,7 +164,7 @@ netif_probe(struct netif *nif, void *machdep_hint)
if (netif_debug)
printf("%s%d: netif_probe\n", drv->netif_bname, nif->nif_unit);
#endif
- return drv->netif_probe(nif, machdep_hint);
+ return (drv->netif_probe(nif, machdep_hint));
}
void
@@ -176,15 +176,15 @@ netif_attach(struct netif *nif, struct iodesc *desc, void *machdep_hint)
if (netif_debug)
printf("%s%d: netif_attach\n", drv->netif_bname, nif->nif_unit);
#endif
- desc->io_netif = nif;
+ desc->io_netif = nif;
#ifdef PARANOID
if (drv->netif_init == NULL)
panic("%s%d: no netif_init support\n", drv->netif_bname,
nif->nif_unit);
#endif
drv->netif_init(desc, machdep_hint);
- bzero(drv->netif_ifs[nif->nif_unit].dif_stats,
- sizeof(struct netif_stats));
+ bzero(drv->netif_ifs[nif->nif_unit].dif_stats,
+ sizeof (struct netif_stats));
}
void
@@ -274,7 +274,7 @@ netif_open(void *machdep_hint)
int fd;
struct iodesc *s;
struct netif *nif;
-
+
/* find a free socket */
for (fd = 0, s = sockets; fd < SOPEN_MAX; fd++, s++)
if (s->io_netif == (struct netif *)0)
@@ -283,10 +283,10 @@ netif_open(void *machdep_hint)
return (-1);
fnd:
- bzero(s, sizeof(*s));
+ bzero(s, sizeof (*s));
netif_init();
nif = netif_select(machdep_hint);
- if (!nif)
+ if (!nif)
panic("netboot: no interfaces left untried");
if (netif_probe(nif, machdep_hint)) {
printf("netboot: couldn't probe %s%d\n",
diff --git a/usr/src/boot/lib/libstand/nfs.c b/usr/src/boot/lib/libstand/nfs.c
index 1ca0547c9d..a31f449da8 100644
--- a/usr/src/boot/lib/libstand/nfs.c
+++ b/usr/src/boot/lib/libstand/nfs.c
@@ -48,10 +48,10 @@
#include "netif.h"
#include "rpc.h"
-#define NFS_DEBUGxx
+#define NFS_DEBUGxx
-#define NFSREAD_MIN_SIZE 1024
-#define NFSREAD_MAX_SIZE 16384
+#define NFSREAD_MIN_SIZE 1024
+#define NFSREAD_MAX_SIZE 16384
/* NFSv3 definitions */
#define NFS_V3MAXFHSIZE 64
@@ -113,7 +113,7 @@ struct nfs_iodesc {
struct iodesc *iodesc;
off_t off;
uint32_t fhsize;
- u_char fh[NFS_V3MAXFHSIZE];
+ uchar_t fh[NFS_V3MAXFHSIZE];
struct nfsv3_fattrs fa; /* all in network order */
uint64_t cookie;
};
@@ -122,24 +122,24 @@ struct nfs_iodesc {
* XXX interactions with tftp? See nfswrapper.c for a confusing
* issue.
*/
-int nfs_open(const char *path, struct open_file *f);
-static int nfs_close(struct open_file *f);
-static int nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
-static off_t nfs_seek(struct open_file *f, off_t offset, int where);
-static int nfs_stat(struct open_file *f, struct stat *sb);
-static int nfs_readdir(struct open_file *f, struct dirent *d);
+int nfs_open(const char *path, struct open_file *f);
+static int nfs_close(struct open_file *f);
+static int nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
+static off_t nfs_seek(struct open_file *f, off_t offset, int where);
+static int nfs_stat(struct open_file *f, struct stat *sb);
+static int nfs_readdir(struct open_file *f, struct dirent *d);
struct nfs_iodesc nfs_root_node;
struct fs_ops nfs_fsops = {
- "nfs",
- nfs_open,
- nfs_close,
- nfs_read,
- null_write,
- nfs_seek,
- nfs_stat,
- nfs_readdir
+ .fs_name = "nfs",
+ .fo_open = nfs_open,
+ .fo_close = nfs_close,
+ .fo_read = nfs_read,
+ .fo_write = null_write,
+ .fo_seek = nfs_seek,
+ .fo_stat = nfs_stat,
+ .fo_readdir = nfs_readdir
};
static int nfs_read_size = NFSREAD_MIN_SIZE;
@@ -181,7 +181,7 @@ set_nfs_read_size(void)
* Return zero or error number.
*/
int
-nfs_getrootfh(struct iodesc *d, char *path, uint32_t *fhlenp, u_char *fhp)
+nfs_getrootfh(struct iodesc *d, char *path, uint32_t *fhlenp, uchar_t *fhp)
{
void *pkt = NULL;
int len;
@@ -192,7 +192,7 @@ nfs_getrootfh(struct iodesc *d, char *path, uint32_t *fhlenp, u_char *fhp)
struct repl {
uint32_t errno;
uint32_t fhsize;
- u_char fh[NFS_V3MAXFHSIZE];
+ uchar_t fh[NFS_V3MAXFHSIZE];
uint32_t authcnt;
uint32_t auth[7];
} *repl;
@@ -209,13 +209,13 @@ nfs_getrootfh(struct iodesc *d, char *path, uint32_t *fhlenp, u_char *fhp)
args = &sdata.d;
- bzero(args, sizeof(*args));
+ bzero(args, sizeof (*args));
len = strlen(path);
- if (len > sizeof(args->path))
- len = sizeof(args->path);
+ if (len > sizeof (args->path))
+ len = sizeof (args->path);
args->len = htonl(len);
bcopy(path, args->path, len);
- len = sizeof(uint32_t) + roundup(len, sizeof(uint32_t));
+ len = sizeof (uint32_t) + roundup(len, sizeof (uint32_t));
cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER3, RPCMNT_MOUNT,
args, len, (void **)&repl, &pkt);
@@ -252,14 +252,14 @@ nfs_lookupfh(struct nfs_iodesc *d, const char *name, struct nfs_iodesc *newfd)
struct args {
uint32_t fhsize;
uint32_t fhplusname[1 +
- (NFS_V3MAXFHSIZE + FNAME_SIZE) / sizeof(uint32_t)];
+ (NFS_V3MAXFHSIZE + FNAME_SIZE) / sizeof (uint32_t)];
} *args;
struct repl {
uint32_t errno;
uint32_t fhsize;
uint32_t fhplusattr[(NFS_V3MAXFHSIZE +
- 2 * (sizeof(uint32_t) +
- sizeof(struct nfsv3_fattrs))) / sizeof(uint32_t)];
+ 2 * (sizeof (uint32_t) +
+ sizeof (struct nfsv3_fattrs))) / sizeof (uint32_t)];
} *repl;
struct {
uint32_t h[RPC_HEADER_WORDS];
@@ -274,17 +274,17 @@ nfs_lookupfh(struct nfs_iodesc *d, const char *name, struct nfs_iodesc *newfd)
args = &sdata.d;
- bzero(args, sizeof(*args));
+ bzero(args, sizeof (*args));
args->fhsize = htonl(d->fhsize);
bcopy(d->fh, args->fhplusname, d->fhsize);
len = strlen(name);
if (len > FNAME_SIZE)
len = FNAME_SIZE;
- pos = roundup(d->fhsize, sizeof(uint32_t)) / sizeof(uint32_t);
+ pos = roundup(d->fhsize, sizeof (uint32_t)) / sizeof (uint32_t);
args->fhplusname[pos++] = htonl(len);
bcopy(name, &args->fhplusname[pos], len);
- len = sizeof(uint32_t) + pos * sizeof(uint32_t) +
- roundup(len, sizeof(uint32_t));
+ len = sizeof (uint32_t) + pos * sizeof (uint32_t) +
+ roundup(len, sizeof (uint32_t));
cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_LOOKUP,
args, len, (void **)&repl, &pkt);
@@ -292,7 +292,7 @@ nfs_lookupfh(struct nfs_iodesc *d, const char *name, struct nfs_iodesc *newfd)
free(pkt);
return (errno); /* XXX - from rpc_call */
}
- if (cc < 2 * sizeof(uint32_t)) {
+ if (cc < 2 * sizeof (uint32_t)) {
free(pkt);
return (EIO);
}
@@ -303,12 +303,12 @@ nfs_lookupfh(struct nfs_iodesc *d, const char *name, struct nfs_iodesc *newfd)
}
newfd->fhsize = ntohl(repl->fhsize);
bcopy(repl->fhplusattr, &newfd->fh, newfd->fhsize);
- pos = roundup(newfd->fhsize, sizeof(uint32_t)) / sizeof(uint32_t);
+ pos = roundup(newfd->fhsize, sizeof (uint32_t)) / sizeof (uint32_t);
if (repl->fhplusattr[pos++] == 0) {
free(pkt);
return (EIO);
}
- bcopy(&repl->fhplusattr[pos], &newfd->fa, sizeof(newfd->fa));
+ bcopy(&repl->fhplusattr[pos], &newfd->fa, sizeof (newfd->fa));
free(pkt);
return (0);
}
@@ -322,14 +322,14 @@ nfs_readlink(struct nfs_iodesc *d, char *buf)
void *pkt = NULL;
struct args {
uint32_t fhsize;
- u_char fh[NFS_V3MAXFHSIZE];
+ uchar_t fh[NFS_V3MAXFHSIZE];
} *args;
struct repl {
uint32_t errno;
uint32_t ok;
struct nfsv3_fattrs fa;
uint32_t len;
- u_char path[NFS_MAXPATHLEN];
+ uchar_t path[NFS_MAXPATHLEN];
} *repl;
struct {
uint32_t h[RPC_HEADER_WORDS];
@@ -345,16 +345,16 @@ nfs_readlink(struct nfs_iodesc *d, char *buf)
args = &sdata.d;
- bzero(args, sizeof(*args));
+ bzero(args, sizeof (*args));
args->fhsize = htonl(d->fhsize);
bcopy(d->fh, args->fh, d->fhsize);
cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_READLINK,
- args, sizeof(uint32_t) + roundup(d->fhsize, sizeof(uint32_t)),
+ args, sizeof (uint32_t) + roundup(d->fhsize, sizeof (uint32_t)),
(void **)&repl, &pkt);
if (cc == -1)
return (errno);
- if (cc < 2 * sizeof(uint32_t)) {
+ if (cc < 2 * sizeof (uint32_t)) {
rc = EIO;
goto done;
}
@@ -392,7 +392,7 @@ nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len)
void *pkt = NULL;
struct args {
uint32_t fhsize;
- uint32_t fhoffcnt[NFS_V3MAXFHSIZE / sizeof(uint32_t) + 3];
+ uint32_t fhoffcnt[NFS_V3MAXFHSIZE / sizeof (uint32_t) + 3];
} *args;
struct repl {
uint32_t errno;
@@ -401,7 +401,7 @@ nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len)
uint32_t count;
uint32_t eof;
uint32_t len;
- u_char data[NFSREAD_MAX_SIZE];
+ uchar_t data[NFSREAD_MAX_SIZE];
} *repl;
struct {
uint32_t h[RPC_HEADER_WORDS];
@@ -413,10 +413,10 @@ nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len)
args = &sdata.d;
- bzero(args, sizeof(*args));
+ bzero(args, sizeof (*args));
args->fhsize = htonl(d->fhsize);
bcopy(d->fh, args->fhoffcnt, d->fhsize);
- pos = roundup(d->fhsize, sizeof(uint32_t)) / sizeof(uint32_t);
+ pos = roundup(d->fhsize, sizeof (uint32_t)) / sizeof (uint32_t);
args->fhoffcnt[pos++] = 0;
args->fhoffcnt[pos++] = htonl((uint32_t)off);
if (len > nfs_read_size)
@@ -425,7 +425,7 @@ nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len)
hlen = offsetof(struct repl, data[0]);
cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_READ,
- args, 4 * sizeof(uint32_t) + roundup(d->fhsize, sizeof(uint32_t)),
+ args, 4 * sizeof (uint32_t) + roundup(d->fhsize, sizeof (uint32_t)),
(void **)&repl, &pkt);
if (cc == -1) {
/* errno was already set by rpc_call */
@@ -464,7 +464,7 @@ nfs_open(const char *upath, struct open_file *f)
struct iodesc *desc;
struct nfs_iodesc *currfd = NULL;
char buf[2 * NFS_V3MAXFHSIZE + 3];
- u_char *fh;
+ uchar_t *fh;
char *cp;
int i;
struct nfs_iodesc *newfd = NULL;
@@ -518,12 +518,12 @@ nfs_open(const char *upath, struct open_file *f)
setenv("boot.nfsroot.nfshandlelen", buf, 1);
/* Allocate file system specific data structure */
- currfd = malloc(sizeof(*newfd));
+ currfd = malloc(sizeof (*newfd));
if (currfd == NULL) {
error = ENOMEM;
goto out;
}
- bcopy(&nfs_root_node, currfd, sizeof(*currfd));
+ bcopy(&nfs_root_node, currfd, sizeof (*currfd));
newfd = NULL;
cp = path = strdup(upath);
@@ -549,7 +549,7 @@ nfs_open(const char *upath, struct open_file *f)
}
/* allocate file system specific data structure */
- newfd = malloc(sizeof(*newfd));
+ newfd = malloc(sizeof (*newfd));
if (newfd == NULL) {
error = ENOMEM;
goto out;
@@ -592,8 +592,8 @@ nfs_open(const char *upath, struct open_file *f)
link_len = strlen(linkbuf);
len = strlen(cp);
- if (link_len + len > MAXPATHLEN
- || ++nlinks > MAXSYMLINKS) {
+ if (link_len + len > MAXPATHLEN ||
+ ++nlinks > MAXSYMLINKS) {
error = ENOENT;
goto out;
}
@@ -607,7 +607,7 @@ nfs_open(const char *upath, struct open_file *f)
*/
cp = namebuf;
if (*cp == '/')
- bcopy(&nfs_root_node, currfd, sizeof(*currfd));
+ bcopy(&nfs_root_node, currfd, sizeof (*currfd));
free(newfd);
newfd = NULL;
@@ -628,7 +628,7 @@ out:
if (!error) {
currfd->off = 0;
currfd->cookie = 0;
- f->f_fsdata = (void *)currfd;
+ f->f_fsdata = currfd;
return (0);
}
@@ -649,7 +649,7 @@ nfs_close(struct open_file *f)
#ifdef NFS_DEBUG
if (debug)
- printf("nfs_close: fp=0x%lx\n", (u_long)fp);
+ printf("nfs_close: fp=%#p\n", fp);
#endif
free(fp);
@@ -670,12 +670,12 @@ nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
#ifdef NFS_DEBUG
if (debug)
- printf("nfs_read: size=%lu off=%d\n", (u_long)size,
- (int)fp->off);
+ printf("nfs_read: size=%zu off=%j\n", size,
+ (intmax_t)fp->off);
#endif
- while ((int)size > 0) {
+ while (size > 0) {
twiddle(16);
- cc = nfs_readdata(fp, fp->off, (void *)addr, size);
+ cc = nfs_readdata(fp, fp->off, addr, size);
/* XXX maybe should retry on certain errors */
if (cc == -1) {
#ifdef NFS_DEBUG
@@ -777,11 +777,12 @@ nfs_readdir(struct open_file *f, struct dirent *d)
free(pkt);
pkt = NULL;
args = &sdata.d;
- bzero(args, sizeof(*args));
+ bzero(args, sizeof (*args));
args->fhsize = htonl(fp->fhsize);
bcopy(fp->fh, args->fhpluscookie, fp->fhsize);
- pos = roundup(fp->fhsize, sizeof(uint32_t)) / sizeof(uint32_t);
+ pos = roundup(fp->fhsize,
+ sizeof (uint32_t)) / sizeof (uint32_t);
args->fhpluscookie[pos++] = htonl(fp->off >> 32);
args->fhpluscookie[pos++] = htonl(fp->off);
args->fhpluscookie[pos++] = htonl(fp->cookie >> 32);
@@ -789,8 +790,8 @@ nfs_readdir(struct open_file *f, struct dirent *d)
args->fhpluscookie[pos] = htonl(NFS_READDIRSIZE);
cc = rpc_call(fp->iodesc, NFS_PROG, NFS_VER3, NFSPROCV3_READDIR,
- args, 6 * sizeof(uint32_t) +
- roundup(fp->fhsize, sizeof(uint32_t)),
+ args, 6 * sizeof (uint32_t) +
+ roundup(fp->fhsize, sizeof (uint32_t)),
(void **)&buf, &pkt);
if (cc == -1) {
rc = errno;
@@ -822,7 +823,7 @@ nfs_readdir(struct open_file *f, struct dirent *d)
bcopy(rent->nameplus, d->d_name, d->d_namlen);
d->d_name[d->d_namlen] = '\0';
- pos = roundup(d->d_namlen, sizeof(uint32_t)) / sizeof(uint32_t);
+ pos = roundup(d->d_namlen, sizeof (uint32_t)) / sizeof (uint32_t);
fp->off = cookie = ((uint64_t)ntohl(rent->nameplus[pos]) << 32) |
ntohl(rent->nameplus[pos + 1]);
pos += 2;
diff --git a/usr/src/boot/sys/sys/types.h b/usr/src/boot/sys/sys/types.h
index ee3d847278..81168bdff4 100644
--- a/usr/src/boot/sys/sys/types.h
+++ b/usr/src/boot/sys/sys/types.h
@@ -60,7 +60,10 @@ typedef unsigned int uint; /* Sys V compatibility */
/*
* POSIX Extensions
*/
+typedef unsigned char uchar_t;
+typedef unsigned short ushort_t;
typedef unsigned int uint_t;
+typedef unsigned long ulong_t;
/*
* XXX POSIX sized integrals that should appear only in <sys/stdint.h>.