Files
Arquivotheca.AIX-4.1.3/bos/kernel/lfs/getdevno.c
seta75D d6fe8fe829 Init
2021-10-11 22:19:34 -03:00

73 lines
1.5 KiB
C

static char sccsid[] = "@(#)86 1.3 src/bos/kernel/lfs/getdevno.c, syslfs, bos411, 9428A410j 8/27/93 16:20:58";
/*
* COMPONENT_NAME: SYSLFS - Logical File System
*
* FUNCTIONS: fp_getdevno
*
* ORIGINS: 27
*
* IBM CONFIDENTIAL -- (IBM Confidential Restricted when
* combined with the aggregated modules for this product)
* SOURCE MATERIALS
* (C) COPYRIGHT International Business Machines Corp. 1988, 1993
* All Rights Reserved
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
#include <sys/types.h>
#include <sys/user.h>
#include <sys/file.h>
#include <sys/vnode.h>
#include <sys/errno.h>
#include <sys/fs_locks.h>
/*
* fp_getdevno - Return the device number and channel number of the
* device associated with fp.
*/
fp_getdevno(fp,devp,chanp)
struct file * fp;
dev_t * devp;
chan_t * chanp;
{
struct gnode *gp;
int klock; /* entered with kernel lock held */
int rc = 0; /* return code */
if ((klock = IS_LOCKED(&kernel_lock)) != 0)
unlockl(&kernel_lock);
FP_LOCK(fp);
if (fp->f_count <= 0)
{
rc = EINVAL;
goto exit;
}
if (fp->f_type == DTYPE_GNODE)
gp = (struct gnode *) fp->f_vnode;
else if (fp->f_type == DTYPE_VNODE)
gp = (struct gnode *) VTOGP(fp->f_vnode);
else
{
rc = EINVAL;
goto exit;
}
if (devp)
*devp = gp->gn_rdev;
if (chanp)
*chanp = gp->gn_chan;
exit:
FP_UNLOCK(fp);
if (klock)
lockl(&kernel_lock, LOCK_SHORT);
return rc;
}