Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jun 2012 03:05:42 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r237590 - stable/8/usr.sbin/mfiutil
Message-ID:  <201206260305.q5Q35g6f011405@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Tue Jun 26 03:05:42 2012
New Revision: 237590
URL: http://svn.freebsd.org/changeset/base/237590

Log:
  MFC r237259 r237260 r237329:
  	Allow users with RO privilege to the device to read the RO attributes. [0]
  	Add __unused macros to appropriate places in order to allow building
  	with WARNS=6 on base gcc, gcc46, and clang
  
  PR:		bin/167302 [0]
  Approved by:	cperciva (implicit)

Modified:
  stable/8/usr.sbin/mfiutil/Makefile
  stable/8/usr.sbin/mfiutil/mfi_cmd.c
  stable/8/usr.sbin/mfiutil/mfi_config.c
  stable/8/usr.sbin/mfiutil/mfi_drive.c
  stable/8/usr.sbin/mfiutil/mfi_evt.c
  stable/8/usr.sbin/mfiutil/mfi_flash.c
  stable/8/usr.sbin/mfiutil/mfi_patrol.c
  stable/8/usr.sbin/mfiutil/mfi_show.c
  stable/8/usr.sbin/mfiutil/mfi_volume.c
  stable/8/usr.sbin/mfiutil/mfiutil.c
  stable/8/usr.sbin/mfiutil/mfiutil.h
Directory Properties:
  stable/8/usr.sbin/mfiutil/   (props changed)

Modified: stable/8/usr.sbin/mfiutil/Makefile
==============================================================================
--- stable/8/usr.sbin/mfiutil/Makefile	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/Makefile	Tue Jun 26 03:05:42 2012	(r237590)
@@ -6,7 +6,6 @@ SRCS=	mfiutil.c mfi_cmd.c mfi_config.c m
 MAN8=	mfiutil.8
 
 CFLAGS+= -fno-builtin-strftime
-WARNS?=3
 
 DPADD=	${LIBUTIL}
 LDADD=	-lutil

Modified: stable/8/usr.sbin/mfiutil/mfi_cmd.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_cmd.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfi_cmd.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -301,12 +301,12 @@ mfi_ctrl_get_info(int fd, struct mfi_ctr
 }
 
 int
-mfi_open(int unit)
+mfi_open(int unit, int acs)
 {
 	char path[MAXPATHLEN];
 
 	snprintf(path, sizeof(path), "/dev/mfi%d", unit);
-	return (open(path, O_RDWR));
+	return (open(path, acs));
 }
 
 void

Modified: stable/8/usr.sbin/mfiutil/mfi_config.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_config.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfi_config.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -35,6 +35,7 @@
 #endif
 #include <err.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <libutil.h>
 #ifdef DEBUG
 #include <stdint.h>
@@ -151,13 +152,13 @@ mfi_config_lookup_volume(struct mfi_conf
 }
 
 static int
