56 lines
933 B
C++
56 lines
933 B
C++
|
|
// vfs.cpp
|
|
// Author: Josh Holtrop
|
|
// Date: 03/11/04
|
|
// Modified: 04/16/04
|
|
|
|
#include "hos_defines.h"
|
|
#include "vfs.h"
|
|
//#include "fs/vfat.h"
|
|
//#include "block/rd.h"
|
|
//#include "block/loop.h"
|
|
#include "lang/LinkedList.h"
|
|
#include "lang/string.h"
|
|
#include "devfs.h"
|
|
#include "kio.h"
|
|
#include "Mount.h"
|
|
|
|
LinkedList<Mount> *mounts;
|
|
|
|
void vfs_init()
|
|
{
|
|
|
|
mounts = new LinkedList<Mount>;
|
|
|
|
}
|
|
|
|
|
|
void list()
|
|
{
|
|
LinkedList<Mount>::iterator it = mounts->begin();
|
|
while (it != mounts->end())
|
|
{
|
|
printf("%s\t%s\n", (*it).device.data(), (*it).mountPoint.data());
|
|
++it;
|
|
}
|
|
}
|
|
|
|
|
|
int vfs_mount(string device, string mountPoint)
|
|
{
|
|
Mount mount(device, mountPoint);
|
|
LinkedList<Mount>::iterator it = mounts->begin();
|
|
int i = 0;
|
|
while (it != mounts->end() && (*it).mountPoint <= mount.mountPoint)
|
|
{
|
|
if (*it == mount)
|
|
return 1; //device already mounted or mount point already taken
|
|
i++;
|
|
++it;
|
|
}
|
|
mounts->insert(i, mount);
|
|
return 0;
|
|
}
|
|
|
|
|