File: stream.c

package info (click to toggle)
ibcs 971113-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,108 kB
  • ctags: 2,061
  • sloc: ansic: 14,910; makefile: 280; sh: 203; asm: 47; perl: 18; pascal: 2
file content (122 lines) | stat: -rw-r--r-- 2,053 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 *  linux/ibcs/stream.c
 *
 *  Copyright 1994, 1995  Mike Jagdis (jaggy@purplet.demon.co.uk)
 *
 * $Id: stream.c,v 1.9 1996/07/26 12:03:39 mike Exp $
 * $Source: /usr/CVS/ibcs/iBCSemul/stream.c,v $
 */

#include <linux/config.h>

#include <linux/module.h>
#include <linux/version.h>

#include <asm/segment.h>
#ifndef KERNEL_DS
#include <linux/segment.h>
#endif

#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/ptrace.h>
#include <linux/net.h>
#include <linux/mm.h>
#include <linux/socket.h>

#include <ibcs/ibcs.h>
#include <ibcs/stream.h>
#include <ibcs/tli.h>

#ifdef IBCS_TRACE
#include <ibcs/trace.h>
#endif


int
ibcs_getmsg(struct pt_regs *regs)
{
	int fd;
	struct inode *ino;

	fd = (int)get_syscall_parameter (regs, 0);

	if (!current->FD[fd]
	|| !(ino = current->FD[fd]->f_inode))
		return -EBADF;

	if (!ino->i_sock)
		return -EBADF;

#if defined(EMU_XTI) || defined(SPX)
	return timod_getmsg(fd, ino, 0, regs);
#else
	return 0;
#endif /* EMU_XTI */
}


int
ibcs_putmsg(struct pt_regs *regs)
{
	int fd;
	struct inode *ino;

	fd = (int)get_syscall_parameter (regs, 0);

	if (!current->FD[fd]
	|| !(ino = current->FD[fd]->f_inode))
		return -EBADF;

	if (!ino->i_sock
	&& (MAJOR(ino->i_rdev) != 30 || MINOR(ino->i_rdev) != 1))
		return -EBADF;

#if defined(EMU_XTI) || defined(EMU_SPX)
	return timod_putmsg(fd, ino, 0, regs);
#else
	return 0;
#endif
}


#ifdef EMU_XTI
int
ibcs_getpmsg(struct pt_regs *regs)
{
	int fd;
	struct inode *ino;

	fd = (int)get_syscall_parameter (regs, 0);

	if (!current->FD[fd]
	|| !(ino = current->FD[fd]->f_inode))
		return -EBADF;

	if (!ino->i_sock)
		return -EBADF;

	return timod_getmsg(fd, ino, 1, regs);
}


int
ibcs_putpmsg(struct pt_regs *regs)
{
	int fd;
	struct inode *ino;

	fd = (int)get_syscall_parameter (regs, 0);

	if (!current->FD[fd]
	|| !(ino = current->FD[fd]->f_inode))
		return -EBADF;

	if (!ino->i_sock
	&& (MAJOR(ino->i_rdev) != 30 || MINOR(ino->i_rdev) != 1))
		return -EBADF;

	return timod_putmsg(fd, ino, 1, regs);
}
#endif /* EMU_XTI */