Create a stat program

This commit is contained in:
Baptiste Wicht 2014-02-12 17:25:08 +01:00
parent 4193ba0ffa
commit 170f681f27
6 changed files with 47 additions and 3 deletions

1
.gitignore vendored
View File

@ -13,4 +13,5 @@ programs/cpuid/cpuid
programs/args/args
programs/shutdown/shutdown
programs/reboot/reboot
programs/stat/stat
programs/dist/

View File

@ -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

15
programs/stat/Makefile Normal file
View File

@ -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

BIN
programs/stat/reboot Executable file

Binary file not shown.

View File

@ -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 <file.hpp>
#include <system.hpp>
#include <errors.hpp>
#include <print.hpp>
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);
}

View File

@ -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 <types.hpp>
#include <expected.hpp>