Skip to content

Commit

Permalink
devfs: stat() for root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Oct 4, 2024
1 parent 131c6a1 commit 0754f2e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion fs/devfs/src/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,24 @@ void devfsStat(SyscallHeader *req, SyscallHeader *res) {
memcpy(res, req, req->header.length);

res->header.response = 1;
StatCommand *response = (StatCommand *) res;

if((strlen(cmd->path) == 1) && (cmd->path[0] == '/')) {
// /dev is owned by root:root, rwxr-xr-x
response->header.header.status = 0;
response->buffer.st_mode = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
response->buffer.st_uid = 0;
response->buffer.st_gid = 0;
response->buffer.st_size = deviceCount;
luxSendDependency(response);

return;
}

DeviceFile *dev = findDevice(cmd->path);
if(!dev) {
res->header.status = -ENOENT; // file doesn't exist
} else {
StatCommand *response = (StatCommand *) res;
response->header.header.status = 0;
memcpy(&response->buffer, &dev->status, sizeof(struct stat));
}
Expand Down

0 comments on commit 0754f2e

Please sign in to comment.