"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "stress-dev.c" between
stress-ng-0.13.04.tar.xz and stress-ng-0.13.05.tar.xz

About: stress-ng will stress test a computer system in various selectable ways. It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces.

stress-dev.c  (stress-ng-0.13.04.tar.xz):stress-dev.c  (stress-ng-0.13.05.tar.xz)
skipping to change at line 54 skipping to change at line 54
#if defined(HAVE_POLL_H) && \ #if defined(HAVE_POLL_H) && \
defined(HAVE_LIB_PTHREAD) && \ defined(HAVE_LIB_PTHREAD) && \
!defined(__sun__) && \ !defined(__sun__) && \
!defined(__HAIKU__) !defined(__HAIKU__)
#define STRESS_DEV_THREADS_MAX (4) #define STRESS_DEV_THREADS_MAX (4)
#define STRESS_DEV_OPEN_TRIES_MAX (8) #define STRESS_DEV_OPEN_TRIES_MAX (8)
static sigset_t set; static sigset_t set;
static shim_pthread_spinlock_t lock; static shim_pthread_spinlock_t lock;
static shim_pthread_spinlock_t parport_lock;
static char *dev_path; static char *dev_path;
static uint32_t mixup; static uint32_t mixup;
typedef struct stress_dev_func { typedef struct stress_dev_func {
const char *devpath; const char *devpath;
const size_t devpath_len; const size_t devpath_len;
void (*func)(const char *name, const int fd, const char *devpath); void (*func)(const stress_args_t *args, const int fd, const char *devpath );
} stress_dev_func_t; } stress_dev_func_t;
static stress_hash_table_t *dev_open_fail, *dev_open_ok, *dev_scsi; static stress_hash_table_t *dev_open_fail, *dev_open_ok, *dev_scsi;
/* /*
* mixup_sort()
* sort helper based on hash to mix up ordering
*/
static int mixup_sort(const struct dirent **d1, const struct dirent **d2)
{
uint32_t s1, s2;
s1 = stress_hash_pjw((*d1)->d_name);
s2 = stress_hash_pjw((*d2)->d_name);
if (s1 == s2)
return 0;
return (s1 < s2) ? -1 : 1;
}
/*
* ioctl_set_timeout() * ioctl_set_timeout()
* set a itimer to interrupt ioctl call after secs seconds * set a itimer to interrupt ioctl call after secs seconds
*/ */
static void ioctl_set_timeout(const double secs) static void ioctl_set_timeout(const double secs)
{ {
#if defined(ITIMER_REAL) #if defined(ITIMER_REAL)
if (secs > 0.0) { if (secs > 0.0) {
struct itimerval it; struct itimerval it;
int ret; int ret;
time_t tsecs = (time_t)secs; time_t tsecs = (time_t)secs;
skipping to change at line 211 skipping to change at line 196
return xen_guest; return xen_guest;
#else #else
return false; return false;
#endif #endif
} }
#if defined(__linux__) && \ #if defined(__linux__) && \
defined(HAVE_LINUX_MEDIA_H) && \ defined(HAVE_LINUX_MEDIA_H) && \
defined(MEDIA_IOC_DEVICE_INFO) defined(MEDIA_IOC_DEVICE_INFO)
static void stress_dev_media_linux( static void stress_dev_media_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#if defined(MEDIA_IOC_DEVICE_INFO) && \ #if defined(MEDIA_IOC_DEVICE_INFO) && \
defined(HAVE_MEDIA_DEVICE_INFO) defined(HAVE_MEDIA_DEVICE_INFO)
{ {
struct media_device_info mdi; struct media_device_info mdi;
int ret; int ret;
ret = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi); ret = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &mdi);
if (ret < 0) if (ret < 0)
return; return;
if (!mdi.driver[0]) if (!mdi.driver[0])
pr_inf("%s: ioctl MEDIA_IOC_DEVICE_INFO %s: null driver n ame\n", pr_inf("%s: ioctl MEDIA_IOC_DEVICE_INFO %s: null driver n ame\n",
name, devpath); args->name, devpath);
if (!mdi.model[0]) if (!mdi.model[0])
pr_inf("%s: ioctl MEDIA_IOC_DEVICE_INFO %s: null model na me\n", pr_inf("%s: ioctl MEDIA_IOC_DEVICE_INFO %s: null model na me\n",
name, devpath); args->name, devpath);
if (!mdi.bus_info[0]) if (!mdi.bus_info[0])
pr_inf("%s: ioctl MEDIA_IOC_DEVICE_INFO %s: null bus_info field\n", pr_inf("%s: ioctl MEDIA_IOC_DEVICE_INFO %s: null bus_info field\n",
name, devpath); args->name, devpath);
} }
#endif #endif
} }
#endif #endif
#if defined(HAVE_LINUX_VT_H) #if defined(HAVE_LINUX_VT_H)
static void stress_dev_vcs_linux( static void stress_dev_vcs_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#if defined(VT_GETMODE) && \ #if defined(VT_GETMODE) && \
defined(HAVE_VT_MODE) defined(HAVE_VT_MODE)
{ {
struct vt_mode mode; struct vt_mode mode;
int ret; int ret;
ret = ioctl(fd, VT_GETMODE, &mode); ret = ioctl(fd, VT_GETMODE, &mode);
skipping to change at line 278 skipping to change at line 263
ret = ioctl(fd, VT_GETSTATE, &vt_stat); ret = ioctl(fd, VT_GETSTATE, &vt_stat);
(void)ret; (void)ret;
} }
#endif #endif
} }
#endif #endif
#if defined(HAVE_LINUX_DM_IOCTL_H) #if defined(HAVE_LINUX_DM_IOCTL_H)
static void stress_dev_dm_linux( static void stress_dev_dm_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#if defined(DM_VERSION) && \ #if defined(DM_VERSION) && \
defined(HAVE_DM_IOCTL) defined(HAVE_DM_IOCTL)
{ {
struct dm_ioctl dm; struct dm_ioctl dm;
int ret; int ret;
ret = ioctl(fd, DM_VERSION, &dm); ret = ioctl(fd, DM_VERSION, &dm);
skipping to change at line 311 skipping to change at line 296
ret = ioctl(fd, DM_STATUS, &dm); ret = ioctl(fd, DM_STATUS, &dm);
(void)ret; (void)ret;
} }
#endif #endif
} }
#endif #endif
#if defined(HAVE_LINUX_VIDEODEV2_H) #if defined(HAVE_LINUX_VIDEODEV2_H)
static void stress_dev_video_linux( static void stress_dev_video_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#if defined(VIDIOC_QUERYCAP) && \ #if defined(VIDIOC_QUERYCAP) && \
defined(HAVE_V4L2_CAPABILITY) defined(HAVE_V4L2_CAPABILITY)
{ {
struct v4l2_capability c; struct v4l2_capability c;
int ret; int ret;
(void)memset(&c, 0, sizeof(c)); (void)memset(&c, 0, sizeof(c));
skipping to change at line 450 skipping to change at line 435
(void)ret; (void)ret;
} }
#endif #endif
} }
#endif #endif
#if defined(HAVE_TERMIOS_H) && \ #if defined(HAVE_TERMIOS_H) && \
defined(TCGETS) && \ defined(TCGETS) && \
defined(HAVE_TERMIOS) defined(HAVE_TERMIOS)
static void stress_dev_tty( static void stress_dev_tty(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
int ret; int ret;
struct termios t; struct termios t;
(void)name; (void)args;
(void)devpath; (void)devpath;
if (!isatty(fd)) if (!isatty(fd))
return; return;
ret = tcgetattr(fd, &t); ret = tcgetattr(fd, &t);
(void)ret; (void)ret;
#if defined(TCGETS) #if defined(TCGETS)
{ {
ret = ioctl(fd, TCGETS, &t); ret = ioctl(fd, TCGETS, &t);
skipping to change at line 788 skipping to change at line 773
} }
#endif #endif
} }
#endif #endif
/* /*
* stress_dev_blk() * stress_dev_blk()
* block device specific ioctls * block device specific ioctls
*/ */
static void stress_dev_blk( static void stress_dev_blk(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
off_t offset; off_t offset;
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#if defined(BLKFLSBUF) #if defined(BLKFLSBUF)
{ {
int ret; int ret;
ret = ioctl(fd, BLKFLSBUF, 0); ret = ioctl(fd, BLKFLSBUF, 0);
(void)ret; (void)ret;
} }
#endif #endif
skipping to change at line 1044 skipping to change at line 1029
/* Assume not */ /* Assume not */
return false; return false;
} }
#endif #endif
/* /*
* stress_dev_scsi_blk() * stress_dev_scsi_blk()
* SCSI block device specific ioctls * SCSI block device specific ioctls
*/ */
static void stress_dev_scsi_blk( static void stress_dev_scsi_blk(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
if (!is_scsi_dev(devpath)) if (!is_scsi_dev(devpath))
return; return;
#if defined(SG_GET_VERSION_NUM) #if defined(SG_GET_VERSION_NUM)
{ {
int ret, ver; int ret, ver;
ret = ioctl(fd, SG_GET_VERSION_NUM, &ver); ret = ioctl(fd, SG_GET_VERSION_NUM, &ver);
skipping to change at line 1110 skipping to change at line 1095
{ {
/* Old ioctl was 20 chars, new API 8 chars, 32 is plenty */ /* Old ioctl was 20 chars, new API 8 chars, 32 is plenty */
char pci[32]; char pci[32];
ret = ioctl(fd, SCSI_IOCTL_GET_PCI, pci); ret = ioctl(fd, SCSI_IOCTL_GET_PCI, pci);
(void)ret; (void)ret;
} }
#endif #endif
} }
#if defined(__linux__)
/*
* stress_dev_scsi_generic_linux()
* SCSI generic device specific ioctls for linux
*/
static void stress_dev_scsi_generic_linux(
const stress_args_t *args,
const int fd,
const char *devpath)
{
(void)args;
(void)fd;
(void)devpath;
#if defined(SG_GET_VERSION_NUM)
{
int ret, version = 0;
ret = ioctl(fd, SG_GET_VERSION_NUM, &version);
(void)ret;
}
#endif
#if defined(SG_GET_TIMEOUT)
{
int ret;
ret = ioctl(fd, SG_GET_TIMEOUT, 0);
(void)ret;
}
#endif
#if defined(SG_GET_LOW_DMA)
{
int ret, low;
ret = ioctl(fd, SG_GET_LOW_DMA, &low);
(void)ret;
}
#endif
#if defined(SG_GET_PACK_ID)
{
int ret, pack_id;
ret = ioctl(fd, SG_GET_PACK_ID, &pack_id);
(void)ret;
}
#endif
#if defined(SG_GET_NUM_WAITING)
{
int ret, n;
ret = ioctl(fd, SG_GET_NUM_WAITING, &n);
(void)ret;
}
#endif
#if defined(SG_GET_SG_TABLESIZE)
{
int ret, size;
ret = ioctl(fd, SG_GET_SG_TABLESIZE, &size);
(void)ret;
}
#endif
#if defined(SG_GET_RESERVED_SIZE)
{
int ret, size;
ret = ioctl(fd, SG_GET_RESERVED_SIZE, &size);
(void)ret;
}
#endif
#if defined(SG_GET_COMMAND_Q)
{
int ret, cmd_q;
ret = ioctl(fd, SG_GET_COMMAND_Q, &cmd_q);
(void)ret;
}
#endif
#if defined(SG_GET_ACCESS_COUNT)
{
int ret, n;
ret = ioctl(fd, SG_GET_ACCESS_COUNT, &n);
(void)ret;
}
#endif
#if defined(SCSI_IOCTL_GET_IDLUN)
{
int ret;
struct shim_scsi_idlun {
int four_in_one;
int host_unique_id;
} idlun;
ret = ioctl(fd, SCSI_IOCTL_GET_IDLUN, &idlun);
(void)ret;
}
#endif
#if defined(SCSI_IOCTL_GET_BUS_NUMBER)
{
int ret, bus;
ret = ioctl(fd, SCSI_IOCTL_GET_BUS_NUMBER, &bus);
(void)ret;
}
#endif
#if defined(SCSI_GET_TRANSFORM)
{
int ret, bus;
ret = ioctl(fd, SCSI_GET_TRANSFORM, 0);
(void)ret;
}
#endif
#if defined(SG_EMULATED_HOST)
{
int ret, emulated;
ret = ioctl(fd, SG_EMULATED_HOST, &emulated);
(void)ret;
}
#endif
#if defined(BLKSECTGET)
{
int ret, n;
ret = ioctl(fd, BLKSECTGET, &n);
(void)ret;
}
#endif
}
#endif
#if defined(HAVE_LINUX_RANDOM_H) #if defined(HAVE_LINUX_RANDOM_H)
/* /*
* stress_dev_random_linux() * stress_dev_random_linux()
* Linux /dev/random ioctls * Linux /dev/random ioctls
*/ */
static void stress_dev_random_linux( static void stress_dev_random_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#if defined(RNDGETENTCNT) #if defined(RNDGETENTCNT)
{ {
long entropy; long entropy;
int ret; int ret;
ret = ioctl(fd, RNDGETENTCNT, &entropy); ret = ioctl(fd, RNDGETENTCNT, &entropy);
(void)ret; (void)ret;
skipping to change at line 1217 skipping to change at line 1335
} }
ptr = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); ptr = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
if (ptr != MAP_FAILED) { if (ptr != MAP_FAILED) {
(void)munmap(ptr, page_size); (void)munmap(ptr, page_size);
} }
} }
static void stress_dev_mem_linux( static void stress_dev_mem_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)devpath; (void)devpath;
stress_dev_mem_mmap_linux(fd, true); stress_dev_mem_mmap_linux(fd, true);
} }
#endif #endif
#if defined(__linux__) #if defined(__linux__)
static void stress_dev_kmem_linux( static void stress_dev_kmem_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)devpath; (void)devpath;
stress_dev_mem_mmap_linux(fd, false); stress_dev_mem_mmap_linux(fd, false);
} }
#endif #endif
#if defined(__linux__) && \ #if defined(__linux__) && \
defined(CDROMREADTOCENTRY) && \ defined(CDROMREADTOCENTRY) && \
defined(HAVE_CDROM_MSF) && \ defined(HAVE_CDROM_MSF) && \
defined(HAVE_CDROM_TOCENTRY) defined(HAVE_CDROM_TOCENTRY)
skipping to change at line 1395 skipping to change at line 1513
(void)ret; (void)ret;
}, return); }, return);
#endif #endif
} }
#endif #endif
} }
#endif #endif
#if defined(__linux__) #if defined(__linux__)
static void stress_dev_cdrom_linux( static void stress_dev_cdrom_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
stress_cdrom_ioctl_msf(fd); stress_cdrom_ioctl_msf(fd);
#if defined(CDROM_GET_MCN) && \ #if defined(CDROM_GET_MCN) && \
defined(HAVE_CDROM_MCN) defined(HAVE_CDROM_MCN)
IOCTL_TIMEOUT(0.10, { IOCTL_TIMEOUT(0.10, {
struct cdrom_mcn mcn; struct cdrom_mcn mcn;
int ret; int ret;
skipping to change at line 1829 skipping to change at line 1947
(void)memset(&blk, 0, sizeof(blk)); (void)memset(&blk, 0, sizeof(blk));
ret = ioctl(fd, CDROMPLAYBLK, &blk); ret = ioctl(fd, CDROMPLAYBLK, &blk);
(void)ret; (void)ret;
}, return); }, return);
#endif #endif
} }
#endif #endif
#if defined(__linux__) #if defined(__linux__)
static void stress_dev_console_linux( static void stress_dev_console_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#if defined(HAVE_LINUX_KD_H) && \ #if defined(HAVE_LINUX_KD_H) && \
defined(KDGETLED) defined(KDGETLED)
{ {
char argp; char argp;
int ret; int ret;
ret = ioctl(fd, KDGETLED, &argp); ret = ioctl(fd, KDGETLED, &argp);
skipping to change at line 2255 skipping to change at line 2373
#endif #endif
(void)ret; (void)ret;
} }
#endif #endif
} }
#endif #endif
#if defined(__linux__) #if defined(__linux__)
static void stress_dev_kmsg_linux( static void stress_dev_kmsg_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)devpath; (void)devpath;
stress_dev_mem_mmap_linux(fd, true); stress_dev_mem_mmap_linux(fd, true);
} }
#endif #endif
#if defined(__linux__) #if defined(__linux__)
static void stress_dev_nvram_linux( static void stress_dev_nvram_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)devpath; (void)devpath;
stress_dev_mem_mmap_linux(fd, true); stress_dev_mem_mmap_linux(fd, true);
} }
#endif #endif
#if defined(HAVE_LINUX_HPET_H) #if defined(HAVE_LINUX_HPET_H)
static void stress_dev_hpet_linux( static void stress_dev_hpet_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
/* /*
* Avoid https://bugs.xenserver.org/browse/XSO-809 * Avoid https://bugs.xenserver.org/browse/XSO-809
*/ */
if (linux_xen_guest()) if (linux_xen_guest())
return; return;
#if defined(HPET_INFO) #if defined(HPET_INFO)
skipping to change at line 2345 skipping to change at line 2463
ret = ioctl(fd, CDROMMULTISESSION, &ms_info); ret = ioctl(fd, CDROMMULTISESSION, &ms_info);
(void)ret; (void)ret;
} }
#endif #endif
} }
#endif #endif
#if defined(__linux__) && \ #if defined(__linux__) && \
defined(STRESS_ARCH_X86) defined(STRESS_ARCH_X86)
static void stress_dev_port_linux( static void stress_dev_port_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
off_t off; off_t off;
uint8_t *ptr; uint8_t *ptr;
const size_t page_size = stress_get_pagesize(); const size_t page_size = stress_get_pagesize();
(void)name; (void)args;
(void)devpath; (void)devpath;
/* seek and read port 0x80 */ /* seek and read port 0x80 */
off = lseek(fd, (off_t)0x80, SEEK_SET); off = lseek(fd, (off_t)0x80, SEEK_SET);
if (off == 0) { if (off == 0) {
char data[1]; char data[1];
ssize_t ret; ssize_t ret;
ret = read(fd, data, sizeof(data)); ret = read(fd, data, sizeof(data));
(void)ret; (void)ret;
skipping to change at line 2388 skipping to change at line 2506
ret = ioctl(fd, cmd, &val); ret = ioctl(fd, cmd, &val);
(void)ret; (void)ret;
} }
/* /*
* stress_dev_hd_linux() * stress_dev_hd_linux()
* Linux HDIO ioctls * Linux HDIO ioctls
*/ */
static void stress_dev_hd_linux( static void stress_dev_hd_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)devpath; (void)devpath;
#if defined(HDIO_GETGEO) #if defined(HDIO_GETGEO)
{ {
struct hd_geometry geom; struct hd_geometry geom;
int ret; int ret;
ret = ioctl(fd, HDIO_GETGEO, &geom); ret = ioctl(fd, HDIO_GETGEO, &geom);
(void)ret; (void)ret;
} }
skipping to change at line 2467 skipping to change at line 2585
stress_dev_hd_linux_ioctl_long(fd, HDIO_GET_ADDRESS); stress_dev_hd_linux_ioctl_long(fd, HDIO_GET_ADDRESS);
#endif #endif
#if defined(HDIO_GET_BUSSTATE) #if defined(HDIO_GET_BUSSTATE)
stress_dev_hd_linux_ioctl_long(fd, HDIO_GET_BUSSTATE); stress_dev_hd_linux_ioctl_long(fd, HDIO_GET_BUSSTATE);
#endif #endif
} }
#endif #endif
static void stress_dev_null_nop( static void stress_dev_null_nop(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
} }
/* /*
* stress_dev_ptp_linux() * stress_dev_ptp_linux()
* minor exercising of the PTP device * minor exercising of the PTP device
*/ */
static void stress_dev_ptp_linux( static void stress_dev_ptp_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
#if defined(HAVE_LINUX_PTP_CLOCK_H) && \ #if defined(HAVE_LINUX_PTP_CLOCK_H) && \
defined(PTP_CLOCK_GETCAPS) && \ defined(PTP_CLOCK_GETCAPS) && \
defined(PTP_PIN_GETFUNC) defined(PTP_PIN_GETFUNC)
int ret; int ret;
struct ptp_clock_caps caps; struct ptp_clock_caps caps;
(void)name; (void)args;
(void)devpath; (void)devpath;
errno = 0; errno = 0;
ret = ioctl(fd, PTP_CLOCK_GETCAPS, &caps); ret = ioctl(fd, PTP_CLOCK_GETCAPS, &caps);
if (ret == 0) { if (ret == 0) {
int i, pins = caps.n_pins; int i, pins = caps.n_pins;
for (i = 0; i < pins; i++) { for (i = 0; i < pins; i++) {
struct ptp_pin_desc desc; struct ptp_pin_desc desc;
(void)memset(&desc, 0, sizeof(desc)); (void)memset(&desc, 0, sizeof(desc));
desc.index = (unsigned int)i; desc.index = (unsigned int)i;
ret = ioctl(fd, PTP_PIN_GETFUNC, &desc); ret = ioctl(fd, PTP_PIN_GETFUNC, &desc);
(void)ret; (void)ret;
} }
} }
#else #else
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#endif #endif
} }
#if defined(HAVE_LINUX_FD_H)
/*
* stress_dev_fd_linux()
* minor exercising of the floppy device
*/
static void stress_dev_fd_linux(
const stress_args_t *args,
const int fd,
const char *devpath)
{
(void)args;
(void)fd;
(void)devpath;
#if defined(FDMSGON)
{
int ret;
ret = ioctl(fd, FDMSGON, 0);
(void)ret;
}
#endif
#if defined(FDFLUSH)
{
int ret;
ret = ioctl(fd, FDFLUSH, 0);
(void)ret;
}
#endif
#if defined(FDGETPRM) && \
defined(HAVE_FLOPPY_STRUCT)
{
int ret;
struct floppy_struct floppy;
ret = ioctl(fd, FDGETPRM, &floppy);
if (ret == 0) {
ret = ioctl(fd, FDSETPRM, &floppy);
}
(void)ret;
}
#endif
#if defined(FDGETDRVSTAT) && \
defined(HAVE_FLOPPY_DRIVE_STRUCT)
{
int ret;
struct floppy_drive_struct drive;
ret = ioctl(fd, FDGETDRVSTAT, &drive);
(void)ret;
}
#endif
#if defined(FDPOLLDRVSTAT) && \
defined(HAVE_FLOPPY_DRIVE_STRUCT)
{
int ret;
struct floppy_drive_struct drive;
ret = ioctl(fd, FDPOLLDRVSTAT, &drive);
(void)ret;
}
#endif
#if defined(FDGETDRVTYP)
{
int ret;
char buf[64];
ret = ioctl(fd, FDGETDRVTYP, buf);
(void)ret;
}
#endif
#if defined(FDGETFDCSTAT) && \
defined(HAVE_FLOPPY_FDC_STATE)
{
int ret;
struct floppy_fdc_state state;
ret = ioctl(fd, FDGETFDCSTAT, &state);
(void)ret;
}
#endif
#if defined(FDMSGOFF)
{
int ret;
ret = ioctl(fd, FDMSGOFF, 0);
(void)ret;
}
#endif
}
#endif
/* /*
* stress_dev_snd_control_linux() * stress_dev_snd_control_linux()
* exercise Linux sound devices * exercise Linux sound devices
*/ */
static void stress_dev_snd_control_linux( static void stress_dev_snd_control_linux(
const char *name, const stress_args_t *args,
const int fd, const int fd,
const char *devpath) const char *devpath)
{ {
(void)name; (void)args;
(void)fd; (void)fd;
(void)devpath; (void)devpath;
#if defined(SNDRV_CTL_IOCTL_PVERSION) #if defined(SNDRV_CTL_IOCTL_PVERSION)
{ {
int ret, ver; int ret, ver;
ret = ioctl(fd, SNDRV_CTL_IOCTL_PVERSION, &ver); ret = ioctl(fd, SNDRV_CTL_IOCTL_PVERSION, &ver);
(void)ret; (void)ret;
} }
skipping to change at line 2585 skipping to change at line 2804
ret = ioctl(fd, SNDRV_CTL_IOCTL_POWER_STATE, &state); ret = ioctl(fd, SNDRV_CTL_IOCTL_POWER_STATE, &state);
#if defined(SNDRV_CTL_IOCTL_POWER) #if defined(SNDRV_CTL_IOCTL_POWER)
if (ret == 0) if (ret == 0)
ret = ioctl(fd, SNDRV_CTL_IOCTL_POWER, &state); ret = ioctl(fd, SNDRV_CTL_IOCTL_POWER, &state);
#endif #endif
(void)ret; (void)ret;
} }
#endif #endif
} }
#if defined(__linux__)
/*
* stress_dev_hwrng_linux()
* Exercise Linux Hardware Random Number Generator
*/
static void stress_dev_hwrng_linux(
const stress_args_t *args,
const int fd,
const char *devpath)
{
ssize_t ret;
off_t offset = (off_t)0;
char buffer[8];
(void)args;
(void)devpath;
offset = lseek(fd, offset, SEEK_SET);
(void)offset;
ret = read(fd, buffer, sizeof(buffer));
(void)ret;
}
#endif
#if defined(__linux__)
#if defined(PP_IOCT) && \
!defined(PPGETTIME32)
#define PPGETTIME32 _IOR(PP_IOCTL, 0x95, int32_t[2])
#endif
#if defined(PP_IOCT) && \
!defined(PPGETTIME64)
#define PPGETTIME64 _IOR(PP_IOCTL, 0x95, int64_t[2])
#endif
/*
* stress_dev_parport_linux()
* Exercise Linux parallel port
*/
static void stress_dev_parport_linux(
const stress_args_t *args,
const int fd,
const char *devpath)
{
#if defined(PPCLAIM) && \
defined(PPRELEASE)
bool claimed = false;
#endif
(void)args;
(void)fd;
(void)devpath;
/*
* We don't do a PPCLAIM or PPRELEASE on all
* the stressor instances since this the claim
* can indefinitely block and this stops the
* progress of the stressor. Just do this for
* instance 0. For other instances we run
* run without claiming and this will cause
* some of the ioctls to fail.
*/
#if defined(PPCLAIM) && \
defined(PPRELEASE)
if (args->instance == 0) {
int ret;
ret = shim_pthread_spin_lock(&parport_lock);
if (ret == 0) {
ret = ioctl(fd, PPCLAIM);
if (ret == 0)
claimed = true;
}
}
#endif
#if defined(PPGETMODE)
{
int ret, mode;
ret = ioctl(fd, PPGETMODE, &mode);
#if defined(PPSETMODE)
errno = 0;
if (ret == 0)
ret = ioctl(fd, PPSETMODE, &mode);
#endif
(void)ret;
}
#endif
#if defined(PPGETPHASE)
{
int ret, phase;
ret = ioctl(fd, PPGETPHASE, &phase);
#if defined(PPSETPHASE)
errno = 0;
if (ret == 0)
ret = ioctl(fd, PPSETPHASE, &phase);
#endif
(void)ret;
}
#endif
#if defined(PPGETMODES)
{
int ret, modes;
ret = ioctl(fd, PPGETMODES, &modes);
(void)ret;
}
#endif
#if defined(PPGETFLAGS)
{
int ret, uflags;
ret = ioctl(fd, PPGETFLAGS, &uflags);
#if defined(PPSETFLAGS)
errno = 0;
if (ret == 0)
ret = ioctl(fd, PPSETFLAGS, &uflags);
#endif
(void)ret;
}
#endif
#if defined(PPRSTATUS)
{
int ret;
char reg;
ret = ioctl(fd, PPRSTATUS, &reg);
(void)ret;
}
#endif
#if defined(PPRCONTROL)
{
int ret;
char reg;
ret = ioctl(fd, PPRCONTROL, &reg);
(void)ret;
}
#endif
#if defined(PPGETTIME32)
{
int ret;
int32_t time32[2];
ret = ioctl(fd, PPGETTIME32, time32);
(void)ret;
}
#endif
#if defined(PPGETTIME64)
{
int ret;
int64_t time64[2];
ret = ioctl(fd, PPGETTIME64, time64);
(void)ret;
}
#endif
#if defined(PPYIELD)
{
int ret;
ret = ioctl(fd, PPYIELD);
(void)ret;
}
#endif
#if defined(PPCLAIM) && \
defined(PPRELEASE)
if ((args->instance == 0) && claimed) {
int ret;
ret = ioctl(fd, PPRELEASE);
if (ret == 0)
claimed = true;
ret = shim_pthread_spin_unlock(&parport_lock);
(void)ret;
}
#endif
}
#endif
#define DEV_FUNC(dev, func) \ #define DEV_FUNC(dev, func) \
{ dev, sizeof(dev) - 1, func } { dev, sizeof(dev) - 1, func }
static const stress_dev_func_t dev_funcs[] = { static const stress_dev_func_t dev_funcs[] = {
#if defined(__linux__) && \ #if defined(__linux__) && \
defined(HAVE_LINUX_MEDIA_H) && \ defined(HAVE_LINUX_MEDIA_H) && \
defined(MEDIA_IOC_DEVICE_INFO) defined(MEDIA_IOC_DEVICE_INFO)
DEV_FUNC("/dev/media", stress_dev_media_linux), DEV_FUNC("/dev/media", stress_dev_media_linux),
#endif #endif
#if defined(HAVE_LINUX_VT_H) #if defined(HAVE_LINUX_VT_H)
skipping to change at line 2612 skipping to change at line 3023
#endif #endif
#if defined(HAVE_LINUX_RANDOM_H) #if defined(HAVE_LINUX_RANDOM_H)
DEV_FUNC("/dev/random", stress_dev_random_linux), DEV_FUNC("/dev/random", stress_dev_random_linux),
#endif #endif
#if defined(__linux__) #if defined(__linux__)
DEV_FUNC("/dev/mem", stress_dev_mem_linux), DEV_FUNC("/dev/mem", stress_dev_mem_linux),
DEV_FUNC("/dev/kmem", stress_dev_kmem_linux), DEV_FUNC("/dev/kmem", stress_dev_kmem_linux),
DEV_FUNC("/dev/kmsg", stress_dev_kmsg_linux), DEV_FUNC("/dev/kmsg", stress_dev_kmsg_linux),
DEV_FUNC("/dev/nvram", stress_dev_nvram_linux), DEV_FUNC("/dev/nvram", stress_dev_nvram_linux),
DEV_FUNC("/dev/cdrom", stress_dev_cdrom_linux), DEV_FUNC("/dev/cdrom", stress_dev_cdrom_linux),
DEV_FUNC("/dev/sr0", stress_dev_cdrom_linux), DEV_FUNC("/dev/sg", stress_dev_scsi_generic_linux),
DEV_FUNC("/dev/console", stress_dev_console_linux), DEV_FUNC("/dev/sr0", stress_dev_cdrom_linux),
DEV_FUNC("/dev/console",stress_dev_console_linux),
#endif #endif
#if defined(__linux__) && \ #if defined(__linux__) && \
defined(STRESS_ARCH_X86) defined(STRESS_ARCH_X86)
DEV_FUNC("/dev/port", stress_dev_port_linux), DEV_FUNC("/dev/port", stress_dev_port_linux),
#endif #endif
#if defined(HAVE_LINUX_HPET_H) #if defined(HAVE_LINUX_HPET_H)
DEV_FUNC("/dev/hpet", stress_dev_hpet_linux), DEV_FUNC("/dev/hpet", stress_dev_hpet_linux),
#endif #endif
DEV_FUNC("/dev/null", stress_dev_null_nop), DEV_FUNC("/dev/null", stress_dev_null_nop),
DEV_FUNC("/dev/ptp", stress_dev_ptp_linux), DEV_FUNC("/dev/ptp", stress_dev_ptp_linux),
DEV_FUNC("/dev/snd/control", stress_dev_snd_control_linux), DEV_FUNC("/dev/snd/control", stress_dev_snd_control_linux),
#if defined(HAVE_LINUX_FD_H) && \
defined(HAVE_FLOPPY_STRUCT)
DEV_FUNC("/dev/fd", stress_dev_fd_linux),
#endif
#if defined(__linux__)
DEV_FUNC("/dev/hwrng", stress_dev_hwrng_linux),
#endif
#if defined(__linux__)
DEV_FUNC("/dev/parport",stress_dev_parport_linux),
#endif
}; };
static void stress_dev_procname(const char *path) static void stress_dev_procname(const char *path)
{ {
/* /*
* Set process name to enable debugging if it gets stuck * Set process name to enable debugging if it gets stuck
*/ */
if (!(g_opt_flags & OPT_FLAGS_KEEP_NAME)) { if (!(g_opt_flags & OPT_FLAGS_KEEP_NAME)) {
char procname[55]; char procname[55];
skipping to change at line 2794 skipping to change at line 3216
pr_fail("%s: stat failed on %s, errno=%d (%s)\n", pr_fail("%s: stat failed on %s, errno=%d (%s)\n",
args->name, path, errno, strerror(errno)); args->name, path, errno, strerror(errno));
} else { } else {
if ((S_ISBLK(buf.st_mode) | (S_ISCHR(buf.st_mode))) == 0) { if ((S_ISBLK(buf.st_mode) | (S_ISCHR(buf.st_mode))) == 0) {
stress_dev_close_unlock(path, fd); stress_dev_close_unlock(path, fd);
goto next; goto next;
} }
} }
if (S_ISBLK(buf.st_mode)) { if (S_ISBLK(buf.st_mode)) {
stress_dev_blk(args->name, fd, path); stress_dev_blk(args, fd, path);
stress_dev_scsi_blk(args->name, fd, path); stress_dev_scsi_blk(args, fd, path);
#if defined(HAVE_LINUX_HDREG_H) #if defined(HAVE_LINUX_HDREG_H)
stress_dev_hd_linux(args->name, fd, path); stress_dev_hd_linux(args, fd, path);
#endif #endif
} }
#if defined(HAVE_TERMIOS_H) && \ #if defined(HAVE_TERMIOS_H) && \
defined(TCGETS) && \ defined(TCGETS) && \
defined(HAVE_TERMIOS) defined(HAVE_TERMIOS)
if (S_ISCHR(buf.st_mode) && if (S_ISCHR(buf.st_mode) &&
strncmp("/dev/vsock", path, 10) && strncmp("/dev/vsock", path, 10) &&
strncmp("/dev/dri", path, 8) && strncmp("/dev/dri", path, 8) &&
(ioctl(fd, TCGETS, &tios) == 0)) (ioctl(fd, TCGETS, &tios) == 0))
stress_dev_tty(args->name, fd, path); stress_dev_tty(args, fd, path);
#endif #endif
offset = lseek(fd, 0, SEEK_SET); offset = lseek(fd, 0, SEEK_SET);
stress_uint64_put((uint64_t)offset); stress_uint64_put((uint64_t)offset);
offset = lseek(fd, 0, SEEK_CUR); offset = lseek(fd, 0, SEEK_CUR);
stress_uint64_put((uint64_t)offset); stress_uint64_put((uint64_t)offset);
offset = lseek(fd, 0, SEEK_END); offset = lseek(fd, 0, SEEK_END);
stress_uint64_put((uint64_t)offset); stress_uint64_put((uint64_t)offset);
if (stress_time_now() - t_start > threshold) { if (stress_time_now() - t_start > threshold) {
skipping to change at line 2916 skipping to change at line 3338
(void)munmap(ptr, args->page_size); (void)munmap(ptr, args->page_size);
ptr = mmap(NULL, args->page_size, PROT_WRITE, MAP_SHARED, fd, 0); ptr = mmap(NULL, args->page_size, PROT_WRITE, MAP_SHARED, fd, 0);
if (ptr != MAP_FAILED) if (ptr != MAP_FAILED)
(void)munmap(ptr, args->page_size); (void)munmap(ptr, args->page_size);
ret = shim_fsync(fd); ret = shim_fsync(fd);
(void)ret; (void)ret;
for (i = 0; i < SIZEOF_ARRAY(dev_funcs); i++) { for (i = 0; i < SIZEOF_ARRAY(dev_funcs); i++) {
if (!strncmp(path, dev_funcs[i].devpath, dev_funcs[i].dev path_len)) if (!strncmp(path, dev_funcs[i].devpath, dev_funcs[i].dev path_len))
dev_funcs[i].func(args->name, fd, path); dev_funcs[i].func(args, fd, path);
} }
stress_dev_close_unlock(path, fd); stress_dev_close_unlock(path, fd);
if (stress_time_now() - t_start > threshold) { if (stress_time_now() - t_start > threshold) {
timeout = true; timeout = true;
goto next; goto next;
} }
/* /*
* O_RDONLY | O_WRONLY allows one to * O_RDONLY | O_WRONLY allows one to
* use the fd for ioctl() only operations * use the fd for ioctl() only operations
*/ */
skipping to change at line 3000 skipping to change at line 3422
const stress_args_t *args, const stress_args_t *args,
const char *path, const char *path,
const bool recurse, const bool recurse,
const int depth, const int depth,
const uid_t euid, const uid_t euid,
const char *tty_name) const char *tty_name)
{ {
struct dirent **dlist; struct dirent **dlist;
const mode_t flags = S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; const mode_t flags = S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
int32_t loops = args->instance < 8 ? (int32_t)args->instance + 1 : 8; int32_t loops = args->instance < 8 ? (int32_t)args->instance + 1 : 8;
int i, n; int i, k, n;
static int try_failed; static int try_failed;
if (!keep_stressing_flag()) if (!keep_stressing_flag())
return; return;
/* Don't want to go too deep */ /* Don't want to go too deep */
if (depth > 20) if (depth > 20)
return; return;
dlist = NULL; dlist = NULL;
n = scandir(path, &dlist, NULL, mixup_sort); n = scandir(path, &dlist, NULL, alphasort);
if (n <= 0) if (n <= 0)
goto done; goto done;
/*
* Shuffle
*/
for (k = 0; k < 5; k++) {
for (i = 0; i < n; i++) {
int j = stress_mwc32() % n;
struct dirent *tmp;
tmp = dlist[j];
dlist[j] = dlist[i];
dlist[i] = tmp;
}
}
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
int ret; int ret;
struct stat buf; struct stat buf;
char filename[PATH_MAX]; char filename[PATH_MAX];
char tmp[PATH_MAX]; char tmp[PATH_MAX];
struct dirent *d = dlist[i]; struct dirent *d = dlist[i];
size_t len; size_t len;
if (!keep_stressing(args)) if (!keep_stressing(args))
break; break;
skipping to change at line 3229 skipping to change at line 3665
(void)setpgid(0, g_pgrp); (void)setpgid(0, g_pgrp);
stress_parent_died_alarm(); stress_parent_died_alarm();
(void)sched_settings_apply(true); (void)sched_settings_apply(true);
rc = shim_pthread_spin_init(&lock, SHIM_PTHREAD_PROCESS_S HARED); rc = shim_pthread_spin_init(&lock, SHIM_PTHREAD_PROCESS_S HARED);
if (rc) { if (rc) {
pr_inf("%s: pthread_spin_init failed, errno=%d (% s)\n", pr_inf("%s: pthread_spin_init failed, errno=%d (% s)\n",
args->name, rc, strerror(rc)); args->name, rc, strerror(rc));
_exit(EXIT_NO_RESOURCE); _exit(EXIT_NO_RESOURCE);
} }
rc = shim_pthread_spin_init(&parport_lock, SHIM_PTHREAD_P
ROCESS_SHARED);
if (rc) {
pr_inf("%s: pthread_spin_init failed, errno=%d (%
s)\n",
args->name, rc, strerror(rc));
_exit(EXIT_NO_RESOURCE);
}
/* Make sure this is killable by OOM killer */ /* Make sure this is killable by OOM killer */
stress_set_oom_adjustment(args->name, true); stress_set_oom_adjustment(args->name, true);
mixup = stress_mwc32(); mixup = stress_mwc32();
for (i = 0; i < STRESS_DEV_THREADS_MAX; i++) { for (i = 0; i < STRESS_DEV_THREADS_MAX; i++) {
ret[i] = pthread_create(&pthreads[i], NULL, ret[i] = pthread_create(&pthreads[i], NULL,
stress_dev_thread, (void *)&pa); stress_dev_thread, (void *)&pa);
} }
 End of changes. 60 change blocks. 
70 lines changed or deleted 514 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)