Cleaned up. Added the TRACE() macro to kernel_interface.c.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2970 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
#include "rock.h"
|
#include "rock.h"
|
||||||
#include "iso.h"
|
#include "iso.h"
|
||||||
|
|
||||||
#define TRACE_ISO9660 1
|
#define TRACE_ISO9660 0
|
||||||
#if TRACE_ISO9660
|
#if TRACE_ISO9660
|
||||||
# define TRACE(x) dprintf x
|
# define TRACE(x) dprintf x
|
||||||
#else
|
#else
|
||||||
@@ -204,20 +204,20 @@ ISOMount(const char *path, const int flags, nspace **newVol, bool allow_joliet)
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&partitionInfo,0,sizeof(partition_info));
|
memset(&partitionInfo, 0, sizeof(partition_info));
|
||||||
|
|
||||||
/* open and lock the device */
|
/* open and lock the device */
|
||||||
vol->fdOfSession = open(path, O_RDONLY);
|
vol->fdOfSession = open(path, O_RDONLY);
|
||||||
|
|
||||||
/* try to open the raw device to get access to the other sessions as well */
|
/* try to open the raw device to get access to the other sessions as well */
|
||||||
if (vol->fdOfSession >= 0) {
|
if (vol->fdOfSession >= 0) {
|
||||||
if (ioctl(vol->fdOfSession,B_GET_PARTITION_INFO,&partitionInfo) < B_NO_ERROR) {
|
if (ioctl(vol->fdOfSession, B_GET_PARTITION_INFO, &partitionInfo) < B_NO_ERROR) {
|
||||||
TRACE(("B_GET_PARTITION_INFO: ioctl returned error\n"));
|
TRACE(("B_GET_PARTITION_INFO: ioctl returned error\n"));
|
||||||
strcpy(partitionInfo.device,path);
|
strcpy(partitionInfo.device, path);
|
||||||
}
|
}
|
||||||
TRACE(("ISOMount: open device/file \"%s\"\n",partitionInfo.device));
|
TRACE(("ISOMount: open device/file \"%s\"\n", partitionInfo.device));
|
||||||
|
|
||||||
vol->fd = open(partitionInfo.device,O_RDONLY);
|
vol->fd = open(partitionInfo.device, O_RDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vol->fdOfSession < 0 || vol->fd < 0) {
|
if (vol->fdOfSession < 0 || vol->fd < 0) {
|
||||||
|
|||||||
@@ -27,6 +27,13 @@
|
|||||||
|
|
||||||
#include "iso.h"
|
#include "iso.h"
|
||||||
|
|
||||||
|
#define TRACE_ISO9660 0
|
||||||
|
#if TRACE_ISO9660
|
||||||
|
# define TRACE(x) dprintf x
|
||||||
|
#else
|
||||||
|
# define TRACE(x) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Start of fundamental (read-only) required functions */
|
/* Start of fundamental (read-only) required functions */
|
||||||
static int fs_mount(nspace_id nsid, const char *device, ulong flags,
|
static int fs_mount(nspace_id nsid, const char *device, ulong flags,
|
||||||
@@ -228,17 +235,17 @@ static int
|
|||||||
fs_unmount(void *_ns)
|
fs_unmount(void *_ns)
|
||||||
{
|
{
|
||||||
int result = B_NO_ERROR;
|
int result = B_NO_ERROR;
|
||||||
|
nspace *ns = (nspace *)_ns;
|
||||||
nspace* ns = (nspace*)_ns;
|
|
||||||
//dprintf("fs_unmount - ENTER\n");
|
TRACE(("fs_unmount - ENTER\n"));
|
||||||
//dprintf("fs_unmount - removing cached blocks\n");
|
|
||||||
remove_cached_device_blocks(ns->fd, 0);
|
remove_cached_device_blocks(ns->fd, 0);
|
||||||
//dprintf("fs_unmount - closing volume\n");
|
|
||||||
close(ns->fdOfSession);
|
close(ns->fdOfSession);
|
||||||
result = close(ns->fd);
|
result = close(ns->fd);
|
||||||
//dprintf("fs_unmount - freeing volume data\n");
|
|
||||||
free(ns);
|
free(ns);
|
||||||
//dprintf("fs_unmount - EXIT, result is %s\n", strerror(result));
|
|
||||||
|
TRACE(("fs_unmount - EXIT, result is %s\n", strerror(result)));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +257,7 @@ fs_read_fs_stat(void *_ns, struct fs_info *fss)
|
|||||||
nspace *ns = (nspace *)_ns;
|
nspace *ns = (nspace *)_ns;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//dprintf("fs_rfsstat - ENTER\n");
|
TRACE(("fs_rfsstat - ENTER\n"));
|
||||||
|
|
||||||
// Fill in device id.
|
// Fill in device id.
|
||||||
//fss->dev = ns->fd;
|
//fss->dev = ns->fd;
|
||||||
@@ -277,19 +284,19 @@ fs_read_fs_stat(void *_ns, struct fs_info *fss)
|
|||||||
strncpy(fss->device_name, ns->devicePath, sizeof(fss->device_name));
|
strncpy(fss->device_name, ns->devicePath, sizeof(fss->device_name));
|
||||||
|
|
||||||
strncpy(fss->volume_name, ns->volIDString, sizeof(fss->volume_name));
|
strncpy(fss->volume_name, ns->volIDString, sizeof(fss->volume_name));
|
||||||
for (i=strlen(fss->volume_name)-1;i>=0;i--)
|
for (i = strlen(fss->volume_name)-1; i >=0 ; i--)
|
||||||
if (fss->volume_name[i] != ' ')
|
if (fss->volume_name[i] != ' ')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
strcpy(fss->volume_name, "UNKNOWN");
|
strcpy(fss->volume_name, "UNKNOWN");
|
||||||
else
|
else
|
||||||
fss->volume_name[i+1] = 0;
|
fss->volume_name[i + 1] = 0;
|
||||||
|
|
||||||
// File system name
|
// File system name
|
||||||
strcpy(fss->fsh_name,"iso9660");
|
strcpy(fss->fsh_name, "iso9660");
|
||||||
|
|
||||||
//dprintf("fs_rfsstat - EXIT\n");
|
TRACE(("fs_rfsstat - EXIT\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,146 +311,126 @@ fs_walk(void *_ns, void *base, const char *file, char **newpath,
|
|||||||
{
|
{
|
||||||
/* Starting at the base, find file in the subdir, and return path
|
/* Starting at the base, find file in the subdir, and return path
|
||||||
string and vnode id of file. */
|
string and vnode id of file. */
|
||||||
nspace* ns = (nspace*)_ns;
|
nspace *ns = (nspace *)_ns;
|
||||||
vnode* baseNode = (vnode*)base;
|
vnode *baseNode = (vnode*)base;
|
||||||
uint32 dataLen = baseNode->dataLen[FS_DATA_FORMAT];
|
uint32 dataLen = baseNode->dataLen[FS_DATA_FORMAT];
|
||||||
vnode* newNode = NULL;
|
vnode *newNode = NULL;
|
||||||
int result = ENOENT;
|
int result = ENOENT;
|
||||||
bool done = FALSE;
|
bool done = FALSE;
|
||||||
uint32 totalRead = 0;
|
uint32 totalRead = 0;
|
||||||
off_t block;
|
off_t block = baseNode->startLBN[FS_DATA_FORMAT];
|
||||||
|
|
||||||
|
TRACE(("fs_walk - looking for %s in dir file of length %d\n", file,
|
||||||
|
baseNode->dataLen[FS_DATA_FORMAT]));
|
||||||
|
|
||||||
block = baseNode->startLBN[FS_DATA_FORMAT];
|
if (strcmp(file, ".") == 0) {
|
||||||
|
// base directory
|
||||||
//dprintf("fs_walk - ENTER\n");
|
TRACE(("fs_walk - found \".\" file.\n"));
|
||||||
//dprintf("fs_walk - looking for %s in dir file of length %d\n", file,baseNode->dataLen[FS_DATA_FORMAT]);
|
|
||||||
|
|
||||||
if (strcmp(file,".") == 0)
|
|
||||||
{
|
|
||||||
//dprintf("fs_walk - found \".\" file.\n");
|
|
||||||
*vnid = baseNode->id;
|
*vnid = baseNode->id;
|
||||||
if (get_vnode(ns->id,*vnid,(void **)&newNode) != 0)
|
if (get_vnode(ns->id, *vnid, (void **)&newNode) != 0)
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
result = B_NO_ERROR;
|
result = B_NO_ERROR;
|
||||||
}
|
} else if (strcmp(file, "..") == 0) {
|
||||||
}
|
// parent directory
|
||||||
else if (strcmp(file, "..") == 0)
|
TRACE(("fs_walk - found \"..\" file.\n"));
|
||||||
{
|
|
||||||
//dprintf("fs_walk - found \"..\" file.\n");
|
|
||||||
*vnid = baseNode->parID;
|
*vnid = baseNode->parID;
|
||||||
if (get_vnode(ns->id, *vnid, (void**)&newNode) != 0)
|
if (get_vnode(ns->id, *vnid, (void **)&newNode) != 0)
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
result = B_NO_ERROR;
|
result = B_NO_ERROR;
|
||||||
}
|
} else {
|
||||||
}
|
// look up file in the directory
|
||||||
|
char *blockData;
|
||||||
|
|
||||||
else
|
while ((totalRead < dataLen) && !done) {
|
||||||
{
|
off_t cachedBlock = block;
|
||||||
char* blockData;
|
|
||||||
while ((totalRead < dataLen) && !done)
|
|
||||||
{
|
|
||||||
off_t cachedBlock = block;
|
|
||||||
|
|
||||||
blockData = (char*)get_block(ns->fd, block, ns->logicalBlkSize[FS_DATA_FORMAT]);
|
blockData = (char *)get_block(ns->fd, block, ns->logicalBlkSize[FS_DATA_FORMAT]);
|
||||||
if (blockData != NULL)
|
if (blockData != NULL) {
|
||||||
{
|
int bytesRead = 0;
|
||||||
int bytesRead = 0;
|
off_t blockBytesRead = 0;
|
||||||
off_t blockBytesRead = 0;
|
vnode node;
|
||||||
vnode node;
|
int initResult;
|
||||||
int initResult;
|
|
||||||
//dprintf("fs_walk - read buffer from disk at LBN %Ld into buffer 0x%x.\n", block, blockData);
|
TRACE(("fs_walk - read buffer from disk at LBN %Ld into buffer 0x%x.\n",
|
||||||
//kernel_debugger("");
|
block, blockData));
|
||||||
|
|
||||||
// Move to the next 2-block set if necessary
|
// Move to the next 2-block set if necessary
|
||||||
// Don't go over end of buffer, if dir record sits on boundary.
|
// Don't go over end of buffer, if dir record sits on boundary.
|
||||||
|
|
||||||
node.fileIDString = NULL;
|
node.fileIDString = NULL;
|
||||||
node.attr.slName = NULL;
|
node.attr.slName = NULL;
|
||||||
|
|
||||||
while (blockBytesRead < 2*ns->logicalBlkSize[FS_DATA_FORMAT] &&
|
while (blockBytesRead < 2*ns->logicalBlkSize[FS_DATA_FORMAT]
|
||||||
(totalRead + blockBytesRead < dataLen) &&
|
&& totalRead + blockBytesRead < dataLen
|
||||||
blockData[0] != 0 &&
|
&& blockData[0] != 0
|
||||||
!done)
|
&& !done)
|
||||||
{
|
{
|
||||||
|
|
||||||
initResult = InitNode(&node, blockData, &bytesRead, ns->joliet_level);
|
initResult = InitNode(&node, blockData, &bytesRead, ns->joliet_level);
|
||||||
//dprintf("fs_walk - InitNode returned %s, filename %s, %d bytes read\n", strerror(initResult), node.fileIDString, bytesRead);
|
TRACE(("fs_walk - InitNode returned %s, filename %s, %d bytes read\n", strerror(initResult), node.fileIDString, bytesRead));
|
||||||
|
|
||||||
if (initResult == B_NO_ERROR)
|
if (initResult == B_NO_ERROR) {
|
||||||
{
|
if (strlen(node.fileIDString) == strlen(file)
|
||||||
if ((strlen(node.fileIDString) == strlen(file)) &&
|
&& !strncmp(node.fileIDString, file, strlen(file)))
|
||||||
!strncmp(node.fileIDString, file, strlen(file)))
|
|
||||||
{
|
{
|
||||||
//dprintf("fs_walk - success, found vnode at block %Ld, pos %Ld\n", block, blockBytesRead);
|
TRACE(("fs_walk - success, found vnode at block %Ld, pos %Ld\n", block, blockBytesRead));
|
||||||
*vnid = (block << 30) + (blockBytesRead & 0xFFFFFFFF);
|
*vnid = (block << 30) + (blockBytesRead & 0xFFFFFFFF);
|
||||||
//dprintf("fs_walk - New vnode id is %Ld\n", *vnid);
|
TRACE(("fs_walk - New vnode id is %Ld\n", *vnid));
|
||||||
if (get_vnode(ns->id,*vnid,(void **)&newNode) != 0)
|
|
||||||
|
if (get_vnode(ns->id, *vnid, (void **)&newNode) != 0)
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
newNode->parID = baseNode->id;
|
newNode->parID = baseNode->id;
|
||||||
done = TRUE;
|
done = TRUE;
|
||||||
result = B_NO_ERROR;
|
result = B_NO_ERROR;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (node.fileIDString != NULL) {
|
||||||
{
|
|
||||||
if (node.fileIDString != NULL)
|
|
||||||
{
|
|
||||||
free(node.fileIDString);
|
free(node.fileIDString);
|
||||||
node.fileIDString = NULL;
|
node.fileIDString = NULL;
|
||||||
}
|
}
|
||||||
if (node.attr.slName != NULL)
|
if (node.attr.slName != NULL) {
|
||||||
{
|
|
||||||
free(node.attr.slName);
|
free(node.attr.slName);
|
||||||
node.attr.slName = NULL;
|
node.attr.slName = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
result = initResult;
|
result = initResult;
|
||||||
if (bytesRead == 0) done = TRUE;
|
if (bytesRead == 0)
|
||||||
|
done = TRUE;
|
||||||
}
|
}
|
||||||
blockData += bytesRead;
|
blockData += bytesRead;
|
||||||
blockBytesRead += bytesRead;
|
blockBytesRead += bytesRead;
|
||||||
//dprintf("fs_walk - Adding %d bytes to blockBytes read (total %Ld/%Ld).\n", bytesRead, blockBytesRead, baseNode->dataLen[FS_DATA_FORMAT]);
|
|
||||||
|
TRACE(("fs_walk - Adding %d bytes to blockBytes read (total %Ld/%Ld).\n",
|
||||||
|
bytesRead, blockBytesRead, baseNode->dataLen[FS_DATA_FORMAT]));
|
||||||
}
|
}
|
||||||
totalRead += ns->logicalBlkSize[FS_DATA_FORMAT];
|
totalRead += ns->logicalBlkSize[FS_DATA_FORMAT];
|
||||||
block++;
|
block++;
|
||||||
//dprintf("fs_walk - moving to next block %Ld, total read %Ld\n", block, totalRead);
|
|
||||||
|
TRACE(("fs_walk - moving to next block %Ld, total read %Ld\n", block, totalRead));
|
||||||
release_block(ns->fd, cachedBlock);
|
release_block(ns->fd, cachedBlock);
|
||||||
|
|
||||||
}
|
} else
|
||||||
else done = TRUE;
|
done = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if vnode is a symbolic link. If so, fill in the newpath variable
|
// Check to see if vnode is a symbolic link. If so, fill in the newpath variable
|
||||||
// with the path to the real file, and call put_vnode.
|
// with the path to the real file, and call put_vnode.
|
||||||
if (newNode != NULL)
|
if (newNode != NULL) {
|
||||||
{
|
if (S_ISLNK(newNode->attr.stat[FS_DATA_FORMAT].st_mode) && newpath != NULL) {
|
||||||
if ( S_ISLNK(newNode->attr.stat[FS_DATA_FORMAT].st_mode) && newpath != NULL)
|
TRACE(("fs_walk - symbolic link file \'%s\' requested.\n", newNode->attr.slName));
|
||||||
{
|
|
||||||
//dprintf ("fs_walk - symbolic link file \'%s\' requested.\n", newNode->attr.slName);
|
|
||||||
result = new_path(newNode->attr.slName, newpath);
|
result = new_path(newNode->attr.slName, newpath);
|
||||||
//dprintf ("fs_walk - putting vnode.\n");
|
|
||||||
put_vnode(ns->id, *vnid);
|
put_vnode(ns->id, *vnid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//dprintf("fs_walk - EXIT, result is %s, vnid is %Lu\n", strerror(result), *vnid);
|
TRACE(("fs_walk - EXIT, result is %s, vnid is %Lu\n", strerror(result), *vnid));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// fs_read_vnode - Using vnode id, read in vnode information into fs-specific struct,
|
|
||||||
// and return it in node. the reenter flag tells you if this function
|
|
||||||
// is being called via some other fs routine, so that things like
|
|
||||||
// double-locking can be avoided.
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fs_read_vnode(void *_ns, vnode_id vnid, char reenter, void **node)
|
fs_read_vnode(void *_ns, vnode_id vnid, char reenter, void **node)
|
||||||
{
|
{
|
||||||
@@ -457,40 +444,41 @@ fs_read_vnode(void *_ns, vnode_id vnid, char reenter, void **node)
|
|||||||
pos = (vnid & 0x3FFFFFFF);
|
pos = (vnid & 0x3FFFFFFF);
|
||||||
block = (vnid >> 30);
|
block = (vnid >> 30);
|
||||||
|
|
||||||
//dprintf("fs_read_vnode - ENTER, block = %ld, pos = %ld, raw = %Lu node 0x%x\n", block, pos, vnid, newNode);
|
TRACE(("fs_read_vnode - ENTER, block = %ld, pos = %ld, raw = %Lu node 0x%x\n",
|
||||||
|
block, pos, vnid, newNode));
|
||||||
if (newNode != NULL)
|
|
||||||
{
|
if (newNode != NULL) {
|
||||||
if (vnid == ISO_ROOTNODE_ID)
|
if (vnid == ISO_ROOTNODE_ID) {
|
||||||
{
|
TRACE(("fs_read_vnode - root node requested.\n"));
|
||||||
//dprintf("fs_read_vnode - root node requested.\n");
|
|
||||||
memcpy(newNode, &(ns->rootDirRec), sizeof(vnode));
|
memcpy(newNode, &(ns->rootDirRec), sizeof(vnode));
|
||||||
*node = (void*)newNode;
|
*node = (void*)newNode;
|
||||||
}
|
} else {
|
||||||
else
|
char *blockData = (char *)get_block(ns->fd, block, ns->logicalBlkSize[FS_DATA_FORMAT]);
|
||||||
{
|
|
||||||
char* blockData = (char*)get_block(ns->fd, block, ns->logicalBlkSize[FS_DATA_FORMAT]);
|
|
||||||
if (pos > ns->logicalBlkSize[FS_DATA_FORMAT]) {
|
if (pos > ns->logicalBlkSize[FS_DATA_FORMAT]) {
|
||||||
if(blockData != NULL) release_block(ns->fd, block);
|
if (blockData != NULL)
|
||||||
|
release_block(ns->fd, block);
|
||||||
|
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
} else if (blockData != NULL) {
|
} else if (blockData != NULL) {
|
||||||
result = InitNode(newNode, blockData + pos, NULL, ns->joliet_level);
|
result = InitNode(newNode, blockData + pos, NULL, ns->joliet_level);
|
||||||
release_block(ns->fd, block);
|
release_block(ns->fd, block);
|
||||||
newNode->id = vnid;
|
newNode->id = vnid;
|
||||||
//dprintf("fs_read_vnode - init result is %s\n", strerror(result));
|
|
||||||
*node = (void*)newNode;
|
TRACE(("fs_read_vnode - init result is %s\n", strerror(result)));
|
||||||
//dprintf("fs_read_vnode - new file %s, size %ld\n", newNode->fileIDString, newNode->dataLen[FS_DATA_FORMAT]);
|
*node = (void *)newNode;
|
||||||
|
TRACE(("fs_read_vnode - new file %s, size %ld\n", newNode->fileIDString, newNode->dataLen[FS_DATA_FORMAT]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else result = ENOMEM;
|
result = ENOMEM;
|
||||||
|
|
||||||
//dprintf("fs_read_vnode - EXIT, result is %s\n", strerror(result));
|
TRACE(("fs_read_vnode - EXIT, result is %s\n", strerror(result)));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fs_write_vnode(void *ns, void *_node, char reenter)
|
fs_write_vnode(void *ns, void *_node, char reenter)
|
||||||
{
|
{
|
||||||
int result = B_NO_ERROR;
|
int result = B_NO_ERROR;
|
||||||
@@ -499,17 +487,20 @@ fs_write_vnode(void *ns, void *_node, char reenter)
|
|||||||
(void)ns;
|
(void)ns;
|
||||||
(void)reenter;
|
(void)reenter;
|
||||||
|
|
||||||
//dprintf("fs_write_vnode - ENTER (0x%x)\n", node);
|
TRACE(("fs_write_vnode - ENTER (0x%x)\n", node));
|
||||||
|
|
||||||
if (node != NULL) {
|
if (node != NULL) {
|
||||||
if (node->id != ISO_ROOTNODE_ID) {
|
if (node->id != ISO_ROOTNODE_ID) {
|
||||||
if (node->fileIDString != NULL)
|
if (node->fileIDString != NULL)
|
||||||
free (node->fileIDString);
|
free (node->fileIDString);
|
||||||
if (node->attr.slName != NULL)
|
if (node->attr.slName != NULL)
|
||||||
free (node->attr.slName);
|
free (node->attr.slName);
|
||||||
|
|
||||||
free(node);
|
free(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//dprintf("fs_write_vnode - EXIT\n");
|
|
||||||
|
TRACE(("fs_write_vnode - EXIT\n"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,7 +513,8 @@ fs_read_stat(void *_ns, void *_node, struct stat *st)
|
|||||||
int result = B_NO_ERROR;
|
int result = B_NO_ERROR;
|
||||||
time_t time;
|
time_t time;
|
||||||
|
|
||||||
//dprintf("fs_rstat - ENTER\n");
|
TRACE(("fs_rstat - ENTER\n"));
|
||||||
|
|
||||||
st->st_dev = ns->id;
|
st->st_dev = ns->id;
|
||||||
st->st_ino = node->id;
|
st->st_ino = node->id;
|
||||||
st->st_nlink = node->attr.stat[FS_DATA_FORMAT].st_nlink;
|
st->st_nlink = node->attr.stat[FS_DATA_FORMAT].st_nlink;
|
||||||
@@ -535,14 +527,13 @@ fs_read_stat(void *_ns, void *_node, struct stat *st)
|
|||||||
st->st_size = node->dataLen[FS_DATA_FORMAT];
|
st->st_size = node->dataLen[FS_DATA_FORMAT];
|
||||||
if (ConvertRecDate(&(node->recordDate), &time) == B_NO_ERROR)
|
if (ConvertRecDate(&(node->recordDate), &time) == B_NO_ERROR)
|
||||||
st->st_ctime = st->st_mtime = st->st_atime = time;
|
st->st_ctime = st->st_mtime = st->st_atime = time;
|
||||||
//dprintf("fs_rstat - EXIT, result is %s\n", strerror(result));
|
|
||||||
|
TRACE(("fs_rstat - EXIT, result is %s\n", strerror(result)));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// fs_open - Create a vnode cookie, if necessary, to use when
|
|
||||||
// reading/writing a file
|
|
||||||
static int
|
static int
|
||||||
fs_open(void *_ns, void *_node, int omode, void **cookie)
|
fs_open(void *_ns, void *_node, int omode, void **cookie)
|
||||||
{
|
{
|
||||||
@@ -560,12 +551,9 @@ fs_open(void *_ns, void *_node, int omode, void **cookie)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fs_read
|
|
||||||
// Read a file specified by node, using information in cookie
|
|
||||||
// and at offset specified by pos. read len bytes into buffer buf.
|
|
||||||
static int
|
static int
|
||||||
fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buf,
|
fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buf, size_t *len)
|
||||||
size_t *len)
|
|
||||||
{
|
{
|
||||||
nspace *ns = (nspace *)_ns; // global stuff
|
nspace *ns = (nspace *)_ns; // global stuff
|
||||||
vnode *node = (vnode *)_node; // The read file vnode.
|
vnode *node = (vnode *)_node; // The read file vnode.
|
||||||
@@ -602,7 +590,7 @@ fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buf,
|
|||||||
startLen = blockSize - blockPos;
|
startLen = blockSize - blockPos;
|
||||||
|
|
||||||
if (blockPos == 0 && reqLen >= blockSize) {
|
if (blockPos == 0 && reqLen >= blockSize) {
|
||||||
//dprintf("Setting startLen to 0, even block read\n");
|
TRACE(("Setting startLen to 0, even block read\n"));
|
||||||
startLen = 0;
|
startLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,7 +633,7 @@ fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buf,
|
|||||||
|
|
||||||
// Read in the middle blocks.
|
// Read in the middle blocks.
|
||||||
if (numBlocks > 0 && result == B_NO_ERROR) {
|
if (numBlocks > 0 && result == B_NO_ERROR) {
|
||||||
//dprintf("fs_read - getting middle blocks\n");
|
TRACE(("fs_read - getting middle blocks\n"));
|
||||||
result = cached_read(ns->fd, startBlock,
|
result = cached_read(ns->fd, startBlock,
|
||||||
((char *)buf) + startLen,
|
((char *)buf) + startLen,
|
||||||
numBlocks,
|
numBlocks,
|
||||||
@@ -668,13 +656,11 @@ fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buf,
|
|||||||
result = EIO;
|
result = EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
//dprintf("fs_read - EXIT, result is %s\n", strerror(result));
|
TRACE(("fs_read - EXIT, result is %s\n", strerror(result)));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// fs_close - Do whatever is necessary to close a file, EXCEPT for freeing
|
|
||||||
// the cookie!
|
|
||||||
static int
|
static int
|
||||||
fs_close(void *ns, void *node, void *cookie)
|
fs_close(void *ns, void *node, void *cookie)
|
||||||
{
|
{
|
||||||
@@ -743,16 +729,14 @@ fs_read_link(void *_ns, void *_node, char *buffer, size_t *_bufferSize)
|
|||||||
static int
|
static int
|
||||||
fs_open_dir(void *_ns, void *_node, void **cookie)
|
fs_open_dir(void *_ns, void *_node, void **cookie)
|
||||||
{
|
{
|
||||||
// creates fs-specific "cookie" struct that keeps track of where
|
|
||||||
// you are at in reading through directory entries in fs_readdir.
|
|
||||||
|
|
||||||
vnode *node = (vnode *)_node;
|
vnode *node = (vnode *)_node;
|
||||||
int result = B_NO_ERROR;
|
int result = B_NO_ERROR;
|
||||||
dircookie *dirCookie = (dircookie *)malloc(sizeof(dircookie));
|
dircookie *dirCookie = (dircookie *)malloc(sizeof(dircookie));
|
||||||
|
|
||||||
(void)_ns;
|
(void)_ns;
|
||||||
|
|
||||||
//dprintf("fs_opendir - ENTER, node is 0x%x\n", _node);
|
TRACE(("fs_opendir - ENTER, node is 0x%x\n", _node));
|
||||||
|
|
||||||
if (!(node->flags & ISO_ISDIR))
|
if (!(node->flags & ISO_ISDIR))
|
||||||
result = EMFILE;
|
result = EMFILE;
|
||||||
|
|
||||||
@@ -766,7 +750,7 @@ fs_open_dir(void *_ns, void *_node, void **cookie)
|
|||||||
} else
|
} else
|
||||||
result = ENOMEM;
|
result = ENOMEM;
|
||||||
|
|
||||||
//dprintf("fs_opendir - EXIT\n");
|
TRACE(("fs_opendir - EXIT\n"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -781,7 +765,8 @@ fs_read_dir(void *_ns, void *_node, void *_cookie, long *num,
|
|||||||
|
|
||||||
(void)_node;
|
(void)_node;
|
||||||
|
|
||||||
//dprintf("fs_readdir - ENTER\n");
|
TRACE(("fs_readdir - ENTER\n"));
|
||||||
|
|
||||||
result = ISOReadDirEnt(ns, dirCookie, buffer, bufferSize);
|
result = ISOReadDirEnt(ns, dirCookie, buffer, bufferSize);
|
||||||
|
|
||||||
// If we succeeded, return 1, the number of dirents we read.
|
// If we succeeded, return 1, the number of dirents we read.
|
||||||
@@ -796,7 +781,7 @@ fs_read_dir(void *_ns, void *_node, void *_cookie, long *num,
|
|||||||
if (result == ENOENT)
|
if (result == ENOENT)
|
||||||
result = B_NO_ERROR;
|
result = B_NO_ERROR;
|
||||||
|
|
||||||
//dprintf("fs_readdir - EXIT, result is %s\n", strerror(result));
|
TRACE(("fs_readdir - EXIT, result is %s\n", strerror(result)));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user