diff --git a/.gitignore b/.gitignore index ad76d2ab..9f86dbcb 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ programs/cpuid/cpuid programs/args/args programs/shutdown/shutdown programs/reboot/reboot +programs/stat/stat programs/dist/ \ No newline at end of file diff --git a/programs/Makefile b/programs/Makefile index 6888e116..255c9dee 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -41,7 +41,10 @@ shutdown: force_look tlib/libtlib.a args: force_look tlib/libtlib.a cd args; $(MAKE) args -dist: one hello long loop longone longtwo keyboard tsh cpuid shutdown reboot args +stat: force_look tlib/libtlib.a + cd stat; $(MAKE) stat + +dist: one hello long loop longone longtwo keyboard tsh cpuid shutdown reboot args stat mkdir -p dist cp one/a.out dist/one cp hello/a.out dist/hello @@ -55,6 +58,7 @@ dist: one hello long loop longone longtwo keyboard tsh cpuid shutdown reboot arg cp reboot/reboot dist/ cp shutdown/shutdown dist/ cp args/args dist/ + cp stat/stat dist/ strip dist/* force_look: @@ -73,4 +77,5 @@ clean: cd reboot; $(MAKE) clean cd shutdown; $(MAKE) clean cd args; $(MAKE) clean + cd stat; $(MAKE) clean rm -rf dist diff --git a/programs/stat/Makefile b/programs/stat/Makefile new file mode 100644 index 00000000..05454106 --- /dev/null +++ b/programs/stat/Makefile @@ -0,0 +1,15 @@ +.PHONY: default clean + +default: stat + +include ../../cpp.mk + +%.cpp.o: src/%.cpp + $(CC) -c $< -o $@ $(PROGRAM_FLAGS) + +stat: main.cpp.o + $(CC) -o stat main.cpp.o $(PROGRAM_LINK_FLAGS) + +clean: + rm -f *.cpp.o + rm -rf stat diff --git a/programs/stat/reboot b/programs/stat/reboot new file mode 100755 index 00000000..31f5bfb9 Binary files /dev/null and b/programs/stat/reboot differ diff --git a/programs/stat/src/main.cpp b/programs/stat/src/main.cpp new file mode 100644 index 00000000..1d5692ce --- /dev/null +++ b/programs/stat/src/main.cpp @@ -0,0 +1,23 @@ +//======================================================================= +// Copyright Baptiste Wicht 2013-2014. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +//======================================================================= + +#include +#include +#include +#include + +int main(){ + auto fd = open("/stat"); + + if(fd.valid()){ + printf("fd: %u\n", *fd); + } else { + printf("stat: error: %s\n", std::error_message(fd.error())); + } + + exit(0); +} \ No newline at end of file diff --git a/tlib/include/file.hpp b/tlib/include/file.hpp index 26cc3f37..4c33ecb7 100644 --- a/tlib/include/file.hpp +++ b/tlib/include/file.hpp @@ -5,8 +5,8 @@ // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= -#ifndef USER_SYSTEM_HPP -#define USER_SYSTEM_HPP +#ifndef USER_FILE_HPP +#define USER_FILE_HPP #include #include