SLES10 Fixes (part 9)

- Proper ioctl() 32/64-bit binary compatibility.  We need to ensure the
  ioctl data itself is always packed the same for 32/64-bit binaries.
  Additionally, the correct thing to do is encode this size in bytes
  as part of the command using _IOC_SIZE().
- Minor formatting changes to respect the 80 character limit.
- Move all SPLAT_SUBSYSTEM_* defines in to splat-ctl.h.
- Increase SPLAT_SUBSYSTEM_UNKNOWN because we were getting close
  to accidentally using it for a real registered subsystem.
This commit is contained in:
Brian Behlendorf
2009-05-21 10:56:11 -07:00
parent 9593ef76d9
commit e554dffa60
16 changed files with 64 additions and 85 deletions
+39 -23
View File
@@ -27,10 +27,13 @@
#ifndef _SPLAT_CTL_H
#define _SPLAT_CTL_H
/* Contains shared definitions which both the userspace
* and kernelspace portions of splat must agree on.
*/
#include <linux/types.h>
/*
* Contains shared definitions for both user space and kernel space. To
* ensure 32-bit/64-bit interoperability over ioctl()'s only types with
* fixed sizes can be used.
*/
#define SPLAT_MAJOR 225 /* XXX - Arbitrary */
#define SPLAT_MINORS 1
#define SPLAT_NAME "splatctl"
@@ -40,24 +43,24 @@
#define SPLAT_DESC_SIZE 60
typedef struct splat_user {
char name[SPLAT_NAME_SIZE]; /* short name */
char desc[SPLAT_DESC_SIZE]; /* short description */
int id; /* unique numeric id */
char name[SPLAT_NAME_SIZE]; /* Short name */
char desc[SPLAT_DESC_SIZE]; /* Short description */
__u32 id; /* Unique numeric id */
} splat_user_t;
#define SPLAT_CFG_MAGIC 0x15263748U
typedef struct splat_cfg {
unsigned int cfg_magic; /* Unique magic */
int cfg_cmd; /* Config command */
int cfg_arg1; /* Config command arg 1 */
int cfg_rc1; /* Config response 1 */
__u32 cfg_magic; /* Unique magic */
__u32 cfg_cmd; /* Configure command */
__s32 cfg_arg1; /* Configure command arg 1 */
__s32 cfg_rc1; /* Configure response 1 */
union {
struct {
int size;
__u32 size;
splat_user_t descs[0];
} splat_subsystems;
struct {
int size;
__u32 size;
splat_user_t descs[0];
} splat_tests;
} cfg_data;
@@ -65,16 +68,16 @@ typedef struct splat_cfg {
#define SPLAT_CMD_MAGIC 0x9daebfc0U
typedef struct splat_cmd {
unsigned int cmd_magic; /* Unique magic */
int cmd_subsystem; /* Target subsystem */
int cmd_test; /* Subsystem test */
int cmd_data_size; /* Extra opaque data */
__u32 cmd_magic; /* Unique magic */
__u32 cmd_subsystem; /* Target subsystem */
__u32 cmd_test; /* Subsystem test */
__u32 cmd_data_size; /* Opaque data size */
char cmd_data_str[0]; /* Opaque data region */
} splat_cmd_t;
/* Valid ioctls */
#define SPLAT_CFG _IOWR('f', 101, long)
#define SPLAT_CMD _IOWR('f', 102, long)
#define SPLAT_CFG _IOWR('f', 101, splat_cfg_t)
#define SPLAT_CMD _IOWR('f', 102, splat_cmd_t)
/* Valid configuration commands */
#define SPLAT_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */
@@ -84,11 +87,24 @@ typedef struct splat_cmd {
#define SPLAT_CFG_TEST_COUNT 0x201 /* Number of tests */
#define SPLAT_CFG_TEST_LIST 0x202 /* List of N tests */
/* Valid subsystem and test commands defined in each subsystem, we do
* need to be careful to avoid colisions. That alone may argue to define
* them all here, for now we just define the global error codes.
/*
* Valid subsystem and test commands are defined in each subsystem as
* SPLAT_SUBSYSTEM_*. We do need to be careful to avoid collisions, the
* currently defined subsystems are as follows:
*/
#define SPLAT_SUBSYSTEM_UNKNOWN 0xF00
#define SPLAT_TEST_UNKNOWN 0xFFF
#define SPLAT_SUBSYSTEM_KMEM 0x0100
#define SPLAT_SUBSYSTEM_TASKQ 0x0200
#define SPLAT_SUBSYSTEM_KRNG 0x0300
#define SPLAT_SUBSYSTEM_MUTEX 0x0400
#define SPLAT_SUBSYSTEM_CONDVAR 0x0500
#define SPLAT_SUBSYSTEM_THREAD 0x0600
#define SPLAT_SUBSYSTEM_RWLOCK 0x0700
#define SPLAT_SUBSYSTEM_TIME 0x0800
#define SPLAT_SUBSYSTEM_VNODE 0x0900
#define SPLAT_SUBSYSTEM_KOBJ 0x0a00
#define SPLAT_SUBSYSTEM_ATOMIC 0x0b00
#define SPLAT_SUBSYSTEM_LIST 0x0c00
#define SPLAT_SUBSYSTEM_GENERIC 0x0d00
#define SPLAT_SUBSYSTEM_UNKNOWN 0xff00
#endif /* _SPLAT_CTL_H */