summaryrefslogtreecommitdiff
path: root/channelio/open.h
blob: 98f1d47c13f6e204c551847f319c5fc5670cef82 (plain)
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
/* Per-open information for channelio.

   Copyright (C) 1995, 1996, 2007 Free Software Foundation, Inc.

   Written by Miles Bader <miles@gnu.ai.mit.edu>
   Reworked for channelio by Carl Fredrik Hammar <hammy.lite@gmail.com>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2, or (at
   your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */

#ifndef __OPEN_H__
#define __OPEN_H__

#include <pthread.h>
#include <hurd/channel.h>

/* Information about an open session.  */
struct open
{
  pthread_mutex_t lock;
  struct channel *channel;

  /* The current owner of the session.  For terminals, this affects
     controlling terminal behavior (see term_become_ctty).  For all
     objects this affects old-style async IO.  Negative values represent
     pgrps.  This has nothing to do with the owner of a file (as returned
     by io_stat, and as used for various permission checks by
     filesystems).  An owner of 0 indicates that there is no owner.  */
  pid_t owner;
};

/* Returns a new per-open structure in OPEN that wraps CHANNEL.
   Propagates any error.  */
error_t open_alloc (struct channel *channel, struct open **open);

/* Free OPEN and any resources it holds.  */
void open_free (struct open *open);

#endif /* __OPEN_H__ */