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:
+21
-18
@@ -1,32 +1,35 @@
|
|||||||
/* safemode.c - tells if safemode is active
|
/*
|
||||||
* (c) 2004, Jérôme DUVAL for Haiku
|
* (c) 2004, Jérôme DUVAL for Haiku
|
||||||
* released under the MIT licence.
|
* released under the MIT licence.
|
||||||
*
|
*
|
||||||
* ChangeLog:
|
|
||||||
* 08-29-2004 v1.0
|
|
||||||
* Initial.
|
|
||||||
*
|
|
||||||
* safemode
|
* safemode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <strings.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;
|
char buffer[B_FILE_NAME_LENGTH];
|
||||||
uint32 p2 = 1;
|
size_t size = sizeof(buffer);
|
||||||
status_t err;
|
|
||||||
|
status_t status = _kern_get_safemode_option("safemode", buffer, &size);
|
||||||
err = _kget_safemode_option_("safemode", &p1, &p2);
|
if (status == B_OK) {
|
||||||
if (err == B_OK) {
|
if (!strncasecmp(buffer, "true", size)
|
||||||
printf("yes\n");
|
|| !strncasecmp(buffer, "yes", size)
|
||||||
} else
|
|| !strncasecmp(buffer, "on", size)
|
||||||
printf("no\n");
|
|| !strncasecmp(buffer, "enabled", size)) {
|
||||||
|
puts("yes");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
puts("no");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user