vm: fix potential null deref
[minix.git] / commands / mdb / ioctl.c
blob0b8070c6b8de302f14ce07dc9b9f8138e94462ee
1 /*
2 * ioctl.c for mdb -- decode an IOCTL system call
3 */
4 #include "mdb.h"
5 #ifdef SYSCALLS_SUPPORT
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <fcntl.h>
10 #include <sys/stat.h>
11 #include <minix/type.h>
12 #include <minix/callnr.h>
13 #include <minix/com.h>
14 #include <sys/ioctl.h>
15 #include <sgtty.h>
16 #include "proto.h"
18 static int get_request;
20 /*
21 * decode ioctl call
22 * send or receive = 'R' or 'S'
24 void decode_ioctl(sr, m)
25 int sr;
26 message *m;
28 int request, device;
29 int high;
30 long spek, flags;
32 device = m->m2_i1;
33 request = m->m2_i3;
34 spek = m->m2_l1;
35 flags = m->m2_l2;
37 #ifdef DEBUG
38 if( debug )
39 Printf("%c device=%d request=%c|%d m2_l1=%lx m2_l2=%lx\n",
40 sr,device,
41 (request >> 8) & BYTE,
42 request & BYTE,
43 spek,flags);
44 #endif
46 if ( sr == 'R') request = get_request;
48 if ( sr == 'S' ) {
49 Printf("Sending (%lx) ", request);
50 get_request = request;
52 else
53 Printf("Receiving (%lx) ", request);
55 high = ( request & 0xFFFF0000 ) >> 16 ;
56 request &= _IOCTYPE_MASK;
58 Printf("Other IOCTL device=%d request=%c|%d flags=%x size =%d\n",
59 device, (request >> 8) & BYTE, request & BYTE,
60 (high & ~_IOCPARM_MASK ),
61 (high & _IOCPARM_MASK )
63 Printf("\n");
67 #endif /* SYSCALLS_SUPPORT */