1 |
/* |
/* |
2 |
Copyright (C) 1995,96,98,99,2000 Free Software Foundation, Inc. |
Copyright (C) 1995,96,98,99,2000,02 Free Software Foundation, Inc. |
3 |
Written by Michael I. Bushnell, p/BSG. |
Written by Michael I. Bushnell, p/BSG. |
4 |
|
|
5 |
This file is part of the GNU Hurd. |
This file is part of the GNU Hurd. |
206 |
MACH_MSG_TYPE_COPY_SEND); |
MACH_MSG_TYPE_COPY_SEND); |
207 |
mach_port_deallocate (mach_task_self (), right); |
mach_port_deallocate (mach_task_self (), right); |
208 |
} |
} |
209 |
|
|
210 |
if (err) |
if (err) |
211 |
error (2, err, "%s", tdev->dev.name); |
error (2, err, "%s", tdev->dev.name); |
212 |
|
|
236 |
break; |
break; |
237 |
|
|
238 |
if (tdev && flags != O_NORW) |
if (tdev && flags != O_NORW) |
239 |
{ |
{ |
240 |
if (tdev->user) |
if (tdev->user) |
241 |
return EBUSY; |
return EBUSY; |
242 |
else |
else |
277 |
error_t |
error_t |
278 |
trivfs_S_io_read (struct trivfs_protid *cred, |
trivfs_S_io_read (struct trivfs_protid *cred, |
279 |
mach_port_t reply, mach_msg_type_name_t reply_type, |
mach_port_t reply, mach_msg_type_name_t reply_type, |
280 |
vm_address_t *data, mach_msg_type_number_t *data_len, |
char **data, mach_msg_type_number_t *data_len, |
281 |
off_t offs, mach_msg_type_number_t amount) |
loff_t offs, size_t amount) |
282 |
{ |
{ |
283 |
struct tunnel_device *tdev; |
struct tunnel_device *tdev; |
284 |
struct sk_buff *skb; |
struct sk_buff *skb; |
295 |
tdev = (struct tunnel_device *) cred->po->cntl->hook; |
tdev = (struct tunnel_device *) cred->po->cntl->hook; |
296 |
|
|
297 |
__mutex_lock (&tdev->lock); |
__mutex_lock (&tdev->lock); |
298 |
|
|
299 |
while (skb_queue_len(&tdev->xq) == 0) |
while (skb_queue_len(&tdev->xq) == 0) |
300 |
{ |
{ |
301 |
if (cred->po->openmodes & O_NONBLOCK) |
if (cred->po->openmodes & O_NONBLOCK) |
315 |
|
|
316 |
skb = skb_dequeue (&tdev->xq); |
skb = skb_dequeue (&tdev->xq); |
317 |
assert(skb); |
assert(skb); |
318 |
|
|
319 |
if (skb->len < amount) |
if (skb->len < amount) |
320 |
amount = skb->len; |
amount = skb->len; |
321 |
if (amount > 0) |
if (amount > 0) |
322 |
{ |
{ |
323 |
/* Possibly allocate a new buffer. */ |
/* Possibly allocate a new buffer. */ |
324 |
if (*data_len < amount) |
if (*data_len < amount) |
325 |
*data = (vm_address_t) mmap (0, amount, PROT_READ|PROT_WRITE, |
{ |
326 |
MAP_ANON, 0, 0); |
*data = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); |
327 |
|
if (*data == MAP_FAILED) |
328 |
|
{ |
329 |
|
dev_kfree_skb (skb); |
330 |
|
__mutex_unlock (&tdev->lock); |
331 |
|
return ENOMEM; |
332 |
|
} |
333 |
|
} |
334 |
|
|
335 |
/* Copy the constant data into the buffer. */ |
/* Copy the constant data into the buffer. */ |
336 |
memcpy ((char *) *data, skb->data, amount); |
memcpy ((char *) *data, skb->data, amount); |
337 |
} |
} |
421 |
__mutex_lock (&tdev->lock); |
__mutex_lock (&tdev->lock); |
422 |
|
|
423 |
/* XXX: Now return the length of the next entry in the queue. |
/* XXX: Now return the length of the next entry in the queue. |
424 |
From the BSD manual: |
From the BSD manual: |
425 |
The tunnel device, normally /dev/tunN, is exclusive-open (it cannot be |
The tunnel device, normally /dev/tunN, is exclusive-open (it cannot be |
426 |
opened if it is already open) and is restricted to the super-user. A |
opened if it is already open) and is restricted to the super-user. A |
427 |
read() call will return an error (EHOSTDOWN) if the interface is not |
read() call will return an error (EHOSTDOWN) if the interface is not |
618 |
mapping; they will set none of the ports and return an error. Such |
mapping; they will set none of the ports and return an error. Such |
619 |
objects can still be accessed by io_read and io_write. */ |
objects can still be accessed by io_read and io_write. */ |
620 |
error_t |
error_t |
621 |
trivfs_S_io_map(struct trivfs_protid *cred, |
trivfs_S_io_map (struct trivfs_protid *cred, |
622 |
memory_object_t *rdobj, |
mach_port_t reply, |
623 |
mach_msg_type_name_t *rdtype, |
mach_msg_type_name_t replyPoly, |
624 |
memory_object_t *wrobj, |
memory_object_t *rdobj, |
625 |
mach_msg_type_name_t *wrtype) |
mach_msg_type_name_t *rdtype, |
626 |
|
memory_object_t *wrobj, |
627 |
|
mach_msg_type_name_t *wrtype) |
628 |
{ |
{ |
629 |
if (!cred) |
if (!cred) |
630 |
return EOPNOTSUPP; |
return EOPNOTSUPP; |