home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / include / linux / gnbd.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-08-11  |  2.8 KB  |  104 lines

  1. /******************************************************************************
  2. *******************************************************************************
  3. **
  4. **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
  5. **  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
  6. **
  7. **  This copyrighted material is made available to anyone wishing to use,
  8. **  modify, copy, or redistribute it subject to the terms and conditions
  9. **  of the GNU General Public License v.2.
  10. **
  11. *******************************************************************************
  12. ******************************************************************************/
  13.  
  14. #ifndef LINUX_GNBD_H
  15. #define LINUX_GNBD_H
  16.  
  17. #define GNBD_DO_IT    _IO( 0xab, 0x20 )
  18. #define GNBD_CLEAR_QUE    _IO( 0xab, 0x21 )
  19. #define GNBD_PRINT_DEBUG    _IO( 0xab, 0x22 )
  20. #define GNBD_DISCONNECT  _IO( 0xab, 0x23 )
  21. #define GNBD_PING    _IO( 0xab, 0x24 )
  22. #define GNBD_GET_TIME _IO( 0xab, 0x25 )
  23.  
  24. enum {
  25.     GNBD_CMD_READ = 0,
  26.     GNBD_CMD_WRITE = 1,
  27.     GNBD_CMD_DISC = 2,
  28.     GNBD_CMD_PING = 3
  29. };
  30.  
  31. #define gnbd_cmd(req) ((req)->cmd[0])
  32. #define MAX_GNBD 128
  33.  
  34. /* values for flags field */
  35. #define GNBD_READ_ONLY 0x0001
  36.  
  37. /* userspace doesn't need the gnbd_device structure */
  38. #ifdef __KERNEL__
  39.  
  40. struct gnbd_device {
  41.     unsigned short int flags;
  42.     struct socket * sock;
  43.     struct file * file;     /* If == NULL, device is not ready, yet    */
  44.     int magic;
  45.     spinlock_t queue_lock;
  46.     spinlock_t open_lock;
  47.     struct list_head queue_head;/* Requests are added here...    */
  48.     struct semaphore tx_lock;
  49.     struct gendisk *disk;
  50.     pid_t receiver_pid;
  51.     struct semaphore do_it_lock;
  52.     int open_count;
  53.     struct class_device class_dev;
  54.     unsigned short int server_port;
  55.     char *server_name;
  56.     char name[32];
  57.     unsigned long last_received;
  58.     struct block_device *bdev;
  59. };
  60.  
  61. #endif /* __KERNEL__ */
  62.  
  63. /* These are sent over the network in the request/reply magic fields */
  64.  
  65. #define GNBD_REQUEST_MAGIC 0x37a07e00
  66. #define GNBD_REPLY_MAGIC 0x41f09370
  67. #define GNBD_KEEP_ALIVE_MAGIC 0x5B46D8C2
  68. /* Do *not* use magics: 0x12560953 0x96744668. */
  69.  
  70. /*
  71.  * This is the packet used for communication between client and
  72.  * server. All data are in network byte order.
  73.  */
  74. struct gnbd_request {
  75.     uint32_t magic;
  76.     uint32_t type;    /* == READ || == WRITE     why so long */
  77.     char handle[8];  /* why is this a char array instead of a u64 */
  78.     uint64_t from;
  79.     uint32_t len;
  80. }
  81. #ifdef __GNUC__
  82.     __attribute__ ((packed))
  83. #endif /* __GNUC__ */
  84. ;
  85.  
  86. /*
  87.  * This is the reply packet that gnbd-server sends back to the client after
  88.  * it has completed an I/O request (or an error occurs).
  89.  */
  90. #define SIZE_OF_REPLY 16
  91. struct gnbd_reply {
  92.     uint32_t magic;
  93.     uint32_t error;        /* 0 = ok, else error    */
  94.     char handle[8];        /* handle you got from request    */
  95. };
  96.  
  97. struct do_it_req_s {
  98.         unsigned int minor;
  99.         int sock_fd;
  100. };
  101. typedef struct do_it_req_s do_it_req_t;
  102.  
  103. #endif /* LINUX_GNBD_H */
  104.