BuildSystem: Cleanup userspace directory layout
userspace programs are now in userspace/programs userspace tests are now in userspace/tests This makes listing userspace projects much cleaner. Libraries were already separated to their own directory, so other programs should also.
This commit is contained in:
8
userspace/programs/sync/CMakeLists.txt
Normal file
8
userspace/programs/sync/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(sync ${SOURCES})
|
||||
banan_link_library(sync libc)
|
||||
|
||||
install(TARGETS sync OPTIONAL)
|
||||
29
userspace/programs/sync/main.cpp
Normal file
29
userspace/programs/sync/main.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void usage(int ret, char* cmd)
|
||||
{
|
||||
FILE* fout = (ret == 0) ? stdout : stderr;
|
||||
fprintf(fout, "usage: %s [OPTION]...\n", cmd);
|
||||
fprintf(fout, "Tells the kernel to start a disk sync as soon as possible\n");
|
||||
fprintf(fout, " -b, --block return only after sync is complete\n");
|
||||
fprintf(fout, " -h, --help show this message and exit\n");
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
bool block = false;
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "--block") == 0)
|
||||
block = true;
|
||||
else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
||||
usage(0, argv[0]);
|
||||
else
|
||||
usage(1, argv[0]);
|
||||
}
|
||||
syncsync(block);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user