/*1* Copyright (c) 2000 by Matthew Jacob2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions, and the following disclaimer,9* without modification, immediately at the beginning of the file.10* 2. The name of the author may not be used to endorse or promote products11* derived from this software without specific prior written permission.12*13* Alternatively, this software may be distributed under the terms of the14* the GNU Public License ("GPL").15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR20* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*28* Matthew Jacob29* Feral Software30* [email protected]31*/3233#include <unistd.h>34#include <stddef.h>35#include <stdint.h>36#include <stdlib.h>37#include <stdio.h>38#include <unistd.h>39#include <fcntl.h>40#include <sys/ioctl.h>41#include <cam/scsi/scsi_all.h>42#include <cam/scsi/scsi_ses.h>4344int45main(int argc, char **argv)46{47unsigned int nobj;48int fd;4950while (*++argv != NULL) {51char *name = *argv;52fd = open(name, O_RDONLY);53if (fd < 0) {54perror(name);55continue;56}57if (ioctl(fd, SESIOC_GETNOBJ, (caddr_t) &nobj) < 0) {58perror("SESIOC_GETNOBJ");59} else {60fprintf(stdout, "%s: %d objects\n", name, nobj);61}62close (fd);63}64return (0);65}666768