Import backup from 2004-06-09

This commit is contained in:
josh committed 2017-07-25 22:23:47 -04:00
1 parent fdf6b71a91
commit b54b8191c4
11 files changed
+469 -117

No files matched your search

+63 -3
View File
@@ -3,7 +3,7 @@
// Device object for use in devfs
// Author: Josh Holtrop
// Date: 06/03/04
// Modified: 06/08/04
// Modified: 06/09/04
#include "Device.h"
#include "DeviceFolder.h"
@@ -13,12 +13,12 @@
Device::Device()
{
major = minor = permissions = 0;
major = minor = permissions = type = 0;
}
Device::Device(string aname)
{
major = minor = permissions = 0;
major = minor = permissions = type = 0;
name = aname;
}
@@ -46,6 +46,66 @@ Device::Device(string aname, dword amajor, dword aminor, char atype, word apermi
break;
}
}
Device::Device(const Device & orig)
{
minor = orig.minor;
permissions = orig.permissions;
type = orig.type;
switch (type)
{
case 'b':
case 'c':
default:
major = orig.major;
break;
case 'l':
link = new string(*orig.link);
break;
case 'd':
folder = new DeviceFolder(*(DeviceFolder *)orig.folder);
break;
}
}
Device::~Device()
{
switch (type)
{
case 'l':
delete link;
break;
case 'd':
delete (DeviceFolder *)folder;
break;
}
}
Device & Device::operator=(const Device & orig)
{
if (&orig != this)
{
this->~Device();
permissions = orig.permissions;
type = orig.type;
switch (type)
{
case 'b':
case 'c':
default:
major = orig.major;
minor = orig.minor;
break;
case 'l':
link = new string(*orig.link);
break;
case 'd':
folder = new DeviceFolder(*(DeviceFolder *)orig.folder);
break;
}
}
return *this;
}
void Device::setLink(string alink)
{
+6 -3
View File
@@ -29,12 +29,15 @@ public:
string *link;
};
dword minor;
word permissions;
char type;
word permissions; //0644 or similar
char type; //'b', 'c', 'l', 'd'
Device();
Device(string aname);
Device(string aname, dword amajor, dword aminor, char atype, word apermissions);
Device(const Device & orig);
~Device();
Device & operator=(const Device & orig);
void setLink(string alink);
};
+58 -6
View File
@@ -3,38 +3,90 @@
// DeviceFolder object for use in devfs
// Author: Josh Holtrop
// Date: 06/03/04
// Modified: 06/03/04
// Modified: 06/09/04
#include "DeviceFolder.h"
#include "Device.h"
#include "lang/LinkedList.h"
#include "kio.h"
void DeviceFolder::ls()
{
LinkedList<Device>::iterator it = devices.begin();
while (it != devices.end())
{
printf("%c", (*it).type);
const char *bitmask = "rwxrwxrwx";
for (dword mask = 0x100; mask; mask = mask >> 1)
{
if ((*it).permissions & mask)
printf("%c", *bitmask);
else
printf("-");
bitmask++;
}
printf("\t");
switch ((*it).type)
{
case 'b':
case 'c':
default:
printf("%d, %d\t%s\n", (*it).major, (*it).minor, (*it).name.data());
break;
case 'd':
printf("\t%s/\n", (*it).name.data());
break;
case 'l':
printf("\t%s -> %s\n", (*it).name.data(), (*it).link->data());
break;
}
it++;
}
}
DeviceFolder::DeviceFolder()
{
}
int Device::addDevice(Device dev)
int DeviceFolder::addDevice(Device dev)
{
int i = 0;
LinkedList<Device>::iterator it = devices.begin();
while ((*it).name < dev.name && it != devices.end())
{
it++;
i++;
}
if (it != devices.end())
if ((*it).name == dev.name)
return 1; //name conflict
devices.insert(i, dev);
return 0;
}
int Device::mkdir(string name, word permissions)
int DeviceFolder::mkdir(string name, word permissions)
{
Device dev(name, 0, 0, 'd', permissions);
return addDevice(dev);
}
int Device::mklink(string name, string link)
int DeviceFolder::mklink(string name, string link)
{
Device dev(name, 0, 0, 'l', 0777);
dev.setLink(link);
return addDevice(dev);
}
int Device::mknod(string name, dword major, dword minor, char type, word permissions)
int DeviceFolder::mknod(string name, dword major, dword minor, char type, word permissions)
{
Device dev(name, major, minor, type, permissions);
return addDevice(dev);
}
int DeviceFolder::size()
{
return devices.size();
}
+4 -1
View File
@@ -3,13 +3,14 @@
// DeviceFolder object for use in devfs
// Author: Josh Holtrop
// Date: 06/03/04
// Modified: 06/03/04
// Modified: 06/09/04
#ifndef __HOS_DEVICEFOLDER__
#define __HOS_DEVICEFOLDER__ __HOS_DEVICEFOLDER__
#include "lang/LinkedList.h"
#include "Device.h"
#include "kio.h"
class DeviceFolder
{
@@ -18,9 +19,11 @@ private:
int addDevice(Device name);
public:
DeviceFolder();
int size();
int mkdir(string name, word permissions);
int mklink(string name, string link);
int mknod(string name, dword major, dword minor, char type, word permissions);
void ls();
};
#endif
+7
View File
@@ -15,6 +15,13 @@ DeviceFolder *dev;
void devfs_init(string mountPoint)
{
dev = new DeviceFolder();
/* dev->mkdir("test", 0644);
dev->mkdir("test1", 0755);
dev->mkdir("test1", 0644);
dev->mknod("hda1", 3, 1, 'b', 0632);
dev->mknod("psmouse", 4, 1, 'c', 0677);
dev->mklink("root", "hda1");
*/ dev->ls();
// vfs_mount("devfs", mountPoint, 0755, 0, 0);
}
+2 -2
View File
@@ -19,8 +19,8 @@
void vfs_init()
{
//mntList = new LinkedList<Mount>;
printf("%u\n", sizeof(Device));
printf("%u\n", sizeof(DeviceFolder));
devfs_init("/dev");
}