Initial checkin. Currently does nothing particularly useful.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3114 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder 2003-04-28 22:47:29 +00:00
parent 70eaa1f5b5
commit 29008bcfd8
2 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,68 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
// Mad props to Axel Dörfler and his BFS implementation, from which
// this UDF implementation draws much influence (and a little code :-P).
//----------------------------------------------------------------------
#include "Volume.h"
#include "Block.h"
#include "Debug.h"
using namespace UDF;
//----------------------------------------------------------------------
// Volume
//----------------------------------------------------------------------
/*! \brief Creates an unmounted volume with the given id.
*/
Volume::Volume(nspace_id id)
: fID(id)
, fDevice(0)
, fReadOnly(false)
{
}
status_t
Volume::Identify(int device, off_t base)
{
return B_ERROR;
}
/*! \brief Attempts to mount the given device.
*/
status_t
Volume::Mount(const char *deviceName, uint32 flags)
{
if (!deviceName)
RETURN_ERROR(B_BAD_VALUE);
fReadOnly = flags & B_READ_ONLY;
// Open the device, trying read only if readwrite fails
fDevice = open(deviceName, fReadOnly ? O_RDONLY : O_RDWR);
if (fDevice < B_OK && !fReadOnly) {
fReadOnly = true;
fDevice = open(deviceName, O_RDONLY);
}
if (fDevice < B_OK)
RETURN_ERROR(fDevice);
// If the device is actually a normal file, try to disable the cache
// for the file in the parent filesystem
struct stat stat;
status_t err = fstat(fDevice, &stat) < 0 ? B_OK : B_ERROR;
if (!err) {
if (stat.st_mode & S_IFREG && ioctl(fDevice, IOCTL_FILE_UNCACHED_IO, NULL) < 0) {
// Probably should die some sort of painful death here.
}
}
// Now identify the volume
return B_ERROR;
}

View File

@ -0,0 +1,55 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//
// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
// Mad props to Axel Dörfler and his BFS implementation, from which
// this UDF implementation draws much influence (and a little code :-P).
//---------------------------------------------------------------------
#ifndef _UDF_VOLUME_H
#define _UDF_VOLUME_H
/*! \file Volume.h
*/
#include <KernelExport.h>
extern "C" {
#ifndef _IMPEXP_KERNEL
# define _IMPEXP_KERNEL
#endif
#include <fsproto.h>
}
#include "cpp.h"
namespace UDF {
class Volume {
public:
Volume(nspace_id id);
static status_t Identify(int device) { return Identify(device, 0); }
static status_t Identify(int device, off_t base);
status_t Mount(const char *deviceName, uint32 flags);
status_t Unmount();
nspace_id GetID() { return fID; }
const char *Name() const;
int Device() const { return fDevice; }
bool IsReadOnly() const { return fReadOnly; }
vnode_id ToVnodeID(off_t block) const { return (vnode_id)block; }
private:
nspace_id fID;
int fDevice;
bool fReadOnly;
};
}; // namespace UDF
#endif // _UDF_VOLUME_H