-clear_config(int ac, char **av)
+clear_config(int ac __unused, char **av __unused)
 {
 	struct mfi_ld_list list;
 	int ch, error, fd;
 	u_int i;
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -410,7 +411,7 @@ find_next_volume(struct config_id_state 
 
 /* Populate an array with drives. */
 static void
-build_array(int fd, char *arrayp, struct array_info *array_info,
+build_array(int fd __unused, char *arrayp, struct array_info *array_info,
     struct config_id_state *state, int verbose)
 {
 	struct mfi_array *ar = (struct mfi_array *)arrayp;
@@ -575,7 +576,7 @@ create_volume(int ac, char **av)
 	narrays = 0;
 	error = 0;
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -857,7 +858,7 @@ delete_volume(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -925,7 +926,7 @@ add_spare(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -1050,7 +1051,7 @@ remove_spare(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -1196,7 +1197,7 @@ debug_config(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -1233,7 +1234,7 @@ dump(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");

Modified: stable/8/usr.sbin/mfiutil/mfi_drive.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_drive.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfi_drive.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -33,6 +33,7 @@
 #include <sys/errno.h>
 #include <ctype.h>
 #include <err.h>
+#include <fcntl.h>
 #include <libutil.h>
 #include <limits.h>
 #include <stdio.h>
@@ -71,7 +72,7 @@ mfi_drive_name(struct mfi_pd_info *pinfo
 		else
 			snprintf(buf, sizeof(buf), "%2u", device_id);
 
-		fd = mfi_open(mfi_unit);
+		fd = mfi_open(mfi_unit, O_RDWR);
 		if (fd < 0) {
 			warn("mfi_open");
 			return (buf);
@@ -329,11 +330,13 @@ cam_strvis(char *dst, const char *src, i
 const char *
 mfi_pd_inq_string(struct mfi_pd_info *info)
 {
-	struct scsi_inquiry_data *inq_data;
+	struct scsi_inquiry_data iqd, *inq_data = &iqd;
 	char vendor[16], product[48], revision[16], rstr[12], serial[SID_VENDOR_SPECIFIC_0_SIZE];
 	static char inq_string[64];
 
-	inq_data = (struct scsi_inquiry_data *)info->inquiry_data;
+	memcpy(inq_data, info->inquiry_data,
+	    (sizeof (iqd) <  sizeof (info->inquiry_data))?
+	    sizeof (iqd) : sizeof (info->inquiry_data));
 	if (SID_QUAL_IS_VENDOR_UNIQUE(inq_data))
 		return (NULL);
 	if (SID_TYPE(inq_data) != T_DIRECT)
@@ -383,7 +386,7 @@ drive_set_state(char *drive, uint16_t ne
 	uint8_t mbox[6];
 	int error, fd;
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -484,7 +487,7 @@ start_rebuild(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -541,7 +544,7 @@ abort_rebuild(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -597,7 +600,7 @@ drive_progress(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -663,7 +666,7 @@ drive_clear(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -723,7 +726,7 @@ drive_locate(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");

Modified: stable/8/usr.sbin/mfiutil/mfi_evt.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_evt.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfi_evt.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <err.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <strings.h>
@@ -63,7 +64,7 @@ mfi_get_events(int fd, struct mfi_evt_li
 }
 
 static int
-show_logstate(int ac, char **av)
+show_logstate(int ac, char **av __unused)
 {
 	struct mfi_evt_log_state info;
 	int error, fd;
@@ -73,7 +74,7 @@ show_logstate(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -541,7 +542,7 @@ show_events(int ac, char **av)
 	int ch, error, fd, num_events, verbose;
 	u_int i;
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");

Modified: stable/8/usr.sbin/mfiutil/mfi_flash.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_flash.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfi_flash.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -150,7 +150,7 @@ flash_adapter(int ac, char **av)
 		goto error;
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");

Modified: stable/8/usr.sbin/mfiutil/mfi_patrol.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_patrol.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfi_patrol.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <err.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -74,7 +75,7 @@ patrol_get_props(int fd, struct mfi_pr_p
 }
 
 static int
-show_patrol(int ac, char **av)
+show_patrol(int ac __unused, char **av __unused)
 {
 	struct mfi_pr_properties prop;
 	struct mfi_pr_status status;
@@ -86,7 +87,7 @@ show_patrol(int ac, char **av)
 	int error, fd;
 	u_int i;
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -192,11 +193,11 @@ show_patrol(int ac, char **av)
 MFI_COMMAND(show, patrol, show_patrol);
 
 static int
-start_patrol(int ac, char **av)
+start_patrol(int ac __unused, char **av __unused)
 {
 	int error, fd;
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -218,11 +219,11 @@ start_patrol(int ac, char **av)
 MFI_COMMAND(start, patrol, start_patrol);
 
 static int
-stop_patrol(int ac, char **av)
+stop_patrol(int ac __unused, char **av __unused)
 {
 	int error, fd;
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -293,7 +294,7 @@ patrol_config(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");

Modified: stable/8/usr.sbin/mfiutil/mfi_show.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_show.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfi_show.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <err.h>
+#include <fcntl.h>
 #include <libutil.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -50,7 +51,7 @@ format_stripe(char *buf, size_t buflen, 
 }
 
 static int
-show_adapter(int ac, char **av)
+show_adapter(int ac, char **av __unused)
 {
 	struct mfi_ctrl_info info;
 	char stripe[5];
@@ -61,7 +62,7 @@ show_adapter(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDONLY);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -135,7 +136,7 @@ show_adapter(int ac, char **av)
 MFI_COMMAND(show, adapter, show_adapter);
 
 static int
-show_battery(int ac, char **av)
+show_battery(int ac, char **av __unused)
 {
 	struct mfi_bbu_capacity_info cap;
 	struct mfi_bbu_design_info design;
@@ -148,7 +149,7 @@ show_battery(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDONLY);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -303,7 +304,7 @@ print_pd(struct mfi_pd_info *info, int s
 }
 
 static int
-show_config(int ac, char **av)
+show_config(int ac, char **av __unused)
 {
 	struct mfi_config_data *config;
 	struct mfi_array *ar;
@@ -320,7 +321,7 @@ show_config(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDONLY);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -409,7 +410,7 @@ show_config(int ac, char **av)
 MFI_COMMAND(show, config, show_config);
 
 static int
-show_volumes(int ac, char **av)
+show_volumes(int ac, char **av __unused)
 {
 	struct mfi_ld_list list;
 	struct mfi_ld_info info;
@@ -421,7 +422,7 @@ show_volumes(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDONLY);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -492,7 +493,7 @@ show_volumes(int ac, char **av)
 MFI_COMMAND(show, volumes, show_volumes);
 
 static int
-show_drives(int ac, char **av)
+show_drives(int ac, char **av __unused)
 {
 	struct mfi_pd_list *list;
 	struct mfi_pd_info info;
@@ -504,7 +505,7 @@ show_drives(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDONLY);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -600,7 +601,7 @@ display_firmware(struct mfi_info_compone
 }
 
 static int
-show_firmware(int ac, char **av)
+show_firmware(int ac, char **av __unused)
 {
 	struct mfi_ctrl_info info;
 	struct mfi_info_component header;
@@ -612,7 +613,7 @@ show_firmware(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDONLY);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -656,7 +657,7 @@ show_firmware(int ac, char **av)
 MFI_COMMAND(show, firmware, show_firmware);
 
 static int
-show_progress(int ac, char **av)
+show_progress(int ac, char **av __unused)
 {
 	struct mfi_ld_list llist;
 	struct mfi_pd_list *plist;
@@ -672,7 +673,7 @@ show_progress(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDONLY);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");

Modified: stable/8/usr.sbin/mfiutil/mfi_volume.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfi_volume.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfi_volume.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/errno.h>
 #include <err.h>
+#include <fcntl.h>
 #include <libutil.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -294,7 +295,7 @@ volume_cache(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -402,7 +403,7 @@ volume_name(int ac, char **av)
 		return (ENOSPC);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDWR);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");
@@ -453,7 +454,7 @@ volume_progress(int ac, char **av)
 		return (EINVAL);
 	}
 
-	fd = mfi_open(mfi_unit);
+	fd = mfi_open(mfi_unit, O_RDONLY);
 	if (fd < 0) {
 		error = errno;
 		warn("mfi_open");

Modified: stable/8/usr.sbin/mfiutil/mfiutil.c
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfiutil.c	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfiutil.c	Tue Jun 26 03:05:42 2012	(r237590)
@@ -92,10 +92,10 @@ usage(void)
 }
 
 static int
-version(int ac, char **av)
+version(int ac __unused, char **av __unused)
 {
 
-	printf("mfiutil version 1.0.13");
+	printf("mfiutil version 1.0.14");
 #ifdef DEBUG
 	printf(" (DEBUG)");
 #endif

Modified: stable/8/usr.sbin/mfiutil/mfiutil.h
==============================================================================
--- stable/8/usr.sbin/mfiutil/mfiutil.h	Tue Jun 26 03:05:17 2012	(r237589)
+++ stable/8/usr.sbin/mfiutil/mfiutil.h	Tue Jun 26 03:05:42 2012	(r237590)
@@ -139,7 +139,7 @@ int	mfi_lookup_drive(int fd, char *drive
 int	mfi_lookup_volume(int fd, const char *name, uint8_t *target_id);
 int	mfi_dcmd_command(int fd, uint32_t opcode, void *buf, size_t bufsize,
     uint8_t *mbox, size_t mboxlen, uint8_t *statusp);
-int	mfi_open(int unit);
+int	mfi_open(int unit, int acs);
 int	mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp);
 int	mfi_ld_get_info(int fd, uint8_t target_id, struct mfi_ld_info *info,
     uint8_t *statusp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206260305.q5Q35g6f011405>