hos/kernel/fs/Device.cpp

56 lines
894 B
C++

// Device.cpp
// Device object for use in devfs
// Author: Josh Holtrop
// Date: 06/03/04
// Modified: 06/08/04
#include "Device.h"
#include "DeviceFolder.h"
#include "hos_defines.h"
#include "lang/string.h"
Device::Device()
{
major = minor = permissions = 0;
}
Device::Device(string aname)
{
major = minor = permissions = 0;
name = aname;
}
//Types:
// l = link, call setLink()
// d = directory, automatically initializes a new DeviceFolder object
// b = block device
// c = char device
Device::Device(string aname, dword amajor, dword aminor, char atype, word apermissions)
{
name = aname;
permissions = apermissions;
type = atype;
switch (type)
{
case 'd':
folder = new DeviceFolder();
break;
case 'l':
break;
case 'b':
case 'c':
major = amajor;
minor = aminor;
break;
}
}
void Device::setLink(string alink)
{
if (type == 'l')
link = new string(alink);
}