|
|
1.1 ! root 1: /* ! 2: * System V Compatible Message Device Driver ! 3: * ! 4: * This device driver provides System V compatible messaging operations. ! 5: * Operations are performed through the message device (/dev/msg). ! 6: * and are implemented as ioctl calls from msgctl, msgget, msgsnd, msgrcv ! 7: * utilities. ! 8: * ! 9: * Author: Allan Cornish. ! 10: * ! 11: */ ! 12: ! 13: #include <sys/coherent.h> ! 14: #include <sys/types.h> ! 15: #include <sys/uproc.h> ! 16: #include <errno.h> ! 17: #include <sys/con.h> ! 18: #include <sys/msg.h> ! 19: #ifndef _I386 ! 20: #define getusd(arg) getuwd(arg) ! 21: #define putusd(arg1, arg2) putuwd(arg1, arg2) ! 22: #endif ! 23: ! 24: /* ! 25: * Functions. ! 26: */ ! 27: ! 28: int msgopen(); ! 29: int msgioctl(); ! 30: int nulldev(); ! 31: int nonedev(); ! 32: ! 33: /* ! 34: * Device Configuration. ! 35: */ ! 36: ! 37: CON msgcon = { ! 38: DFCHR, /* Flags */ ! 39: 25, /* Major Index */ ! 40: msgopen, /* Open */ ! 41: nulldev, /* Close */ ! 42: nonedev, /* Block */ ! 43: nonedev, /* Read */ ! 44: nonedev, /* Write */ ! 45: msgioctl, /* Ioctl */ ! 46: nulldev, /* Power fail */ ! 47: nulldev, /* Timeout */ ! 48: nulldev, /* Load */ ! 49: nulldev /* Unload */ ! 50: }; ! 51: ! 52: /* ! 53: * Message Device Open. ! 54: */ ! 55: ! 56: static ! 57: msgopen( dev, mode ) ! 58: ! 59: dev_t dev; ! 60: int mode; ! 61: ! 62: { ! 63: extern struct msqid_ds * msqs; /* Pointer to array of message queues */ ! 64: ! 65: ! 66: if ( ! msqs ){ /* message queues not initialized */ ! 67: msginit(); ! 68: } ! 69: ! 70: if ( ! msqs ) /* no message queues */ ! 71: u.u_error = ENODEV; ! 72: } ! 73: ! 74: /* ! 75: * Message Device Ioctl. ! 76: */ ! 77: ! 78: static ! 79: msgioctl( dev, com, vec ) ! 80: ! 81: dev_t dev; ! 82: short com; ! 83: register short *vec; ! 84: ! 85: { ! 86: switch ( com ) { ! 87: ! 88: case MSGCTL: ! 89: putusd( vec+0, /* -1 */ ! 90: umsgctl(getusd( vec+1 ), /* msqid */ ! 91: getusd( vec+2 ), /* command */ ! 92: getusd( vec+3 ) )); /* msqid_ds address */ ! 93: return; ! 94: ! 95: case MSGGET: ! 96: putusd( vec+0, /* -1 */ ! 97: umsgget(getusd( vec+1 ), /* key 0 -15 */ ! 98: /* getusd( vec+2 ), key 15 - 31 */ ! 99: getusd( vec+3 ) )); /* msgflag */ ! 100: return; ! 101: ! 102: case MSGSND: ! 103: putusd( vec+0, /* -1 */ ! 104: umsgsnd(getusd( vec+1 ), /* msqid */ ! 105: getusd( vec+2 ), /* -> message text */ ! 106: getusd( vec+3 ), /* size of text */ ! 107: getusd( vec+4 ) )); /* flag */ ! 108: return; ! 109: ! 110: case MSGRCV: ! 111: putusd( vec+0, /* -1 */ ! 112: umsgrcv(getusd( vec+1 ), /* msqid */ ! 113: getusd( vec+2 ), /* -> message text */ ! 114: getusd( vec+3 ), /* size of text */ ! 115: getusd( vec+4 ), /* msgtype 0 - 15 */ ! 116: /* getusd( vec+5 ), msgtype 16 - 31 */ ! 117: getusd( vec+6 ) )); /* flag */ ! 118: return; ! 119: ! 120: default: ! 121: u.u_error = EINVAL; ! 122: return; ! 123: } ! 124: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.