1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:07:34 +00:00

Add SpinLock to IDE disk access.

This forces serialization of accesses. This driver needs to be redesigned.
This commit is contained in:
Andreas Kling 2018-10-31 21:31:56 +01:00
parent dec5683e9c
commit 8f6998c902
7 changed files with 57 additions and 13 deletions

View file

@ -5,6 +5,8 @@
#include <sys/mman.h>
#include <AK/String.h>
extern "C" {
struct passwd_with_strings : public passwd {
char name_buffer[256];
char passwd_buffer[256];
@ -24,6 +26,10 @@ void setpwent()
rewind(__pwdb_stream);
} else {
__pwdb_stream = fopen("/etc/passwd", "r");
if (!__pwdb_stream) {
perror("open /etc/passwd");
}
assert(__pwdb_stream);
__pwdb_entry = (struct passwd_with_strings*)mmap(nullptr, getpagesize());
set_mmap_name(__pwdb_entry, getpagesize(), "setpwent");
}
@ -67,6 +73,7 @@ struct passwd* getpwent()
if (!__pwdb_stream)
setpwent();
assert(__pwdb_stream);
if (feof(__pwdb_stream))
return nullptr;
@ -76,6 +83,7 @@ next_entry:
char* s = fgets(buffer, sizeof(buffer), __pwdb_stream);
if (!s)
return nullptr;
assert(__pwdb_stream);
if (feof(__pwdb_stream))
return nullptr;
String line(s);
@ -116,3 +124,5 @@ next_entry:
strncpy(__pwdb_entry->shell_buffer, e_shell.characters(), e_shell.length());
return __pwdb_entry;
}
}