Ported over safemode to our kernel.

_kern_get_safemode_option() just returns the driver_settings parameter
string, so it has to be evaluated by the caller.
Also, "safemode" returns 1 if safemode is enabled.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10236 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-11-25 18:34:45 +00:00
parent fa2c0f885f
commit 9b9e67a199

View File

@ -1,32 +1,35 @@
/* safemode.c - tells if safemode is active
/*
* (c) 2004, Jérôme DUVAL for Haiku
* released under the MIT licence.
*
* ChangeLog:
* 08-29-2004 v1.0
* Initial.
*
* safemode
*/
#include <syscalls.h>
#include <stdio.h>
#include <strings.h>
#include <SupportDefs.h>
// i don't know the exact signature but this one works
extern status_t _kget_safemode_option_(char* name, uint8 *p1, uint32 *p2);
int main(int argc, char **argv)
int
main(int argc, char **argv)
{
uint8 p1;
uint32 p2 = 1;
status_t err;
err = _kget_safemode_option_("safemode", &p1, &p2);
if (err == B_OK) {
printf("yes\n");
} else
printf("no\n");
char buffer[B_FILE_NAME_LENGTH];
size_t size = sizeof(buffer);
status_t status = _kern_get_safemode_option("safemode", buffer, &size);
if (status == B_OK) {
if (!strncasecmp(buffer, "true", size)
|| !strncasecmp(buffer, "yes", size)
|| !strncasecmp(buffer, "on", size)
|| !strncasecmp(buffer, "enabled", size)) {
puts("yes");
return 1;
}
}
puts("no");
return 0;
}