Import backup from 2004-06-12
This commit is contained in:
1 parent
9a8d2c29cb
commit
c76725eac3
10 files changed
+224
-185
No files matched your search
+17
-6
@@ -13,23 +13,26 @@
|
||||
|
||||
Device::Device()
|
||||
{
|
||||
major = minor = permissions = type = 0;
|
||||
uid = gid = major = minor = permissions = type = 0;
|
||||
}
|
||||
|
||||
Device::Device(string aname)
|
||||
{
|
||||
major = minor = permissions = type = 0;
|
||||
uid = gid = major = minor = permissions = type = 0;
|
||||
name = aname;
|
||||
}
|
||||
|
||||
//Types:
|
||||
// h = hard link (. and .. only)
|
||||
// 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)
|
||||
Device::Device(string aname, dword auid, dword agid, dword amajor, dword aminor, char atype, word apermissions)
|
||||
{
|
||||
name = aname;
|
||||
uid = auid;
|
||||
gid = agid;
|
||||
permissions = apermissions;
|
||||
type = atype;
|
||||
switch (type)
|
||||
@@ -37,13 +40,14 @@ Device::Device(string aname, dword amajor, dword aminor, char atype, word apermi
|
||||
case 'd':
|
||||
folder = new DeviceFolder();
|
||||
break;
|
||||
case 'l':
|
||||
break;
|
||||
case 'b':
|
||||
case 'c':
|
||||
major = amajor;
|
||||
minor = aminor;
|
||||
break;
|
||||
case 'l':
|
||||
case 'h':
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +56,7 @@ Device::~Device()
|
||||
switch (type)
|
||||
{
|
||||
case 'l':
|
||||
case 'h':
|
||||
delete link;
|
||||
break;
|
||||
case 'd':
|
||||
@@ -63,6 +68,8 @@ Device::~Device()
|
||||
Device::Device(const Device & orig)
|
||||
{
|
||||
name = orig.name;
|
||||
uid = orig.uid;
|
||||
gid = orig.gid;
|
||||
permissions = orig.permissions;
|
||||
type = orig.type;
|
||||
switch (type)
|
||||
@@ -74,6 +81,7 @@ Device::Device(const Device & orig)
|
||||
minor = orig.minor;
|
||||
break;
|
||||
case 'l':
|
||||
case 'h':
|
||||
link = new string(*orig.link);
|
||||
break;
|
||||
case 'd':
|
||||
@@ -88,6 +96,8 @@ Device & Device::operator=(const Device & orig)
|
||||
{
|
||||
this->~Device();
|
||||
name = orig.name;
|
||||
uid = orig.uid;
|
||||
gid = orig.gid;
|
||||
permissions = orig.permissions;
|
||||
type = orig.type;
|
||||
switch (type)
|
||||
@@ -99,6 +109,7 @@ Device & Device::operator=(const Device & orig)
|
||||
minor = orig.minor;
|
||||
break;
|
||||
case 'l':
|
||||
case 'h':
|
||||
link = new string(*orig.link);
|
||||
break;
|
||||
case 'd':
|
||||
@@ -111,7 +122,7 @@ Device & Device::operator=(const Device & orig)
|
||||
|
||||
void Device::setLink(string alink)
|
||||
{
|
||||
if (type == 'l')
|
||||
if (type == 'l' || type == 'h')
|
||||
link = new string(alink);
|
||||
}
|
||||
|
||||
+3
-1
@@ -28,13 +28,15 @@ public:
|
||||
void *folder;
|
||||
string *link;
|
||||
};
|
||||
dword uid;
|
||||
dword gid;
|
||||
dword minor;
|
||||
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(string aname, dword auid, dword agid, dword amajor, dword aminor, char atype, word apermissions);
|
||||
Device(const Device & orig);
|
||||
~Device();
|
||||
Device & operator=(const Device & orig);
|
||||
|
||||
+13
-12
@@ -18,15 +18,16 @@ void DeviceFolder::ls()
|
||||
{
|
||||
printf("%c", (*it).type);
|
||||
const char *bitmask = "rwxrwxrwx";
|
||||
for (dword mask = 0x100; mask; mask = mask >> 1)
|
||||
int i = 0;
|
||||
for (dword mask = 0x100; mask; mask >>= 1)
|
||||
{
|
||||
if ((*it).permissions & mask)
|
||||
printf("%c", *bitmask);
|
||||
printf("%c", bitmask[i]);
|
||||
else
|
||||
printf("-");
|
||||
bitmask++;
|
||||
i++;
|
||||
}
|
||||
printf("\t");
|
||||
printf("\t%d\t%d\t", (*it).uid, (*it).gid);
|
||||
switch ((*it).type)
|
||||
{
|
||||
case 'b':
|
||||
@@ -45,8 +46,9 @@ void DeviceFolder::ls()
|
||||
}
|
||||
}
|
||||
|
||||
DeviceFolder::DeviceFolder()
|
||||
DeviceFolder::DeviceFolder(string location)
|
||||
{
|
||||
//initialize . and .. here
|
||||
}
|
||||
|
||||
int DeviceFolder::addDevice(Device dev)
|
||||
@@ -65,23 +67,22 @@ int DeviceFolder::addDevice(Device dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DeviceFolder::mkdir(string name, word permissions)
|
||||
int DeviceFolder::mkdir(string name, dword uid, dword gid, word permissions)
|
||||
{
|
||||
Device dev(name, 0, 0, 'd', permissions);
|
||||
Device dev(name, uid, gid, 0, 0, 'd', permissions);
|
||||
return addDevice(dev);
|
||||
}
|
||||
|
||||
int DeviceFolder::mklink(string name, string link)
|
||||
int DeviceFolder::mklink(string name, dword uid, dword gid, string link)
|
||||
{
|
||||
Device dev(name, 0, 0, 'l', 0777);
|
||||
Device dev(name, uid, gid, 0, 0, 'l', 0777);
|
||||
dev.setLink(link);
|
||||
return addDevice(dev);
|
||||
}
|
||||
|
||||
int DeviceFolder::mknod(string name, dword major, dword minor, char type, word permissions)
|
||||
int DeviceFolder::mknod(string name, dword uid, dword gid, dword major, dword minor, char type, word permissions)
|
||||
{
|
||||
Device dev(name, major, minor, type, permissions);
|
||||
printf("Well, we got here successfully.\n");
|
||||
Device dev(name, uid, gid, major, minor, type, permissions);
|
||||
return addDevice(dev);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ private:
|
||||
LinkedList<Device> devices;
|
||||
int addDevice(Device name);
|
||||
public:
|
||||
DeviceFolder();
|
||||
DeviceFolder(string location);
|
||||
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);
|
||||
int mkdir(string name, dword uid, dword gid, word permissions);
|
||||
int mklink(string name, dword uid, dword gid, string link);
|
||||
int mknod(string name, dword uid, dword gid, dword major, dword minor, char type, word permissions);
|
||||
void ls();
|
||||
};
|
||||
|
||||
|
||||
+8
-10
@@ -15,17 +15,15 @@ DeviceFolder *dev;
|
||||
void devfs_init(string mountPoint)
|
||||
{
|
||||
printf("I'm going to make a new DeviceFolder\n");
|
||||
dev = new DeviceFolder();
|
||||
printf("I'm going to make a new Device\n");
|
||||
Device device("aDevice", 3, 1, 'b', 0644);
|
||||
dev = new DeviceFolder(mountPoint);
|
||||
printf("I'm going to add hda1 to devfs\n");
|
||||
dev->mknod("hda1", 3, 1, 'b', 0632);
|
||||
/* dev->mkdir("test", 0644);
|
||||
dev->mkdir("test1", 0755);
|
||||
dev->mkdir("test1", 0644);
|
||||
dev->mknod("psmouse", 4, 1, 'c', 0677);
|
||||
dev->mklink("root", "hda1");
|
||||
*/
|
||||
dev->mknod("hda1", 0, 0, 3, 1, 'b', 0632);
|
||||
dev->mkdir("test", 0, 501, 0644);
|
||||
dev->mkdir("test1", 0, 0, 0755);
|
||||
dev->mkdir("test1", 1, 1, 0644);
|
||||
dev->mknod("psmouse", 2, 3, 4, 1, 'c', 0677);
|
||||
dev->mklink("root", 5, 6, "hda1");
|
||||
|
||||
printf("I'm going to list the devices i know about:\n");
|
||||
dev->ls();
|
||||
// vfs_mount("devfs", mountPoint, 0755, 0, 0);
|
||||
|
||||
Reference in new issue
Block a user