newchan man page on Inferno

Man page or keyword search:  
man Server   579 pages
apropos Keyword Search (all sections)
Output format
Inferno logo
[printable version]

NEWCHAN(10.2)							 NEWCHAN(10.2)

NAME
       newchan,	 chanfree,  cclose,  eqqid,  eqchan,  isdir, fdtochan, namec -
       channel operations

SYNOPSIS
       Chan* newchan(void)

       void  chanfree(Chan *c)

       int   eqqid(Qid a, Qid b)

       int   eqchan(Chan *a, Chan *b, int pathonly)

       void  isdir(Chan *c)

       Chan* fdtochan(Fgrp *f, int fd, int mode, int chkmnt, int iref)

       Chan* namec(char *pathname, int amode, int omode, ulong perm)

       void  cclose(Chan *c)

DESCRIPTION
       A value of type Chan represents a kernel channel for I/O and name space
       operations.  It has the following public structure:

	      typedef struct Chan{
		    ushort    type;	  /* driver name */
		    ulong     dev;	  /* instance number */
		    ushort    mode;	  /* open mode */
		    ushort    flag;	  /* COPEN set once opened */
		    ulong     offset;	  /* current file offset */
		    Qid	      qid;	  /* unique id (path, vers) */
		    Cname*     name;/* name by which it was accessed */

       Newchan	returns	 a  pointer  to a newly allocated channel (sleeping if
       necessary until memory is available).  Device drivers do	 not  normally
       call  newchan  directly,	 but  instead  allocate	 channels using either
       devattach, when a process attaches to the device's root,	 or  devclone,
       when an existing channel is cloned; see devattach(10.2).

       Chanfree frees the channel structure c for reuse.

       Eqqid  returns  1  if Qid values a and b are equal (ie, both their path
       and vers members are equal); it returns 0 otherwise.

       Eqchan returns 1 if a and b have the same qid,  type  and  dev  members
       (ie,  they  represent  the  same	 file);	 it  returns  0 otherwise.  If
       pathonly is non-zero, the comparison of the two	qid  members  compares
       only their path values, ignoring the version field vers.

       Isdir checks that a given channel c is a directory.  If so, it returns;
       otherwise, it generates an error(10.2), Enotdir.

       The Fgrp structure represents an array of open files, each  represented
       by  a  Chan,  indexed by integer file descriptors.  A given Fgrp can be
       shared between processes.

       Fdtochan returns a pointer to the Chan corresponding to file descriptor
       fd  in  file  descriptor	 group f (almost invariably up->env->fgrp, the
       file descriptor group for the current process).	If  mode  is  a	 valid
       mode  for sys-open(2), typically OREAD, OWRITE or ORDWR, it must corre‐
       spond to the mode with which fd was originally opened; if mode  is  -1,
       no  check  is  made.  If chkmnt is non-zero, c must not be a channel in
       use by the mount driver mnt(3).	On successful return, if iref is  non-
       zero,  the  channel's  reference	 count has been incremented.  Fdtochan
       calls error(10.2) if it detects invalid uses, in particular an  invalid
       file descriptor fd.

       Namec looks up a pathname in the current name space and returns a chan‐
       nel.  Amode determines the mode of look up, and must be one of the con‐
       stants below:

       Aaccess
	      Access file for information, as in the stat command or call.

       Atodir Access  file as directory (the QTDIR bit of its qid.type must be
	      set).

       Aopen  Access for I/O.

       Amount Access directory to be mounted upon.

       Acreate
	      File is to be created.

       If amode is Aopen or Acreate, omode should be a mode suitable for  sys-
       open(2);	 if  Acreate,  perm  should be valid file permissions.	In all
       other cases, omode and perm can be zero.

       Cclose decrements the reference count on c; if  no  further  references
       remain,	it  calls  the	corresponding  device's Dev.close to close the
       channel, and frees c.

DIAGNOSTICS
       Most functions call error(10.2) on any sort of error.

SOURCE
       /os/port/chan.c
       /emu/port/chan.c

SEE ALSO
       ref(10.2)

								 NEWCHAN(10.2)
[top]

List of man pages available for Inferno

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net