Allow users with RO privilege to the device to read the RO attributes.

PR:		bin/167302
Submitted by:	markham breitbach <markham@ssimicro.com>
Discussed with:	pjd (briefly)
Approved by:	cperciva
MFC after:	1 week
This commit is contained in:
eadler 2012-06-19 06:18:37 +00:00
parent 1edc5fff53
commit a60d1f6e5a
10 changed files with 41 additions and 35 deletions

View File

@ -301,12 +301,12 @@ mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp)
}
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

View File

@ -35,6 +35,7 @@
#endif
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <libutil.h>
#ifdef DEBUG
#include <stdint.h>
@ -157,7 +158,7 @@ clear_config(int ac, char **av)
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");
@ -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");

View File

@ -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, uint16_t device_id, uint32_t def)
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);
@ -383,7 +384,7 @@ drive_set_state(char *drive, uint16_t new_state)
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 +485,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 +542,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 +598,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 +664,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 +724,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");

View File

@ -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>
@ -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");

View File

@ -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");

View File

@ -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>
@ -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");
@ -196,7 +197,7 @@ start_patrol(int ac, char **av)
{
int error, fd;
fd = mfi_open(mfi_unit);
fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@ -222,7 +223,7 @@ stop_patrol(int ac, char **av)
{
int error, fd;
fd = mfi_open(mfi_unit);
fd = mfi_open(mfi_unit, O_RDWR);
if (fd < 0) {
error = errno;
warn("mfi_open");
@ -292,7 +293,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");

View File

@ -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>
@ -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");
@ -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");
@ -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");
@ -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");
@ -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");
@ -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");
@ -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");

View File

@ -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");

View File

@ -95,7 +95,7 @@ static int
version(int ac, char **av)
{
printf("mfiutil version 1.0.13");
printf("mfiutil version 1.0.14");
#ifdef DEBUG
printf(" (DEBUG)");
#endif

View File

@ -139,7 +139,7 @@ int mfi_lookup_drive(int fd, char *drive, uint16_t *device_id);
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);