stat.c revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* when a stat() is done for a non-device file, the devt returned
* via the stat is the devt of the device backing the filesystem which
* contains the file the stat was performed on. these devts are currently
* untranslated. if this turns out to cause problems in the future then
* we might want to add more devt translators to convert sd and cmdk
* devts into linux devts that normally represent disks.
*
* XXX this may not be the best place to have the devt translation code.
* devt translation will also be needed for /proc fs support, which will
* probably be done in the kernel. we may need to move this code into
* the kernel and add a brand syscall to do the translation for us. this
* will need to be worked out before putback.
*/
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <libintl.h>
#include <sys/lx_types.h>
#include <sys/lx_debug.h>
#include <sys/lx_audio.h>
/* define _KERNEL to get the devt manipulation macros */
#define _KERNEL
#include <sys/sysmacros.h>
#define LX_PTS_MAJOR_MIN 136
#define LX_PTS_MAJOR_MAX 143
#define LX_PTS_MAX \
#define LX_PTM_MAJOR 5
#define LX_PTM_MINOR 2
/* values for dt_type */
#define DTT_INVALID 0
#define DTT_LIST 1
#define DTT_CUSTOM 2
/* convience macros for access the dt_minor union */
/*
* structure used to define devt translators
*/
typedef struct minor_translator {
char *mt_path; /* solaris minor node path */
int mt_lx_major; /* linux major node number */
int mt_lx_minor; /* linux minor node number */
typedef struct devt_translator {
char *dt_driver; /* solaris driver name */
/* dt_type dictates how we intrepret dt_minor */
int dt_type;
union {
} dt_minor;
/*
* forward declerations
*/
static devt_translator_t devt_translators[];
/*
* called to initialize the devt translation subsystem
*/
int
{
char *driver;
int i, j, ret;
/* figure out the major numbers for our devt translators */
if (ret != 0) {
"lx_stat_init(): modctl(MODGETMAJBIND, ",
continue;
}
/* save the major node value */
/* if this translator doesn't use a list mapping we're done. */
continue;
/* for each device listed, lookup the minor node number */
/* stat the device */
if (ret != 0) {
"lx_stat_init(): stat(",
"%s: %s translator disabled for: %s\n"),
"lx_stat_init()", "devt",
} else {
/* make sure the major node matches */
}
/* save the minor node value */
}
}
return (0);
}
static int
/*ARGSUSED*/
{
int lx_maj;
int lx_min;
/*
* linux has a really small minor number name space (8 bits).
* so if pts devices are limited to one major number you could
* only have 256 of them. linux addresses this issue by using
* multiple major numbers for pts devices.
*/
if (min >= LX_PTS_MAX)
return (EOVERFLOW);
return (0);
}
static int
/*ARGSUSED*/
{
return (0);
}
static int
{
if (fd == -1) {
} else {
/*
* this is a cloning device so we have to ask the driver
* what kind of minor node this is
*/
return (-EINVAL);
}
switch (s_minor) {
case LXA_MINORNUM_DSP:
l_minor = 3;
break;
case LXA_MINORNUM_MIXER:
l_minor = 0;
break;
default:
return (-EINVAL);
}
return (0);
}
static void
{
if (lx_debug_enabled == 0)
return;
lx_debug("\ttranslated devt [%d, %d] -> [%d, %d]",
}
static int
{
int i, j, err;
/* look for a devt translator for this major number */
break;
}
/* try to translate the solaris devt to a linux devt */
switch (devt_translators[i].dt_type) {
case DTT_LIST:
/* found a translation */
*jdev = LX_MAKEDEVICE(
mt[j].mt_lx_major,
mt[j].mt_lx_minor);
return (0);
}
}
break;
case DTT_CUSTOM:
if (err == 0)
return (err);
break;
}
}
/* we don't have a translator for this device */
return (0);
}
static int
{
int err;
return (err);
return (err);
return (-EOVERFLOW);
/* Linux seems to report a 0 st_size for all block devices */
s->st_size = 0;
return (-errno);
return (0);
}
static int
{
int err;
return (err);
return (err);
/* Linux seems to report a 0 st_size for all block devices */
s->st_size = 0;
return (-errno);
return (0);
}
int
{
return (-errno);
}
int
{
if (lx_debug_enabled != 0) {
path = "?";
}
return (-errno);
}
int
{
return (-errno);
}
int
{
return (-errno);
}
int
{
if (lx_debug_enabled != 0) {
path = "?";
}
return (-errno);
}
int
{
return (-errno);
}
/*
* devt translator definitions
*/
#define MINOR_TRANSLATOR_END \
{ NULL, 0, 0, 0 }
/*
* translators for devts
*/
static minor_translator_t mtranslator_mm[] = {
};
static minor_translator_t mtranslator_random[] = {
};
static minor_translator_t mtranslator_sy[] = {
};
static minor_translator_t mtranslator_zcons[] = {
};
static devt_translator_t devt_translators[] = {
DEVT_TRANSLATOR(NULL, 0, 0)
};