Compare commits
162 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3cf8ae04f1 | |||
| 25b4a34f1b | |||
| 206d0ebf05 | |||
| a64ce2f81d | |||
| 5aaddd467c | |||
| 0fd6bec4a3 | |||
| c1cc7e366a | |||
| 442e9f33bf | |||
| 1d3d48feb8 | |||
| f24814450d | |||
| 5a461aabb0 | |||
| 5e5b9ba370 | |||
| 47f0ee965a | |||
| dfbf5915dd | |||
| 4d69a58225 | |||
| d021526210 | |||
| df8936cad0 | |||
| 5c2b1dbebd | |||
| 8119074390 | |||
| 4c6db2dd87 | |||
| 4dca2d8b87 | |||
| fce63282fb | |||
| 4a0e344edd | |||
| e17b350248 | |||
| 453644d57e | |||
| a33d35f47f | |||
| 259697608f | |||
| e9d1cf9187 | |||
| 36aa392534 | |||
| cef88432a1 | |||
| 4e07800428 | |||
| 7e78df36cf | |||
| f6a1ab4012 | |||
| 29776a2fa3 | |||
| e485a40d3d | |||
| 9d0819ae02 | |||
| 3b533bd964 | |||
| 41928ad25b | |||
| 9189d79fb7 | |||
| 66bedb903f | |||
| e53b0056d2 | |||
| 3a56fb41d5 | |||
| 4e0c9d5cd5 | |||
| 7ef9fd2f2d | |||
| 821135d686 | |||
| 1e4a43e0f2 | |||
| ef4bd71aca | |||
| 334bf4a5eb | |||
| f70e7df1c5 | |||
| a7ca9f90d6 | |||
| 6ed5794b1e | |||
| 69d5939542 | |||
| 38ce67f426 | |||
| dfd6ba9a28 | |||
| 9e8bcb7690 | |||
| 630e80f724 | |||
| b61cfe0fb2 | |||
| 6606d5708f | |||
| b78d09fc24 | |||
| 942072d72f | |||
| 2047ab7b8a | |||
| 1e4a1f5852 | |||
| 50264d439f | |||
| 245f434aa4 | |||
| 0130725518 | |||
| 096183c27d | |||
| bfce80fef8 | |||
| ae6451e138 | |||
| 5751b60430 | |||
| f2b0348eb4 | |||
| 6c1745964d | |||
| 561524d440 | |||
| d9df8fd01c | |||
| 144dfb1bab | |||
| 0b8885f8d1 | |||
| 62d89ca38e | |||
| 0f9175e11c | |||
| c31a678075 | |||
| ca2d8e27f4 | |||
| 91af18b5a6 | |||
| e7f77a88f1 | |||
| 80b28a8768 | |||
| cb33ec1875 | |||
| 1b2bc49d41 | |||
| 73147816c7 | |||
| b83f5f7ec4 | |||
| 5c75019ddd | |||
| bef162cd24 | |||
| 2944f5cc43 | |||
| 41990c570f | |||
| f9334b25ed | |||
| 30637c3a51 | |||
| f95c361283 | |||
| df1c5352c4 | |||
| 455c555223 | |||
| b1285a4658 | |||
| d19e1845f8 | |||
| 4a29a27204 | |||
| ac9b627fad | |||
| 2461d82431 | |||
| 181d1d69cb | |||
| 5673102fd4 | |||
| c6906d4f2d | |||
| 47276eb503 | |||
| 81a0abed20 | |||
| 1ebc74f31f | |||
| 7c4a4ac0ba | |||
| 2226eebdc8 | |||
| 5ca3cec48e | |||
| 74dbffcb8d | |||
| 44e588b586 | |||
| 8018ecd274 | |||
| 913e7bf0b7 | |||
| 3db113f2d7 | |||
| 642284d3fb | |||
| 61e5eaa99a | |||
| 43f03e44dd | |||
| 60ed18dd80 | |||
| f7b951cb72 | |||
| a72f8e6b75 | |||
| 5f59da0e13 | |||
| a6f0f8768c | |||
| 177e325d89 | |||
| 8a826f0472 | |||
| 3013442c9d | |||
| 0ca6e9627f | |||
| 32a1425294 | |||
| b8b4feeedd | |||
| 151404d0d3 | |||
| 11f485cf77 | |||
| a0dbeb1527 | |||
| 33c02fe570 | |||
| fe13f087c9 | |||
| 73ef08dc11 | |||
| 7d74ab6bce | |||
| ef90d20604 | |||
| ae56fd09fa | |||
| 0949f75054 | |||
| df1ef59063 | |||
| f53100453f | |||
| 69f3cc6b88 | |||
| 4715809f96 | |||
| 43d34814bf | |||
| f6090319c7 | |||
| b48d2ad54a | |||
| 4c8ce44426 | |||
| f6eb4f8138 | |||
| 9d8e700fc6 | |||
| 1df4d8748f | |||
| ac3141a6d8 | |||
| d0a0f338c7 | |||
| ca4250c663 | |||
| f8da589298 | |||
| 36242acdb0 | |||
| f7297e3ded | |||
| 04bf7b9e3b | |||
| 60a56e1139 | |||
| 7a78333bae | |||
| 37465c2d2f | |||
| f2032f0bf4 | |||
| 50ad329b6e | |||
| 28981a82d0 |
@@ -0,0 +1,52 @@
|
|||||||
|
name: Main
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- "releases/**"
|
||||||
|
paths-ignore:
|
||||||
|
- "**.md"
|
||||||
|
- ".gitignore"
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- "**.md"
|
||||||
|
- ".gitignore"
|
||||||
|
jobs:
|
||||||
|
doxygen:
|
||||||
|
name: Doxygen
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Doxygen Ubuntu
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y doxygen nasm
|
||||||
|
|
||||||
|
- name: Generate documentation
|
||||||
|
run: |
|
||||||
|
cmake -B build -D DOXYGEN_WARN_AS_ERROR=NO
|
||||||
|
cmake --build build --target doxygen_doc
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Build
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Clone repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install NASM Ubuntu
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y nasm
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake -B build
|
||||||
|
cmake --build build --parallel 2
|
||||||
+19
-1
@@ -1,3 +1,15 @@
|
|||||||
|
# Covers Visual Studio Code
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
# Built Visual Studio Code Extensions
|
||||||
|
*.vsix
|
||||||
|
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
@@ -101,4 +113,10 @@ src/initscp/initfscp
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# OS filesystem files.
|
# OS filesystem files.
|
||||||
files/bin/**
|
files/bin/**
|
||||||
|
|
||||||
|
# ISO creation files.
|
||||||
|
iso/boot/*.bin
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode
|
||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
dist : xenial
|
|
||||||
sudo : required
|
|
||||||
language : c
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- compiler: gcc
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- gcc-5
|
|
||||||
env: COMPILER=gcc-5
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- sudo apt-get update -qq
|
|
||||||
- sudo apt-get install -qq nasm
|
|
||||||
|
|
||||||
script:
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake -DCMAKE_C_COMPILER=$COMPILER .. && make
|
|
||||||
+169
-116
@@ -1,158 +1,211 @@
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Set the minimum required version of cmake.
|
# Set the minimum required version of cmake.
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 3.1...3.22)
|
||||||
# Initialize the project.
|
# Initialize the project.
|
||||||
project(MentOs)
|
project(mentos C ASM)
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
# BUILD TYPE (Debug/Release)
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
# Set the default build type to Debug.
|
# Set the default build type to Debug.
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
message(STATUS "Setting build type to 'Debug' as none was specified.")
|
message(STATUS "Setting build type to 'Debug' as none was specified.")
|
||||||
set(CMAKE_BUILD_TYPE
|
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
|
||||||
"Debug"
|
|
||||||
CACHE STRING "Choose the type of build." FORCE)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
# DOCUMENTATION
|
||||||
|
# =============================================================================
|
||||||
|
add_subdirectory(doc/doxygen)
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# OS-SPECIFIC COMPILERS
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
# Add operating system specific option.
|
# Add operating system specific option.
|
||||||
message(STATUS "Crosscompiling : ${CMAKE_CROSSCOMPILING}")
|
message(STATUS "Crosscompiling : ${CMAKE_CROSSCOMPILING}")
|
||||||
message(STATUS "System name : ${CMAKE_HOST_SYSTEM_NAME}")
|
message(STATUS "System name : ${CMAKE_HOST_SYSTEM_NAME}")
|
||||||
message(STATUS "Kernel version : ${CMAKE_SYSTEM_VERSION}")
|
message(STATUS "Kernel version : ${CMAKE_SYSTEM_VERSION}")
|
||||||
if((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") OR APPLE)
|
if((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") OR APPLE)
|
||||||
# Set the Apple MacOSx compilers.
|
# Set the Apple MacOSx compilers.
|
||||||
if(CMAKE_VERSION VERSION_LESS "3.6.0")
|
if(CMAKE_VERSION VERSION_LESS "3.6.0")
|
||||||
include(CMakeForceCompiler)
|
include(CMakeForceCompiler)
|
||||||
cmake_force_c_compiler(i386-elf-gcc Clang)
|
cmake_force_c_compiler(i386-elf-gcc Clang)
|
||||||
cmake_force_cxx_compiler(i386-elf-g++ Clang)
|
cmake_force_cxx_compiler(i386-elf-g++ Clang)
|
||||||
else()
|
else()
|
||||||
set(CMAKE_C_COMPILER i386-elf-gcc)
|
set(CMAKE_C_COMPILER i386-elf-gcc)
|
||||||
set(CMAKE_CXX_COMPILER i386-elf-g++)
|
set(CMAKE_CXX_COMPILER i386-elf-g++)
|
||||||
set(CMAKE_AR i386-elf-ar)
|
set(CMAKE_AR i386-elf-ar)
|
||||||
endif()
|
endif()
|
||||||
# Speicfy the linker.
|
# Speicfy the linker.
|
||||||
set(CMAKE_LINKER i386-elf-ld)
|
set(CMAKE_LINKER i386-elf-ld)
|
||||||
# Specify the linker flags.
|
# Specify the linker flags.
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")
|
||||||
|
|
||||||
elseif((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") OR WIN32)
|
elseif((${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") OR WIN32)
|
||||||
# Windows set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
# Windows set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
# Generic Unix System
|
# Generic Unix System.
|
||||||
find_program(LSB_RELEASE_EXEC lsb_release)
|
# Find the `lsb_release` program.
|
||||||
execute_process(
|
find_program(LSB_RELEASE_EXEC lsb_release HINTS /usr/bin/ /usr/local/bin/)
|
||||||
COMMAND "${LSB_RELEASE_EXEC}" --short --release
|
# Mark the program path as advanced, we do not want it to appear as an option.
|
||||||
OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT
|
mark_as_advanced(LSB_RELEASE_EXEC)
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
# Get the version.
|
||||||
message(STATUS "LSB version : ${LSB_RELEASE_VERSION_SHORT}")
|
execute_process(
|
||||||
if(${LSB_RELEASE_VERSION_SHORT} MATCHES "^18")
|
COMMAND "${LSB_RELEASE_EXEC}" --short --release
|
||||||
# Ubuntu 18 set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT
|
||||||
elseif(${LSB_RELEASE_VERSION_SHORT} MATCHES "^19")
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
# Ubuntu 19
|
)
|
||||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -display gtk)
|
message(STATUS "LSB version : ${LSB_RELEASE_VERSION_SHORT}")
|
||||||
elseif(${LSB_RELEASE_VERSION_SHORT} MATCHES "^20")
|
if(${LSB_RELEASE_VERSION_SHORT} MATCHES "^18")
|
||||||
# Ubuntu 20
|
# Ubuntu 18 set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -display gtk)
|
elseif(${LSB_RELEASE_VERSION_SHORT} MATCHES "^19")
|
||||||
else()
|
# Ubuntu 19
|
||||||
# set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -display gtk)
|
||||||
endif()
|
elseif(${LSB_RELEASE_VERSION_SHORT} MATCHES "^20")
|
||||||
|
# Ubuntu 20
|
||||||
|
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -display gtk)
|
||||||
|
else()
|
||||||
|
# set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -sdl)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Add the debugging option.
|
# COMPILATION
|
||||||
set(DEBUGGING_TYPE
|
|
||||||
"DEBUG_STDIO"
|
|
||||||
CACHE STRING "Chose the type of debugging: DEBUG_STDIO DEBUG_LOG")
|
|
||||||
set_property(CACHE DEBUGGING_TYPE PROPERTY STRINGS DEBUG_STDIO DEBUG_LOG)
|
|
||||||
if("${DEBUGGING_TYPE}" STREQUAL "DEBUG_STDIO" OR "${DEBUGGING_TYPE}" STREQUAL "DEBUG_LOG")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${DEBUGGING_TYPE}")
|
|
||||||
message(STATUS "Setting debugging type to ${DEBUGGING_TYPE}.")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Debugging type ${DEBUGGING_TYPE} is not valid.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
# Add the sub-directories.
|
# Add the sub-directories.
|
||||||
add_subdirectory(programs)
|
add_subdirectory(programs)
|
||||||
add_subdirectory(programs/tests)
|
add_subdirectory(programs/tests)
|
||||||
add_subdirectory(mentos)
|
add_subdirectory(mentos)
|
||||||
add_subdirectory(initscp)
|
|
||||||
add_subdirectory(libc)
|
add_subdirectory(libc)
|
||||||
add_subdirectory(doc)
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Target to generate the initrd filesystem.
|
# FILESYSTEM
|
||||||
add_custom_target(
|
# =============================================================================
|
||||||
initrd
|
|
||||||
COMMAND echo "---------------------------------------------"
|
# MentOS is compatible with EXT2 fileystems. This target generates an EXT2
|
||||||
COMMAND echo "Initializing 'initrd'..."
|
# fileystem using the content of the `files` folder.
|
||||||
COMMAND echo "---------------------------------------------"
|
add_custom_target(filesystem
|
||||||
COMMAND initfscp -s ${CMAKE_SOURCE_DIR}/files -t ${CMAKE_BINARY_DIR}/initrd -m /dev
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/rootfs.img
|
||||||
COMMAND echo "---------------------------------------------"
|
COMMAND echo '============================================================================='
|
||||||
COMMAND echo "Done!"
|
COMMAND echo 'Creating EXT2 filesystem...'
|
||||||
COMMAND echo "---------------------------------------------"
|
COMMAND echo '============================================================================='
|
||||||
DEPENDS initfscp
|
COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/files/proc
|
||||||
DEPENDS all_programs all_tests)
|
COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/files/dev
|
||||||
|
COMMAND mke2fs -L 'rootfs' -N 0 -d ${CMAKE_SOURCE_DIR}/files -m 5 -r 1 -t ext2 -v -F ${CMAKE_BINARY_DIR}/rootfs.img 32M
|
||||||
|
COMMAND echo '============================================================================='
|
||||||
|
COMMAND echo 'Done!'
|
||||||
|
COMMAND echo '============================================================================='
|
||||||
|
DEPENDS all_programs all_tests
|
||||||
|
)
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Update GDB symbol file.
|
# EMULATION SERIAL OUTPUT OPTION
|
||||||
add_custom_target(
|
# =============================================================================
|
||||||
gdb_file
|
# Set the list of valid emulator output options.
|
||||||
COMMAND echo "symbol-file ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
set(EMULATOR_OUTPUT_TYPES OUTPUT_STDIO OUTPUT_LOG)
|
||||||
COMMAND echo "exec-file ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
# Add the emulator output option.
|
||||||
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/mentos/kernel.bin > ${CMAKE_BINARY_DIR}/.gdbinit
|
set(EMULATOR_OUTPUT_TYPE "OUTPUT_STDIO" CACHE STRING "Chose the type of emulator output: ${EMULATOR_OUTPUT_TYPES}")
|
||||||
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin >> ${CMAKE_BINARY_DIR}/.gdbinit
|
# List of emulator output options.
|
||||||
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/programs/tests/test_* >> ${CMAKE_BINARY_DIR}/.gdbinit
|
set_property(CACHE EMULATOR_OUTPUT_TYPE PROPERTY STRINGS ${EMULATOR_OUTPUT_TYPES})
|
||||||
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/programs/prog_* >> ${CMAKE_BINARY_DIR}/.gdbinit
|
# Check which emulator output option is currently active.
|
||||||
COMMAND echo "break boot.c: boot_main" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
list(FIND EMULATOR_OUTPUT_TYPES ${EMULATOR_OUTPUT_TYPE} INDEX)
|
||||||
COMMAND echo "break kernel.c: kmain" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
if(index EQUAL -1)
|
||||||
COMMAND echo "target remote localhost:1234" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
message(FATAL_ERROR "Emulator output type ${EMULATOR_OUTPUT_TYPE} is not valid.")
|
||||||
DEPENDS ${PROJECT_NAME}_bootloader
|
else()
|
||||||
DEPENDS all_programs all_tests
|
message(STATUS "Setting emulator output type to ${EMULATOR_OUTPUT_TYPE}.")
|
||||||
DEPENDS libc)
|
endif()
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Update GDB symbol file.
|
# EMULATOR CONFIGURATION
|
||||||
add_custom_target(
|
|
||||||
gdb_file_clion_embedded
|
|
||||||
COMMAND echo "symbol-file ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
|
||||||
COMMAND echo "exec-file ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
|
||||||
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/mentos/kernel.bin > ${CMAKE_BINARY_DIR}/.gdbinit
|
|
||||||
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin >> ${CMAKE_BINARY_DIR}/.gdbinit
|
|
||||||
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/programs/prog_* >> ${CMAKE_BINARY_DIR}/.gdbinit
|
|
||||||
DEPENDS ${PROJECT_NAME}_bootloader
|
|
||||||
DEPENDS all_programs all_tests
|
|
||||||
DEPENDS libc)
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Set memory size.
|
|
||||||
set(MEMORY_SIZE 1096M)
|
|
||||||
|
|
||||||
# =============================================================================
|
# Set the emulator.
|
||||||
# Builds the code and runs qemu with the built Os.
|
|
||||||
set(EMULATOR qemu-system-i386)
|
set(EMULATOR qemu-system-i386)
|
||||||
if(${DEBUGGING_TYPE} STREQUAL DEBUG_LOG)
|
# Set the debug type.
|
||||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -serial file:serial.log)
|
if(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_LOG)
|
||||||
elseif(${DEBUGGING_TYPE} STREQUAL DEBUG_STDIO)
|
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -serial file:${CMAKE_BINARY_DIR}/serial.log)
|
||||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -serial stdio)
|
elseif(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_STDIO)
|
||||||
endif(${DEBUGGING_TYPE} STREQUAL DEBUG_LOG)
|
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -serial stdio)
|
||||||
|
endif(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_LOG)
|
||||||
|
# Set the type of video.
|
||||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -vga std)
|
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -vga std)
|
||||||
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -m ${MEMORY_SIZE})
|
# Set the amount of memory.
|
||||||
set(EMULATOR_KERNEL -kernel mentos/kernel-bootloader.bin)
|
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -m 1096M)
|
||||||
set(EMULATOR_FS -initrd initrd)
|
# Set the EXT2 drive.
|
||||||
|
set(EMULATOR_FLAGS ${EMULATOR_FLAGS} -drive file=${CMAKE_BINARY_DIR}/rootfs.img,format=raw)
|
||||||
add_custom_target(
|
|
||||||
qemu
|
|
||||||
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} ${EMULATOR_KERNEL} ${EMULATOR_FS}
|
|
||||||
DEPENDS kernel-bootloader.bin initrd all_programs all_tests libc)
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Builds the code and runs qemu with the built Os.
|
# Booting with QEMU for fun
|
||||||
set(EMULATOR_FLAGS_GDB ${EMULATOR_FLAGS} -s -S)
|
# =============================================================================
|
||||||
|
|
||||||
|
# This first target runs the emualtor passing the kernel binary file.
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
qemu-gdb
|
qemu
|
||||||
COMMAND ${EMULATOR} ${EMULATOR_FLAGS_GDB} ${EMULATOR_KERNEL} ${EMULATOR_FS} &
|
COMMAND test -e ${CMAKE_BINARY_DIR}/rootfs.img || ${CMAKE_COMMAND} -E cmake_echo_color --red "No filesystem file detected, you need to run: make filesystem"
|
||||||
DEPENDS gdb_file kernel-bootloader.bin initrd)
|
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} -kernel ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin
|
||||||
|
DEPENDS kernel-bootloader.bin
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_target(all-execs-clion-embedded DEPENDS gdb_file_clion_embedded kernel-bootloader.bin initrd)
|
# =============================================================================
|
||||||
|
# Booting with QEMU+GDB for debugging
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
# First, we need to generate a GDB file containing all the symbols of all our
|
||||||
|
# executables.
|
||||||
|
add_custom_target(
|
||||||
|
.gdbinit
|
||||||
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/.gdbinit
|
||||||
|
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/mentos/kernel.bin > ${CMAKE_BINARY_DIR}/.gdbinit
|
||||||
|
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin >> ${CMAKE_BINARY_DIR}/.gdbinit
|
||||||
|
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/programs/tests/test_* >> ${CMAKE_BINARY_DIR}/.gdbinit
|
||||||
|
COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/get_text_address.sh ${CMAKE_BINARY_DIR}/programs/prog_* >> ${CMAKE_BINARY_DIR}/.gdbinit
|
||||||
|
COMMAND echo "break boot.c: boot_main" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
||||||
|
COMMAND echo "break kernel.c: kmain" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
||||||
|
COMMAND echo "target remote localhost:1234" >> ${CMAKE_BINARY_DIR}/.gdbinit
|
||||||
|
DEPENDS kernel-bootloader.bin
|
||||||
|
DEPENDS all_programs
|
||||||
|
DEPENDS all_tests
|
||||||
|
DEPENDS libc
|
||||||
|
)
|
||||||
|
|
||||||
|
# This second target runs the emualtor passing the kernel binary file, and also
|
||||||
|
# the `-s -S` options. This basically tells the emulator to run the kernel in
|
||||||
|
# debug mode, and pause it up until a debugger connects to it.
|
||||||
|
add_custom_target(
|
||||||
|
qemu-gdb
|
||||||
|
COMMAND test -e ${CMAKE_BINARY_DIR}/rootfs.img || ${CMAKE_COMMAND} -E cmake_echo_color --red "No filesystem file detected, you need to run: make filesystem"
|
||||||
|
COMMAND echo "\n\n"
|
||||||
|
COMMAND echo "Now, QEMU has loaded the kernel, and it is waiting that you\n"
|
||||||
|
COMMAND echo "remotely connect to it. To start debugging, open a new shell\n"
|
||||||
|
COMMAND echo "in THIS same folder, and just type :\n"
|
||||||
|
COMMAND printf " cgdb -q -iex %q" "add-auto-load-safe-path ."
|
||||||
|
COMMAND echo "\n\n"
|
||||||
|
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} -s -S -kernel ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin
|
||||||
|
DEPENDS kernel-bootloader.bin
|
||||||
|
DEPENDS .gdbinit
|
||||||
|
)
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# Booting with QEMU+GRUB
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
# First, we need to build the ISO for the cdrom.
|
||||||
|
add_custom_target(
|
||||||
|
cdrom.iso
|
||||||
|
COMMAND cp -rf ${CMAKE_SOURCE_DIR}/iso .
|
||||||
|
COMMAND cp ${CMAKE_BINARY_DIR}/mentos/kernel-bootloader.bin ${CMAKE_BINARY_DIR}/iso/boot
|
||||||
|
COMMAND grub-mkrescue -o ${CMAKE_BINARY_DIR}/cdrom.iso ${CMAKE_BINARY_DIR}/iso
|
||||||
|
DEPENDS kernel-bootloader.bin
|
||||||
|
)
|
||||||
|
|
||||||
|
# This third target runs the emualtor, but this time, the kernel binary file is
|
||||||
|
# inside the cdrom, so we will not pass the `-kernel` option. We will pass the
|
||||||
|
# `-cdrom` option and the `-boot d` option, all the other options will remain
|
||||||
|
# the same.
|
||||||
|
add_custom_target(
|
||||||
|
qemu-grub
|
||||||
|
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} -boot d -cdrom ${CMAKE_BINARY_DIR}/cdrom.iso
|
||||||
|
DEPENDS cdrom.iso
|
||||||
|
)
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# Coding Style
|
|
||||||
If you'd like to contribute you are welcome, thus refer to the following coding
|
|
||||||
styles please:
|
|
||||||
|
|
||||||
* **C**: _the Linux kernel coding style_
|
|
||||||
https://www.kernel.org/doc/html/v4.10/process/coding-style.html
|
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2019 Alessandro Danese, Enrico Fraccaroli, Luigi Capogrosso,
|
Copyright (c) 2014-2022 MentOs-Team.
|
||||||
Mirco De Marchi
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -26,12 +26,49 @@ Parts of MentOS are inherited or inspired by a similar educational operating
|
|||||||
system called [DreamOs](https://github.com/dreamos82/DreamOs) written by Ivan
|
system called [DreamOs](https://github.com/dreamos82/DreamOs) written by Ivan
|
||||||
Gualandri.
|
Gualandri.
|
||||||
|
|
||||||
## 2. Prerequisites
|
## 2. Implemented features
|
||||||
|
Follows the list of implemented features:
|
||||||
|
|
||||||
|
**Processes and Events**
|
||||||
|
- [x] Memory protection (User vs Kernel);
|
||||||
|
- [x] Processes;
|
||||||
|
- [x] Scheduler (synchronous and asynchronous);
|
||||||
|
- [x] Interrupts and Exceptions;
|
||||||
|
- [x] Signals;
|
||||||
|
- [x] Timers and RTC;
|
||||||
|
- [x] Wait-queues;
|
||||||
|
- [x] System Calls;
|
||||||
|
- [ ] Multi-core;
|
||||||
|
|
||||||
|
**Memory**
|
||||||
|
- [x] Paging;
|
||||||
|
- [x] Buddy System;
|
||||||
|
- [x] Slab Allocation;
|
||||||
|
- [x] Zone Allocator;
|
||||||
|
- [x] Cache Allocator;
|
||||||
|
- [x] Heap;
|
||||||
|
- [x] Virtual Addressing;
|
||||||
|
|
||||||
|
**Filesystem**
|
||||||
|
- [x] Virtual Filesystem (VFS);
|
||||||
|
- [x] Initramfs;
|
||||||
|
- [x] EXT2;
|
||||||
|
- [x] Procfs;
|
||||||
|
|
||||||
|
**Input/Output**
|
||||||
|
- [x] Programmable Interrupt Controller (PIC) drivers;
|
||||||
|
- [x] Keyboard drivers (IT/ENG layouts);
|
||||||
|
- [x] Video drivers;
|
||||||
|
- [ ] VGA drivers;
|
||||||
|
|
||||||
|
I will try to keep it updated...
|
||||||
|
|
||||||
|
## 3. Prerequisites
|
||||||
|
|
||||||
MentOS is compatible with the main **unix-based** operating systems. It has been
|
MentOS is compatible with the main **unix-based** operating systems. It has been
|
||||||
tested with *Ubuntu*, *WSL1*, *WSL2*, and *MacOS*.
|
tested with *Ubuntu*, *WSL1*, *WSL2*, and *MacOS*.
|
||||||
|
|
||||||
### 2.1. Generic Prerequisites
|
### 3.1. Generic Prerequisites
|
||||||
|
|
||||||
#### 3.1.1. Compile
|
#### 3.1.1. Compile
|
||||||
|
|
||||||
@@ -43,6 +80,7 @@ For compiling the system:
|
|||||||
- cmake
|
- cmake
|
||||||
- git
|
- git
|
||||||
- ccmake (suggested)
|
- ccmake (suggested)
|
||||||
|
- e2fsprogs (should be already installed)
|
||||||
|
|
||||||
Under **MacOS**, for compiling, you have additional dependencies:
|
Under **MacOS**, for compiling, you have additional dependencies:
|
||||||
|
|
||||||
@@ -59,18 +97,18 @@ To execute the operating system, you need to install:
|
|||||||
|
|
||||||
For debugging we suggest using:
|
For debugging we suggest using:
|
||||||
|
|
||||||
- cgdb
|
- gdb or cgdb
|
||||||
- xterm
|
|
||||||
|
|
||||||
### 2.2. installation Prerequisites
|
### 3.2. installation Prerequisites
|
||||||
|
|
||||||
Under **Ubuntu**, you can type the following commands:
|
Under **Ubuntu**, you can type the following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get update && sudo apt-get upgrade -y
|
sudo apt-get update && sudo apt-get upgrade -y
|
||||||
sudo apt-get install -y build-essential git cmake qemu-system-i386
|
sudo apt-get install -y build-essential git cmake qemu-system-x86 nasm e2fsprogs
|
||||||
sudo apt-get install -y cgdb xterm
|
sudo apt-get install -y gdb cgdb
|
||||||
```
|
```
|
||||||
|
Note: Older versions might have `qemu-system-i386` instead of `qemu-system-x86`.
|
||||||
|
|
||||||
Under **MacOS** you also need to install the i386-elf cross-compiler. The
|
Under **MacOS** you also need to install the i386-elf cross-compiler. The
|
||||||
simplest installation method is through Homebrew package manager.
|
simplest installation method is through Homebrew package manager.
|
||||||
@@ -79,13 +117,13 @@ then type the following commands:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew update && brew upgrade
|
brew update && brew upgrade
|
||||||
brew install i386-elf-binutils i386-elf-gcc git cmake qemu nasm
|
brew install i386-elf-binutils i386-elf-gcc git cmake qemu nasm e2fsprogs
|
||||||
brew install cgdb xterm #<- for debug only
|
brew install gdb cgdb #<- for debug only
|
||||||
```
|
```
|
||||||
|
|
||||||
## 3. Compiling MentOS
|
## 4. Compiling MentOS and generating the EXT2 filesystem
|
||||||
|
|
||||||
Compile and boot MentOS with qemu:
|
Compile MentOS with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd <clone_directory>
|
cd <clone_directory>
|
||||||
@@ -93,12 +131,76 @@ mkdir build
|
|||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, generate the EXT2 filesystem with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make filesystem
|
||||||
|
```
|
||||||
|
you just need to generate the filesystem once. If you change a `program` you need to re-generate the entire filesystem with `make filesystem`, but this will override any changes you made to the files inside the `rootfs.img`. In the future I will find a way to update just the `/usr/bin` directory and the programs.
|
||||||
|
|
||||||
|
## 5. Running MentOS
|
||||||
|
|
||||||
|
Boot MentOS with qemu:
|
||||||
|
|
||||||
|
```bash
|
||||||
make qemu
|
make qemu
|
||||||
```
|
```
|
||||||
|
|
||||||
To login, use one of the usernames listed in `files/etc/passwd`.
|
To login, use one of the usernames listed in `files/etc/passwd`.
|
||||||
|
|
||||||
## 4. Change the scheduling algorithm
|
## 6. Kernel logging
|
||||||
|
The kernel provides ways of printing logging messages *from* inside the kernel code *to* the bash where you executed the `make qemu`.
|
||||||
|
|
||||||
|
These *logging* functions are:
|
||||||
|
```C++
|
||||||
|
#define pr_emerg(...)
|
||||||
|
#define pr_alert(...)
|
||||||
|
#define pr_crit(...)
|
||||||
|
#define pr_err(...)
|
||||||
|
#define pr_warning(...)
|
||||||
|
#define pr_notice(...)
|
||||||
|
#define pr_info(...)
|
||||||
|
#define pr_debug(...)
|
||||||
|
#define pr_default(...)
|
||||||
|
```
|
||||||
|
|
||||||
|
You use them like you would use a `printf`:
|
||||||
|
```C++
|
||||||
|
if (fd < 0) {
|
||||||
|
pr_err("Failed to open file '%s', received file descriptor %d.\n", filename, fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
By default only message that goes from `pr_notice` included down to `pr_emerg` are displayed.
|
||||||
|
|
||||||
|
Each logging function (they are actually macros) is a wrapper that automatically sets the desired **log level**. Each log level is identified by a number, and declared as follows:
|
||||||
|
```C++
|
||||||
|
#define LOGLEVEL_DEFAULT (-1) ///< default-level messages.
|
||||||
|
#define LOGLEVEL_EMERG 0 ///< system is unusable.
|
||||||
|
#define LOGLEVEL_ALERT 1 ///< action must be taken immediately.
|
||||||
|
#define LOGLEVEL_CRIT 2 ///< critical conditions.
|
||||||
|
#define LOGLEVEL_ERR 3 ///< error conditions.
|
||||||
|
#define LOGLEVEL_WARNING 4 ///< warning conditions.
|
||||||
|
#define LOGLEVEL_NOTICE 5 ///< normal but significant condition.
|
||||||
|
#define LOGLEVEL_INFO 6 ///< informational.
|
||||||
|
#define LOGLEVEL_DEBUG 7 ///< debug-level messages.
|
||||||
|
```
|
||||||
|
|
||||||
|
You can change the logging level by including the following lines at the beginning of your source code:
|
||||||
|
```C++
|
||||||
|
// Include the kernel log levels.
|
||||||
|
#include "sys/kernel_levels.h"
|
||||||
|
/// Change the header.
|
||||||
|
#define __DEBUG_HEADER__ "[ATA ]"
|
||||||
|
/// Set the log level.
|
||||||
|
#define __DEBUG_LEVEL__ LOGLEVEL_INFO
|
||||||
|
```
|
||||||
|
This example sets the `__DEBUG_LEVEL__`, so that all the messages from `INFO` and below are shown. While `__DEBUG_HEADER__` is just a string that is automatically prepended to your message, helping you identifying from which code the message is coming from.
|
||||||
|
|
||||||
|
## 7. Change the scheduling algorithm
|
||||||
|
|
||||||
MentOS provides three different scheduling algorithms:
|
MentOS provides three different scheduling algorithms:
|
||||||
|
|
||||||
@@ -152,29 +254,63 @@ make
|
|||||||
make qemu
|
make qemu
|
||||||
```
|
```
|
||||||
|
|
||||||
## 5. Use Debugger
|
## 8. Use Debugger
|
||||||
|
|
||||||
If you want to use GDB to debug MentOS:
|
If you want to use GDB to debug MentOS, first you need to compile everything:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
make
|
make
|
||||||
make qemu-gdb
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you did everything correctly, you should have 3 windows with:
|
Then, you need to generate a file called `.gdbinit` placed inside the `build` directory, which will tell **gdb** which *object* file he needs to read in order to allow proper debugging.
|
||||||
|
```bash
|
||||||
|
make gdb_file
|
||||||
|
```
|
||||||
|
|
||||||
1. Kernel Booting on qemu
|
Finally, you run qemu in debugging mode with:
|
||||||
2. Shell with video printing of statistics previously discussed
|
```bash
|
||||||
3. Debugger cgdb with code screening
|
make qemu-gdb
|
||||||
|
```
|
||||||
|
If you did everything correctly, you should see an empty QEMU window. Basically, QEMU is waiting for you to connect *remotely* with gdb. Anyway, running `make qemu-gdb` will make your current shell busy, you cannot call `gdb` in it. You need to open a new shell inside the `build` folder and do a:
|
||||||
|
```bash
|
||||||
|
cgdb -q -iex 'add-auto-load-safe-path .'
|
||||||
|
```
|
||||||
|
|
||||||
## Developers
|
Now you will have:
|
||||||
|
1. the QEMU window waiting for you,
|
||||||
|
2. the shell where you ran `make qemu-gdb` also waiting for you,
|
||||||
|
3. the debugger that loaded a series of symbol files and the location of their `.text` section.
|
||||||
|
|
||||||
Main Developers:
|
By default I placed a breakpoint at the begginning of 1) the bootloader, 2) the `kmain` function of the kernel.
|
||||||
|
|
||||||
|
So, when gdb starts you need to first give a continue:
|
||||||
|
```bash
|
||||||
|
(gdb) continue
|
||||||
|
```
|
||||||
|
|
||||||
|
This will make the kernel run, and stop at the first breakpoint which is inside the *bootloader*:
|
||||||
|
```bash
|
||||||
|
Breakpoint 1, boot_main (...) at .../mentos/src/boot.c:220
|
||||||
|
220 {
|
||||||
|
```
|
||||||
|
|
||||||
|
giving a second `continue` will get you to the start of the operating system:
|
||||||
|
|
||||||
|
This will make the kernel run, and stop at the first breakpoint which is inside the *bootloader*:
|
||||||
|
```bash
|
||||||
|
Breakpoint 2, kmain (...) at .../mentos/src/kernel.c:95
|
||||||
|
95 {
|
||||||
|
```
|
||||||
|
|
||||||
|
## 9. Contributors
|
||||||
|
|
||||||
|
Project Manager:
|
||||||
|
|
||||||
* [Enrico Fraccaroli](https://github.com/Galfurian)
|
* [Enrico Fraccaroli](https://github.com/Galfurian)
|
||||||
- Mr. Wolf
|
|
||||||
|
Developers:
|
||||||
* [Alessandro Danese](https://github.com/alessandroDanese88), [Luigi Capogrosso](https://github.com/luigicapogrosso), [Mirco De Marchi](https://github.com/mircodemarchi)
|
* [Alessandro Danese](https://github.com/alessandroDanese88), [Luigi Capogrosso](https://github.com/luigicapogrosso), [Mirco De Marchi](https://github.com/mircodemarchi)
|
||||||
- Protection ring
|
- Protection ring
|
||||||
- libc
|
- libc
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
|
|
||||||
if (DOXYGEN_FOUND)
|
if (DOXYGEN_FOUND)
|
||||||
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doc_doxygen)
|
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/html/index.html)
|
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/html/index.html)
|
||||||
|
|
||||||
# Replace variables inside @@ with the current values.
|
# Replace variables inside @@ with the current values.
|
||||||
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxygen)
|
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
|
||||||
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxygen)
|
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||||
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
|
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
|
||||||
|
|
||||||
# Copy the files needd by the documentation.
|
# Copy the files needd by the documentation.
|
||||||
@@ -19,19 +19,19 @@ if (DOXYGEN_FOUND)
|
|||||||
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
|
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${DOXYGEN_INDEX_FILE}
|
OUTPUT ${DOXYGEN_INDEX_FILE}
|
||||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
|
||||||
|
|
||||||
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
|
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
|
||||||
COMMENT "Generating docs"
|
COMMENT "Generating docs"
|
||||||
)
|
)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
Doxygen
|
doxygen_doc
|
||||||
DEPENDS
|
DEPENDS
|
||||||
${DOXYGEN_INDEX_FILE}
|
${DOXYGEN_INDEX_FILE}
|
||||||
${DOXYFILE_IN}
|
${DOXYFILE_IN}
|
||||||
${DOXYFILE_CSS}
|
${DOXYFILE_CSS}
|
||||||
${DOXYFILE_HEADER}
|
${DOXYFILE_HEADER}
|
||||||
${DOXYFILE_FOOTER}
|
${DOXYFILE_FOOTER}
|
||||||
)
|
)
|
||||||
endif (DOXYGEN_FOUND)
|
endif (DOXYGEN_FOUND)
|
||||||
@@ -38,7 +38,7 @@ PROJECT_NAME = MentOS
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 0.3.0
|
PROJECT_NUMBER = 0.5.2
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
@@ -853,7 +853,7 @@ INPUT_ENCODING = UTF-8
|
|||||||
# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f, *.for, *.tcl, *.vhd,
|
# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f, *.for, *.tcl, *.vhd,
|
||||||
# *.vhdl, *.ucf, *.qsf and *.ice.
|
# *.vhdl, *.ucf, *.qsf and *.ice.
|
||||||
|
|
||||||
FILE_PATTERNS = *.c *.h
|
FILE_PATTERNS = *.c *.h *.S
|
||||||
|
|
||||||
# The RECURSIVE tag can be used to specify whether or not subdirectories should
|
# The RECURSIVE tag can be used to specify whether or not subdirectories should
|
||||||
# be searched for input files as well.
|
# be searched for input files as well.
|
||||||
@@ -2250,7 +2250,7 @@ HIDE_UNDOC_RELATIONS = YES
|
|||||||
# set to NO
|
# set to NO
|
||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
|
|
||||||
HAVE_DOT = YES
|
HAVE_DOT = NO
|
||||||
|
|
||||||
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
|
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
|
||||||
# to run in parallel. When set to 0 doxygen will base this on the number of
|
# to run in parallel. When set to 0 doxygen will base this on the number of
|
||||||
@@ -2491,7 +2491,7 @@ DOT_GRAPH_MAX_NODES = 50
|
|||||||
# Minimum value: 0, maximum value: 1000, default value: 0.
|
# Minimum value: 0, maximum value: 1000, default value: 0.
|
||||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||||
|
|
||||||
MAX_DOT_GRAPH_DEPTH = 0
|
MAX_DOT_GRAPH_DEPTH = 3
|
||||||
|
|
||||||
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
|
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
|
||||||
# background. This is disabled by default, because dot on Windows does not seem
|
# background. This is disabled by default, because dot on Windows does not seem
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -7,11 +7,22 @@ $cyan-color: #56b6c2;
|
|||||||
$yellow-color: #e5c07b;
|
$yellow-color: #e5c07b;
|
||||||
$blue-color: #61afef;
|
$blue-color: #61afef;
|
||||||
$gutter-color: #4b5263;
|
$gutter-color: #4b5263;
|
||||||
// $code-font: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
|
|
||||||
$code-font: monaco,
|
/* font families */
|
||||||
Consolas,
|
|
||||||
"Lucida Console",
|
$page-font-family: Roboto, Lucida, sans-serif;
|
||||||
monospace;
|
$code-font-family: Consolas, monospace, fixed;
|
||||||
|
|
||||||
|
/* font sizes */
|
||||||
|
|
||||||
|
$title-font-size: 22px;
|
||||||
|
$page-font-size: 16px;
|
||||||
|
$code-font-size: 14px;
|
||||||
|
$page-line-height: $page-font-size+6px;
|
||||||
|
$code-line-height: $code-font-size+4px;
|
||||||
|
|
||||||
|
/* colors */
|
||||||
|
|
||||||
$title-fg-color: $white-color;
|
$title-fg-color: $white-color;
|
||||||
$title-bg-color: $black-color;
|
$title-bg-color: $black-color;
|
||||||
$menu-bg-color: $gutter-color;
|
$menu-bg-color: $gutter-color;
|
||||||
@@ -69,7 +80,10 @@ table,
|
|||||||
div,
|
div,
|
||||||
p,
|
p,
|
||||||
dl {
|
dl {
|
||||||
font: 400 14px/22px Roboto, sans-serif;
|
font-size: $page-font-size;
|
||||||
|
font-family: $page-font-family;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: $page-line-height;
|
||||||
display: block;
|
display: block;
|
||||||
margin-block-start: 0em;
|
margin-block-start: 0em;
|
||||||
margin-block-end: 0em;
|
margin-block-end: 0em;
|
||||||
@@ -89,7 +103,10 @@ ul {
|
|||||||
|
|
||||||
p.reference,
|
p.reference,
|
||||||
p.definition {
|
p.definition {
|
||||||
font: 400 14px/22px Roboto, sans-serif;
|
font-size: $page-font-size;
|
||||||
|
font-family: $page-font-family;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: $page-line-height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,7 +117,10 @@ h1.groupheader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font: 400 14px/28px Roboto, sans-serif;
|
font-size: $page-font-size;
|
||||||
|
font-family: $page-font-family;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: $page-line-height;
|
||||||
font-size: 150%;
|
font-size: 150%;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin: 10px 2px;
|
margin: 10px 2px;
|
||||||
@@ -205,8 +225,7 @@ span.legend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
span.arrow {
|
span.arrow {
|
||||||
/* width: 32px; */
|
width: 16px;
|
||||||
padding-left: 0px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h3.version {
|
h3.version {
|
||||||
@@ -327,7 +346,7 @@ pre.fragment {
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
line-height: 125%;
|
line-height: 125%;
|
||||||
font-family: $code-font;
|
font-family: $code-font-family;
|
||||||
font-size: 105%;
|
font-size: 105%;
|
||||||
color: $code-fg-color;
|
color: $code-fg-color;
|
||||||
}
|
}
|
||||||
@@ -342,10 +361,9 @@ div.fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.line {
|
div.line {
|
||||||
font-family: monospace, fixed;
|
font-family: $code-font-family;
|
||||||
font-size: 13px;
|
font-size: $code-font-size;
|
||||||
min-height: 13px;
|
line-height: $code-line-height;
|
||||||
line-height: 1.0;
|
|
||||||
text-wrap: unrestricted;
|
text-wrap: unrestricted;
|
||||||
white-space: -moz-pre-wrap;
|
white-space: -moz-pre-wrap;
|
||||||
/* Moz */
|
/* Moz */
|
||||||
@@ -652,7 +670,7 @@ table.memberdecls {
|
|||||||
|
|
||||||
.memItemLeft,
|
.memItemLeft,
|
||||||
.memItemRight {
|
.memItemRight {
|
||||||
font-family: $code-font;
|
font-family: $code-font-family;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mdescLeft,
|
.mdescLeft,
|
||||||
@@ -780,7 +798,7 @@ table.memberdecls {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.memname {
|
.memname {
|
||||||
font-family: $code-font;
|
font-family: $code-font-family;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
}
|
}
|
||||||
@@ -963,8 +981,8 @@ div.directory {
|
|||||||
.directory td.entry {
|
.directory td.entry {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
padding-right: 6px;
|
padding-right: 6px;
|
||||||
padding-top: 3px;
|
padding-top: 2px;
|
||||||
padding-bottom: 3px;
|
padding-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.directory td.entry a {
|
.directory td.entry a {
|
||||||
@@ -1024,8 +1042,8 @@ div.directory {
|
|||||||
font-family: Arial, Helvetica;
|
font-family: Arial, Helvetica;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
height: 14px;
|
height: $page-font-size;
|
||||||
width: 16px;
|
width: $page-font-size;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
background-color: #728DC1;
|
background-color: #728DC1;
|
||||||
color: white;
|
color: white;
|
||||||
@@ -1075,7 +1093,10 @@ div.directory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
table.directory {
|
table.directory {
|
||||||
font: 400 14px Roboto, sans-serif;
|
font-size: $page-font-size;
|
||||||
|
font-family: $page-font-family;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: $page-line-height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1126,6 +1147,7 @@ table.fieldtable {
|
|||||||
-moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px;
|
-moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px;
|
||||||
-webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15);
|
-webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15);
|
||||||
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15);
|
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15);
|
||||||
|
width: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fieldtable td,
|
.fieldtable td,
|
||||||
@@ -1273,7 +1295,7 @@ table.classindex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.ingroups {
|
div.ingroups {
|
||||||
font-size: 8pt;
|
font-size: 10pt;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
@@ -1687,7 +1709,7 @@ tr.heading h2 {
|
|||||||
#powerTip div {
|
#powerTip div {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
font: 12px/16px Roboto, sans-serif;
|
font: 12px/16px $page-font-family;
|
||||||
}
|
}
|
||||||
|
|
||||||
#powerTip:before,
|
#powerTip:before,
|
||||||
@@ -1862,15 +1884,19 @@ tr.heading h2 {
|
|||||||
#top {
|
#top {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#side-nav {
|
#side-nav {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#nav-path {
|
#nav-path {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2,
|
||||||
h3,
|
h3,
|
||||||
@@ -1879,12 +1905,15 @@ tr.heading h2 {
|
|||||||
h6 {
|
h6 {
|
||||||
page-break-after: avoid;
|
page-break-after: avoid;
|
||||||
}
|
}
|
||||||
|
|
||||||
.summary {
|
.summary {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.memitem {
|
.memitem {
|
||||||
page-break-inside: avoid;
|
page-break-inside: avoid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#doc-content {
|
#doc-content {
|
||||||
margin-left: 0 !important;
|
margin-left: 0 !important;
|
||||||
height: auto !important;
|
height: auto !important;
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<!-- HTML footer for doxygen 1.8.16-->
|
||||||
|
<!-- start footer part -->
|
||||||
|
<!--BEGIN GENERATE_TREEVIEW-->
|
||||||
|
<div id="nav-path" class="navpath">
|
||||||
|
<!-- id is needed for treeview function! -->
|
||||||
|
<ul>
|
||||||
|
$navpath
|
||||||
|
<li class="footer">$generatedby
|
||||||
|
<a href="http://www.doxygen.org/index.html">
|
||||||
|
<img class="footer" src="$relpath^doxygen.png" alt="doxygen" />
|
||||||
|
</a> $doxygenversion
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<!--END GENERATE_TREEVIEW-->
|
||||||
|
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||||
|
<div class="footer">
|
||||||
|
<hr class="footer" />
|
||||||
|
<ul class="footer-info">
|
||||||
|
<li class="footer-info-lastmode">
|
||||||
|
This page was last modified on $datetime.
|
||||||
|
</li>
|
||||||
|
<li class="footer-info-copyright">
|
||||||
|
MentOs © 2014–2022 the MentOs-Team, and numerous contributors.<br>
|
||||||
|
It is available for use and modification under the 
|
||||||
|
<a href="$relpath^md_LICENSE.html">MIT License</a>.<br>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<hr class="footer" />
|
||||||
|
<address class="footer">
|
||||||
|
$generatedby 
|
||||||
|
<a href="http://www.doxygen.org/index.html">
|
||||||
|
<img class="footer" src="$relpath^doxygen.png" alt="doxygen" />
|
||||||
|
</a> $doxygenversion
|
||||||
|
</address>
|
||||||
|
</div>
|
||||||
|
<!--END !GENERATE_TREEVIEW-->
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<!-- HTML header for doxygen 1.8.17-->
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=9" />
|
||||||
|
<meta name="generator" content="Doxygen $doxygenversion" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<!--BEGIN PROJECT_NAME-->
|
||||||
|
<title>$projectname: $title</title>
|
||||||
|
<!--END PROJECT_NAME-->
|
||||||
|
<!--BEGIN !PROJECT_NAME-->
|
||||||
|
<title>$title</title>
|
||||||
|
<!--END !PROJECT_NAME-->
|
||||||
|
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css" />
|
||||||
|
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||||
|
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||||
|
$treeview
|
||||||
|
$search
|
||||||
|
$mathjax
|
||||||
|
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||||
|
$extrastylesheet
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="top">
|
||||||
|
<!-- do not remove this div, it is closed by doxygen! -->
|
||||||
|
|
||||||
|
<!--BEGIN TITLEAREA-->
|
||||||
|
<div id="titlearea">
|
||||||
|
<table cellspacing="0" cellpadding="0">
|
||||||
|
<tbody>
|
||||||
|
<tr style="height: 56px;">
|
||||||
|
<!--BEGIN PROJECT_LOGO-->
|
||||||
|
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo" /></td>
|
||||||
|
<!--END PROJECT_LOGO-->
|
||||||
|
<!--BEGIN PROJECT_NAME-->
|
||||||
|
<td id="projectalign" style="padding-left: 0.5em;">
|
||||||
|
<div id="projectname">$projectname
|
||||||
|
<!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span>
|
||||||
|
<!--END PROJECT_NUMBER-->
|
||||||
|
</div>
|
||||||
|
<!--BEGIN PROJECT_BRIEF-->
|
||||||
|
<div id="projectbrief">$projectbrief</div>
|
||||||
|
<!--END PROJECT_BRIEF-->
|
||||||
|
</td>
|
||||||
|
<!--END PROJECT_NAME-->
|
||||||
|
<!--BEGIN !PROJECT_NAME-->
|
||||||
|
<!--BEGIN PROJECT_BRIEF-->
|
||||||
|
<td style="padding-left: 0.5em;">
|
||||||
|
<div id="projectbrief">$projectbrief</div>
|
||||||
|
</td>
|
||||||
|
<!--END PROJECT_BRIEF-->
|
||||||
|
<!--END !PROJECT_NAME-->
|
||||||
|
<!--BEGIN DISABLE_INDEX-->
|
||||||
|
<!--BEGIN SEARCHENGINE-->
|
||||||
|
<td>$searchbox</td>
|
||||||
|
<!--END SEARCHENGINE-->
|
||||||
|
<!--END DISABLE_INDEX-->
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<!--END TITLEAREA-->
|
||||||
|
<!-- end header part -->
|
||||||
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
@@ -1,38 +0,0 @@
|
|||||||
<!-- HTML footer for doxygen 1.8.16-->
|
|
||||||
<!-- start footer part -->
|
|
||||||
<!--BEGIN GENERATE_TREEVIEW-->
|
|
||||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
||||||
<ul>
|
|
||||||
$navpath
|
|
||||||
<li class="footer">$generatedby
|
|
||||||
<a href="http://www.doxygen.org/index.html">
|
|
||||||
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/>
|
|
||||||
</a> $doxygenversion
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<!--END GENERATE_TREEVIEW-->
|
|
||||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
|
||||||
<div class="footer">
|
|
||||||
<hr class="footer"/>
|
|
||||||
<ul class="footer-info">
|
|
||||||
<li class="footer-info-lastmode">
|
|
||||||
This page was last modified on $datetime.
|
|
||||||
</li>
|
|
||||||
<li class="footer-info-copyright">
|
|
||||||
MentOs © 2014–2021 the MentOs team, and numerous contributors.<br>
|
|
||||||
It is available for use and modification under the 
|
|
||||||
<a href="$relpath^md_LICENSE.html">MIT License</a>.<br>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<hr class="footer"/>
|
|
||||||
<address class="footer">
|
|
||||||
$generatedby 
|
|
||||||
<a href="http://www.doxygen.org/index.html">
|
|
||||||
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/>
|
|
||||||
</a> $doxygenversion
|
|
||||||
</address>
|
|
||||||
</div>
|
|
||||||
<!--END !GENERATE_TREEVIEW-->
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
<!-- HTML header for doxygen 1.8.17-->
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
||||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
||||||
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title>
|
|
||||||
<!--END PROJECT_NAME-->
|
|
||||||
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
|
||||||
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
|
|
||||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
|
||||||
$treeview
|
|
||||||
$search
|
|
||||||
$mathjax
|
|
||||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css"/>
|
|
||||||
$extrastylesheet
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
||||||
|
|
||||||
<!--BEGIN TITLEAREA-->
|
|
||||||
<div id="titlearea">
|
|
||||||
<table cellspacing="0" cellpadding="0">
|
|
||||||
<tbody>
|
|
||||||
<tr style="height: 56px;">
|
|
||||||
<!--BEGIN PROJECT_LOGO-->
|
|
||||||
<td id="projectlogo"><img alt="Logo"
|
|
||||||
src="$relpath^$projectlogo"/></td>
|
|
||||||
<!--END PROJECT_LOGO-->
|
|
||||||
<!--BEGIN PROJECT_NAME-->
|
|
||||||
<td id="projectalign" style="padding-left: 0.5em;">
|
|
||||||
<div id="projectname">$projectname
|
|
||||||
<!--BEGIN PROJECT_NUMBER--> <span
|
|
||||||
id="projectnumber">$projectnumber</span>
|
|
||||||
<!--END PROJECT_NUMBER-->
|
|
||||||
</div>
|
|
||||||
<!--BEGIN PROJECT_BRIEF-->
|
|
||||||
<div id="projectbrief">$projectbrief</div>
|
|
||||||
<!--END PROJECT_BRIEF-->
|
|
||||||
</td>
|
|
||||||
<!--END PROJECT_NAME-->
|
|
||||||
<!--BEGIN !PROJECT_NAME-->
|
|
||||||
<!--BEGIN PROJECT_BRIEF-->
|
|
||||||
<td style="padding-left: 0.5em;">
|
|
||||||
<div id="projectbrief">$projectbrief</div>
|
|
||||||
</td>
|
|
||||||
<!--END PROJECT_BRIEF-->
|
|
||||||
<!--END !PROJECT_NAME-->
|
|
||||||
<!--BEGIN DISABLE_INDEX-->
|
|
||||||
<!--BEGIN SEARCHENGINE-->
|
|
||||||
<td>$searchbox</td>
|
|
||||||
<!--END SEARCHENGINE-->
|
|
||||||
<!--END DISABLE_INDEX-->
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<!--END TITLEAREA-->
|
|
||||||
<!-- end header part -->
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
|
||||||
|
#define KEY_LEFT_WIN 0xE05b
|
||||||
|
#define KEY_RIGHT_WIN 0xE05c
|
||||||
|
|
||||||
|
Normal Shifted Ctrl Alt
|
||||||
|
KEY_A 0x001E A 0x1E61 0x1E41 0x1E01 0x1E00
|
||||||
|
KEY_B 0x0030 B 0x3062 0x3042 0x3002 0x3000
|
||||||
|
KEY_C 0x002E C 0x2E63 0x2E42 0x2E03 0x2E00
|
||||||
|
KEY_D 0x0020 D 0x2064 0x2044 0x2004 0x2000
|
||||||
|
KEY_E 0x0012 E 0x1265 0x1245 0x1205 0x1200
|
||||||
|
KEY_F 0x0021 F 0x2166 0x2146 0x2106 0x2100
|
||||||
|
KEY_G 0x0022 G 0x2267 0x2247 0x2207 0x2200
|
||||||
|
KEY_H 0x0023 H 0x2368 0x2348 0x2308 0x2300
|
||||||
|
KEY_I 0x0017 I 0x1769 0x1749 0x1709 0x1700
|
||||||
|
KEY_J 0x0024 J 0x246A 0x244A 0x240A 0x2400
|
||||||
|
KEY_K 0x0025 K 0x256B 0x254B 0x250B 0x2500
|
||||||
|
KEY_L 0x0026 L 0x266C 0x264C 0x260C 0x2600
|
||||||
|
KEY_M 0x0032 M 0x326D 0x324D 0x320D 0x3200
|
||||||
|
KEY_N 0x0031 N 0x316E 0x314E 0x310E 0x3100
|
||||||
|
KEY_O 0x0018 O 0x186F 0x184F 0x180F 0x1800
|
||||||
|
KEY_P 0x0019 P 0x1970 0x1950 0x1910 0x1900
|
||||||
|
KEY_Q 0x0010 Q 0x1071 0x1051 0x1011 0x1000
|
||||||
|
KEY_R 0x0013 R 0x1372 0x1352 0x1312 0x1300
|
||||||
|
KEY_S 0x001F S 0x1F73 0x1F53 0x1F13 0x1F00
|
||||||
|
KEY_T 0x0014 T 0x1474 0x1454 0x1414 0x1400
|
||||||
|
KEY_U 0x0016 U 0x1675 0x1655 0x1615 0x1600
|
||||||
|
KEY_V 0x002F V 0x2F76 0x2F56 0x2F16 0x2F00
|
||||||
|
KEY_W 0x0011 W 0x1177 0x1157 0x1117 0x1100
|
||||||
|
KEY_X 0x002D X 0x2D78 0x2D58 0x2D18 0x2D00
|
||||||
|
KEY_Y 0x0015 Y 0x1579 0x1559 0x1519 0x1500
|
||||||
|
KEY_Z 0x002C Z 0x2C7A 0x2C5A 0x2C1A 0x2C00
|
||||||
|
|
||||||
|
KEY_1 0x0002 1 ! 0x0231 0x0221 0x0000 0x7800
|
||||||
|
KEY_2 0x0003 2 " 0x0332 0x0322 0x0300 0x7900
|
||||||
|
KEY_3 0x0004 3 £ 0x0433 0x049C 0x0000 0x7A00
|
||||||
|
KEY_4 0x0005 4 $ 0x0534 0x0524 0x0000 0x7B00
|
||||||
|
KEY_5 0x0006 5 % 0x0635 0x0625 0x0000 0x7C00
|
||||||
|
KEY_6 0x0007 6 & 0x0736 0x075E 0x071E 0x7D00
|
||||||
|
KEY_7 0x0008 7 / 0x0837 0x0826 0x0000 0x7E00
|
||||||
|
KEY_8 0x0009 8 ( 0x0938 0x0928 0x0000 0x7F00
|
||||||
|
KEY_9 0x000A 9 ) 0x0A39 0x0A29 0x0000 0x8000
|
||||||
|
KEY_0 0x000B 0 = 0x0B30 0x0B3D 0x0000 0x8100
|
||||||
|
|
||||||
|
KEY_GRAVE 0x0029 \ | 0x295C 0x297C 0x0000 0x2900
|
||||||
|
KEY_APOSTROPHE 0x000C ' ? 0x0C27 0x0C3F 0x0000 0x8200
|
||||||
|
KEY_I_ACC 0x000D ì ^ 0x0D8D 0x0D5E 0x0000 0x8300
|
||||||
|
KEY_LEFT_BRAKET 0x001A è é [ 0x1A8A 0x1A82 0x0000 0x1A5B
|
||||||
|
KEY_RIGHT_BRAKET 0x001B + * ] 0x1B2B 0x1B2A 0x0000 0x1B5D
|
||||||
|
KEY_SEMICOLON 0x0027 ò ç @ 0x2795 0x2780 0x0000 0x2740
|
||||||
|
KEY_DOUBLE_QUOTES 0x0028 à ° # 0x2885 0x28A7 0x0000 0x2823
|
||||||
|
KEY_BACKSLASH 0x002B ù § 0x2B97 0x2BA7 0x0000 0x2B00
|
||||||
|
KEY_KP_LESS 0x0056 < > 0x563C 0x563E 0x0000 0x5600
|
||||||
|
KEY_COMMA 0x0033 , ; 0x332C 0x333B 0x0000 0x3300
|
||||||
|
KEY_PERIOD 0x0034 . : 0x342E 0x343A 0x0000 0x3400
|
||||||
|
KEY_MINUS 0x0035 - _ 0x352D 0x355F 0x0000 0x3500
|
||||||
|
|
||||||
|
KEY_F1 0x003B F1 0x3B00 0x5400 0x5E00 0x6800
|
||||||
|
KEY_F2 0x003C F2 0x3C00 0x5500 0x5F00 0x6900
|
||||||
|
KEY_F3 0x003D F3 0x3D00 0x5600 0x6000 0x6A00
|
||||||
|
KEY_F4 0x003E F4 0x3E00 0x5700 0x6100 0x6B00
|
||||||
|
KEY_F5 0x003F F5 0x3F00 0x5800 0x6200 0x6C00
|
||||||
|
KEY_F6 0x0040 F6 0x4000 0x5900 0x6300 0x6D00
|
||||||
|
KEY_F7 0x0041 F7 0x4100 0x5A00 0x6400 0x6E00
|
||||||
|
KEY_F8 0x0042 F8 0x4200 0x5B00 0x6500 0x6F00
|
||||||
|
KEY_F9 0x0043 F9 0x4300 0x5C00 0x6600 0x7000
|
||||||
|
KEY_F10 0x0044 F10 0x4400 0x5D00 0x6700 0x7100
|
||||||
|
KEY_F11 0x0057 F11 0x5700 0x5900 0x5B00 0x5D00
|
||||||
|
KEY_F12 0x0058 F12 0x5800 0x5A00 0x5C00 0x5E00
|
||||||
|
|
||||||
|
KEY_BACKSPACE 0x000E BackSpace 0x0E08 0x0E08 0x0E7F 0x0E00
|
||||||
|
KEY_ENTER 0x001C Enter 0x1C0D 0x1C0D 0x1C0A 0xA600
|
||||||
|
KEY_ESCAPE 0x0001 Esc 0x011B 0x011B 0x011B 0x0100
|
||||||
|
KEY_TAB 0x000F Tab 0x0F09 0x0F00 0x9400 0xA500
|
||||||
|
KEY_SPACE 0x0039 SpaceBar 0x3920 0x3920 0x3920 0x3920
|
||||||
|
|
||||||
|
KEY_INSERT 0xE052 Ins 0x5200 0x5230 0x9200 0xA200
|
||||||
|
KEY_HOME 0xE047 Home 0x4700 0x4737 0x7700 0x9700
|
||||||
|
KEY_PAGE_UP 0xE049 PgUp 0x4900 0x4939 0x8400 0x9900
|
||||||
|
KEY_DELETE 0xE053 Del 0x5300 0x532E 0x9300 0xA300
|
||||||
|
KEY_END 0xE04F End 0x4F00 0x4F31 0x7500 0x9F00
|
||||||
|
KEY_PAGE_DOWN 0xE051 PgDn 0x5100 0x5133 0x7600 0xA100
|
||||||
|
|
||||||
|
KEY_UP_ARROW 0xE048 Up Arrow 0x4800 0x4838 0x8D00 0x9800
|
||||||
|
KEY_DOWN_ARROW 0xE050 Down Arrow 0x5000 0x5032 0x9100 0xA000
|
||||||
|
KEY_LEFT_ARROW 0xE04B Left Arrow 0x4B00 0x4B34 0x7300 0x9B00
|
||||||
|
KEY_RIGHT_ARROW 0xE04D Right Arrow 0x4D00 0x4D36 0x7400 0x9D00
|
||||||
|
|
||||||
|
KEY_KP_DIV 0xE035 Kp.Div 0xE035 0xE035 0x3500 0x3500
|
||||||
|
KEY_KP_MUL 0x0037 Kp.Mul 0x372A 0x372A 0x3700 0x3700
|
||||||
|
KEY_KP_SUB 0x004A Kp.Sub 0x4A2D 0x4A2D 0x4A00 0x4A00
|
||||||
|
KEY_KP_ADD 0x004E Kp.Add 0x4E2B 0x4E2B 0x4E00 0x4E00
|
||||||
|
KEY_KP_RETURN 0xE01C Kp.Enter 0xE01C 0xE01C 0x1C00 0x1C00
|
||||||
|
|
||||||
|
KEY_KP7 0x0047 0x4737 0x4737 0x4700 0x4700
|
||||||
|
KEY_KP8 0x0048 0x4838 0x4838 0x4800 0x4800
|
||||||
|
KEY_KP9 0x0049 0x4939 0x4939 0x4900 0x4900
|
||||||
|
KEY_KP4 0x004B 0x4B34 0x4B34 0x4B00 0x4B00
|
||||||
|
KEY_KP5 0x004C 0x4C35 0x4C35 0x4C00 0x4C00
|
||||||
|
KEY_KP6 0x004D 0x4D36 0x4D36 0x4D00 0x4D00
|
||||||
|
KEY_KP1 0x004F 0x4F31 0x4F31 0x4F00 0x4F00
|
||||||
|
KEY_KP2 0x0050 0x5032 0x5032 0x5000 0x5000
|
||||||
|
KEY_KP3 0x0051 0x5133 0x5133 0x5100 0x5100
|
||||||
|
KEY_KP0 0x0052 0x5230 0x5230 0x5200 0x5200
|
||||||
|
|
||||||
|
KEY_KP_DEC 0x0053 0x532E 0x532E 0x5300 0x5300
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Call `man` to have a list of all the commands.
|
||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
root:root:0:0:Root User:/:/bin/shell
|
root:root:0:0:Root User:/root:/bin/shell
|
||||||
user:user:1000:1000:Normal User:/home/user:/bin/shell
|
user:user:1000:1000:Normal User:/home/user:/bin/shell
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
NAME
|
||||||
|
ls - list directory contents
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
ls [OPTIONS] [FILE/FOLDER]
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
List information about the given file, or the files contained in the given
|
||||||
|
folder. If not argument is provided it will list information about files
|
||||||
|
inside the current folder.
|
||||||
|
|
||||||
|
OPTIONS
|
||||||
|
-a : list all entries.
|
||||||
|
-l : show the entries as a detailed list.
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Initialize the project.
|
|
||||||
project(initfscp C)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Set the project name.
|
|
||||||
set(PROJECT_NAME initfscp)
|
|
||||||
|
|
||||||
if (CMAKE_CROSSCOMPILING)
|
|
||||||
set(CMAKE_C_COMPILER gcc)
|
|
||||||
set(CMAKE_CXX_COMPILER g++)
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "")
|
|
||||||
endif (CMAKE_CROSSCOMPILING)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Set the compiler options (original).
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Add the source files.
|
|
||||||
set(SOURCE_FILES src/initfscp.c)
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Add the executable.
|
|
||||||
add_executable(initfscp ${SOURCE_FILES})
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
----
|
|
||||||
README
|
|
||||||
initfscp - Autore di questa guida: Aleksej
|
|
||||||
----
|
|
||||||
|
|
||||||
initfscp e' un programma che serve a creare un'immagine contenente il file system utilizzato da MentOS.
|
|
||||||
Consente di inserirci dei files e/o dei mountpoint (massimo 32) all'interno.
|
|
||||||
Per far ciò digitare il comando "initfscp [-m mountpoint1 -m mountpoint2 ... -m mountpoint n] file1 file2 ... nomefs"
|
|
||||||
|
|
||||||
dove:
|
|
||||||
- -m mountpoint1 -m mountpoint2 ... -m mountpoint n (facoltativo) indicano i mountpoint da inserire nel filesystem appena creato.
|
|
||||||
- "file1 file2 ..." sono i files che inseriremo nel filesystem,
|
|
||||||
- "nomefs" è il nome che daremo all'immagine.
|
|
||||||
Ad esempio vogliamo inserire i file topolino, pippo e paperino nell'immagine che chiameremo disney, quindi digitiamo:
|
|
||||||
initfscp topolino pippo paperino disney
|
|
||||||
così facendo initfscp genererà l'immagine disney.
|
|
||||||
|
|
||||||
Altri comandi disponibili:
|
|
||||||
--help (-h) per visualizzare una guida più sintetica.
|
|
||||||
--version (-v) per visualizzare la versione utilizzata attualmente di initfscp.
|
|
||||||
@@ -1,404 +0,0 @@
|
|||||||
/// @file initfscp.c
|
|
||||||
/// @brief
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#define INITFSCP_VER "0.3.0"
|
|
||||||
|
|
||||||
#define INITRD_NAME_MAX 255
|
|
||||||
#define INITRD_MAX_FILES 128
|
|
||||||
#define INITRD_MAX_FS_SIZE 1048576
|
|
||||||
|
|
||||||
#define RESET "\033[00m"
|
|
||||||
#define BLACK "\033[30m"
|
|
||||||
#define RED "\033[31m"
|
|
||||||
#define GREEN "\033[32m"
|
|
||||||
#define YELLOW "\033[33m"
|
|
||||||
#define BLUE "\033[34m"
|
|
||||||
#define MAGENTA "\033[35m"
|
|
||||||
#define CYAN "\033[36m"
|
|
||||||
#define WHITE "\033[37m"
|
|
||||||
|
|
||||||
static const char dt_char_array[] = {
|
|
||||||
'?', // DT_UNKNOWN = 0,
|
|
||||||
'p', //DT_FIFO = 1,
|
|
||||||
'c', //DT_CHR = 2,
|
|
||||||
'*',
|
|
||||||
'd', //DT_DIR = 4,
|
|
||||||
'*',
|
|
||||||
'b', //DT_BLK = 6,
|
|
||||||
'*',
|
|
||||||
'-', //DT_REG = 8,
|
|
||||||
'*',
|
|
||||||
'l', //DT_LNK = 10,
|
|
||||||
'*',
|
|
||||||
's', //DT_SOCK = 12,
|
|
||||||
'*',
|
|
||||||
'?', //DT_WHT = 14
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief Information concerning a file.
|
|
||||||
typedef struct initrd_file_t {
|
|
||||||
/// Number used as delimiter, it must be set to 0xBF.
|
|
||||||
int magic;
|
|
||||||
/// The inode of the file.
|
|
||||||
unsigned int inode;
|
|
||||||
/// The name of the file.
|
|
||||||
char name[INITRD_NAME_MAX];
|
|
||||||
/// The type of the file.
|
|
||||||
short int file_type;
|
|
||||||
/// The permissions mask.
|
|
||||||
unsigned int mask;
|
|
||||||
/// The id of the owner.
|
|
||||||
unsigned int uid;
|
|
||||||
/// The id of the group.
|
|
||||||
unsigned int gid;
|
|
||||||
/// Time of last access.
|
|
||||||
unsigned int atime;
|
|
||||||
/// Time of last data modification.
|
|
||||||
unsigned int mtime;
|
|
||||||
/// Time of last status change.
|
|
||||||
unsigned int ctime;
|
|
||||||
/// Offset of the starting address.
|
|
||||||
unsigned int offset;
|
|
||||||
/// Dimension of the file.
|
|
||||||
unsigned int length;
|
|
||||||
} __attribute__((aligned(16))) initrd_file_t;
|
|
||||||
|
|
||||||
/// @brief The details regarding the filesystem.
|
|
||||||
/// @brief Contains the number of files inside the initrd filesystem.
|
|
||||||
typedef struct initrd_t {
|
|
||||||
/// Number of files.
|
|
||||||
unsigned int nfiles;
|
|
||||||
/// List of headers.
|
|
||||||
initrd_file_t headers[INITRD_MAX_FILES];
|
|
||||||
} __attribute__((aligned(16))) initrd_t;
|
|
||||||
|
|
||||||
// Prepare a variable to keep track of the offsets inside the FS. By
|
|
||||||
// default skip the initial space for the FS details structure.
|
|
||||||
static int fs_offset = sizeof(initrd_t);
|
|
||||||
|
|
||||||
static inline void usage(char *prgname)
|
|
||||||
{
|
|
||||||
printf("Usage:\n");
|
|
||||||
printf(" %s --help For this screen\n", prgname);
|
|
||||||
printf(" %s --source [-s] The source directory.\n", prgname);
|
|
||||||
printf(" %s --target [-t] The target file for the initrd.\n", prgname);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void version(char *prgname)
|
|
||||||
{
|
|
||||||
printf("%s version: %s\n", prgname, INITFSCP_VER);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int is_option_mount_point(char *arg)
|
|
||||||
{
|
|
||||||
return ((strcmp(arg, "-m") == 0) || (strcmp(arg, "--mountpoint") == 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int is_option_source(char *arg)
|
|
||||||
{
|
|
||||||
return ((strcmp(arg, "-s") == 0) || (strcmp(arg, "--source") == 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int is_option_target(char *arg)
|
|
||||||
{
|
|
||||||
return ((strcmp(arg, "-t") == 0) || (strcmp(arg, "--target") == 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int open_target_fs(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
printf("%-64s", "Opening target filesystem...");
|
|
||||||
int fd = -1;
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
|
||||||
if (is_option_target(argv[i]) && ((i + 1) < argc)) {
|
|
||||||
fd = open(argv[i + 1], O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fd == -1)
|
|
||||||
printf("[" RED "FAILED" RESET "]\n\n");
|
|
||||||
else
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void init_headers(initrd_t *initrd)
|
|
||||||
{
|
|
||||||
printf("%-64s", "Initializing headers structures...");
|
|
||||||
for (size_t i = 0; i < INITRD_MAX_FILES; i++) {
|
|
||||||
initrd->headers[i].magic = 0xBF;
|
|
||||||
initrd->headers[i].inode = i;
|
|
||||||
initrd->headers[i].file_type = 0;
|
|
||||||
initrd->headers[i].mask = 0;
|
|
||||||
initrd->headers[i].uid = 0;
|
|
||||||
initrd->headers[i].gid = 0;
|
|
||||||
initrd->headers[i].atime = time(NULL);
|
|
||||||
initrd->headers[i].mtime = time(NULL);
|
|
||||||
initrd->headers[i].ctime = time(NULL);
|
|
||||||
initrd->headers[i].offset = 0;
|
|
||||||
initrd->headers[i].length = 0;
|
|
||||||
|
|
||||||
memset(initrd->headers[i].name, 0, INITRD_NAME_MAX);
|
|
||||||
}
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static int create_file_headers(initrd_t *initrd, char *mountpoint, char *directory)
|
|
||||||
{
|
|
||||||
assert(mountpoint && "Received null mountpoint.");
|
|
||||||
assert(directory && "Received null directory.");
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
char directory_path_abs[PATH_MAX], entry_path_abs[PATH_MAX], fs_abs_path[PATH_MAX];
|
|
||||||
memset(directory_path_abs, 0, PATH_MAX);
|
|
||||||
memset(entry_path_abs, 0, PATH_MAX);
|
|
||||||
memset(fs_abs_path, 0, PATH_MAX);
|
|
||||||
strcpy(directory_path_abs, mountpoint);
|
|
||||||
strcat(directory_path_abs, directory);
|
|
||||||
|
|
||||||
int dir_fd = open(directory_path_abs, O_RDONLY);
|
|
||||||
if (dir_fd == -1) {
|
|
||||||
printf("[" RED "FAILED" RESET "]\n");
|
|
||||||
printf("Could not open source directory %s.\n", directory_path_abs);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
char buffer[BUFSIZ], *ebuf;
|
|
||||||
off_t basep;
|
|
||||||
int nbytes;
|
|
||||||
while ((nbytes = getdirentries(dir_fd, buffer, BUFSIZ, &basep)) > 0) {
|
|
||||||
ebuf = buffer + nbytes;
|
|
||||||
char *cp = buffer;
|
|
||||||
while (cp < ebuf) {
|
|
||||||
struct dirent *entry = (struct dirent *)cp;
|
|
||||||
if ((strcmp(entry->d_name, ".") == 0) || (strcmp(entry->d_name, "..") == 0)) {
|
|
||||||
cp += entry->d_reclen;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Create the host machine absolute path.
|
|
||||||
strcpy(entry_path_abs, directory_path_abs);
|
|
||||||
strcat(entry_path_abs, "/");
|
|
||||||
strcat(entry_path_abs, entry->d_name);
|
|
||||||
// Create the filesystem absolute path.
|
|
||||||
strcpy(fs_abs_path, directory);
|
|
||||||
strcat(fs_abs_path, "/");
|
|
||||||
strcat(fs_abs_path, entry->d_name);
|
|
||||||
// Print the entry.
|
|
||||||
printf("[%3d] ENTRY: %-52s", initrd->nfiles, fs_abs_path);
|
|
||||||
// Stat the file.
|
|
||||||
struct stat _stat;
|
|
||||||
if (stat(entry_path_abs, &_stat) == -1) {
|
|
||||||
printf("[" RED "FAILED" RESET "]\n");
|
|
||||||
printf("Error while executing stat on file : %s\n", entry_path_abs);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
printf("[%c%c%c%c%c%c%c%c%c%c]",
|
|
||||||
dt_char_array[entry->d_type],
|
|
||||||
(_stat.st_mode & S_IRUSR) != 0 ? 'r' : '-',
|
|
||||||
(_stat.st_mode & S_IWUSR) != 0 ? 'w' : '-',
|
|
||||||
(_stat.st_mode & S_IXUSR) != 0 ? 'x' : '-',
|
|
||||||
(_stat.st_mode & S_IRGRP) != 0 ? 'r' : '-',
|
|
||||||
(_stat.st_mode & S_IWGRP) != 0 ? 'w' : '-',
|
|
||||||
(_stat.st_mode & S_IXGRP) != 0 ? 'x' : '-',
|
|
||||||
(_stat.st_mode & S_IROTH) != 0 ? 'r' : '-',
|
|
||||||
(_stat.st_mode & S_IWOTH) != 0 ? 'w' : '-',
|
|
||||||
(_stat.st_mode & S_IXOTH) != 0 ? 'x' : '-');
|
|
||||||
|
|
||||||
if (entry->d_type != DT_DIR) {
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
// Copy the name and the main info.
|
|
||||||
strcpy(initrd->headers[initrd->nfiles].name, fs_abs_path);
|
|
||||||
initrd->headers[initrd->nfiles].file_type = DT_REG;
|
|
||||||
initrd->headers[initrd->nfiles].length = _stat.st_size;
|
|
||||||
initrd->headers[initrd->nfiles].offset = fs_offset;
|
|
||||||
initrd->headers[initrd->nfiles].mask = _stat.st_mode;
|
|
||||||
initrd->headers[initrd->nfiles].uid = _stat.st_uid;
|
|
||||||
initrd->headers[initrd->nfiles].gid = _stat.st_gid;
|
|
||||||
initrd->headers[initrd->nfiles].atime = _stat.st_atim.tv_sec;
|
|
||||||
initrd->headers[initrd->nfiles].mtime = _stat.st_mtim.tv_sec;
|
|
||||||
initrd->headers[initrd->nfiles].ctime = _stat.st_ctim.tv_sec;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
printf("[OFFSET:%6d]", initrd->headers[initrd->nfiles].offset);
|
|
||||||
printf("[SIZE:%6d]", initrd->headers[initrd->nfiles].length);
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n");
|
|
||||||
|
|
||||||
fs_offset += initrd->headers[initrd->nfiles].length;
|
|
||||||
++initrd->nfiles;
|
|
||||||
} else {
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
strcpy(initrd->headers[initrd->nfiles].name, fs_abs_path);
|
|
||||||
initrd->headers[initrd->nfiles].file_type = DT_DIR;
|
|
||||||
initrd->headers[initrd->nfiles].length = _stat.st_size;
|
|
||||||
initrd->headers[initrd->nfiles].offset = fs_offset;
|
|
||||||
initrd->headers[initrd->nfiles].mask = _stat.st_mode;
|
|
||||||
initrd->headers[initrd->nfiles].uid = _stat.st_uid;
|
|
||||||
initrd->headers[initrd->nfiles].gid = _stat.st_gid;
|
|
||||||
initrd->headers[initrd->nfiles].atime = _stat.st_atim.tv_sec;
|
|
||||||
initrd->headers[initrd->nfiles].mtime = _stat.st_mtim.tv_sec;
|
|
||||||
initrd->headers[initrd->nfiles].ctime = _stat.st_ctim.tv_sec;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
printf("[OFFSET:%6d]", initrd->headers[initrd->nfiles].offset);
|
|
||||||
printf("[SIZE:%6d]", initrd->headers[initrd->nfiles].length);
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n");
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
++initrd->nfiles;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
if (!create_file_headers(initrd, mountpoint, fs_abs_path)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cp += entry->d_reclen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(dir_fd);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int write_file_system(initrd_t *initrd, int target_fd, char *mountpoint)
|
|
||||||
{
|
|
||||||
printf("Copying data to filesystem...\n");
|
|
||||||
for (int i = 0; i < INITRD_MAX_FILES; i++) {
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
char absolute_path[256];
|
|
||||||
memset(absolute_path, 0, 256);
|
|
||||||
strcpy(absolute_path, mountpoint);
|
|
||||||
strcat(absolute_path, initrd->headers[i].name);
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
if (initrd->headers[i].file_type == DT_REG) {
|
|
||||||
FILE *fd2 = fopen(absolute_path, "r+");
|
|
||||||
if (fd2 == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
printf("[%3d] FILE: %-92s", i, absolute_path);
|
|
||||||
char *buffer = (char *)malloc(initrd->headers[i].length);
|
|
||||||
fread(buffer, 1, initrd->headers[i].length, fd2);
|
|
||||||
// Write the content.
|
|
||||||
write(target_fd, buffer, initrd->headers[i].length);
|
|
||||||
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n");
|
|
||||||
fclose(fd2);
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
printf("Welcome to MentOS initrd file copier tool\n\n");
|
|
||||||
if (argc <= 1) {
|
|
||||||
if (argv[0][0] == '.') {
|
|
||||||
version(argv[0] + 2);
|
|
||||||
}
|
|
||||||
usage(argv[0]);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
if (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")) {
|
|
||||||
version(argv[0] + 2);
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
if (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
|
|
||||||
usage(argv[0]);
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the filesystem details structure.
|
|
||||||
initrd_t initrd;
|
|
||||||
// Target fs file descriptor.
|
|
||||||
int target_fd;
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Open the fs.
|
|
||||||
if ((target_fd = open_target_fs(argc, argv)) == -1) {
|
|
||||||
printf("Could not open target FileSystem.\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Initialize the headers.
|
|
||||||
init_headers(&initrd);
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Create file headers.
|
|
||||||
printf("Creating headers...\n");
|
|
||||||
for (unsigned int i = 1; i < argc; ++i) {
|
|
||||||
if (is_option_source(argv[i]) && ((i + 1) < argc)) {
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
strcpy(initrd.headers[initrd.nfiles].name, "/");
|
|
||||||
initrd.headers[initrd.nfiles].file_type = DT_DIR;
|
|
||||||
initrd.headers[initrd.nfiles].length = 0;
|
|
||||||
initrd.headers[initrd.nfiles].offset = fs_offset;
|
|
||||||
initrd.headers[initrd.nfiles].mask = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
|
||||||
initrd.headers[initrd.nfiles].uid = 0;
|
|
||||||
initrd.headers[initrd.nfiles].gid = 0;
|
|
||||||
initrd.headers[initrd.nfiles].atime = time(NULL);
|
|
||||||
initrd.headers[initrd.nfiles].mtime = time(NULL);
|
|
||||||
initrd.headers[initrd.nfiles].ctime = time(NULL);
|
|
||||||
|
|
||||||
printf("[%3d] DIR : %-52s", initrd.nfiles, initrd.headers[initrd.nfiles].name);
|
|
||||||
printf("[" BLUE "OPEN" RESET "]");
|
|
||||||
printf("[OFFSET:%6d]", initrd.headers[initrd.nfiles].offset);
|
|
||||||
printf("[SIZE:%6d]", initrd.headers[initrd.nfiles].length);
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n");
|
|
||||||
++initrd.nfiles;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
|
||||||
if (!create_file_headers(&initrd, argv[i + 1], "")) {
|
|
||||||
printf("Could not create file headers.\n");
|
|
||||||
close(target_fd);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Copying information about headers on filesystem.
|
|
||||||
printf("%-64s", "Copying the filesystem's details structure...");
|
|
||||||
write(target_fd, &initrd, sizeof(initrd_t));
|
|
||||||
printf("[" GREEN "DONE" RESET "]\n\n");
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
// Write headers on filesystem.
|
|
||||||
for (unsigned int i = 1; i < argc; ++i) {
|
|
||||||
if (is_option_source(argv[i]) && ((i + 1) < argc)) {
|
|
||||||
if (!write_file_system(&initrd, target_fd, argv[i + 1])) {
|
|
||||||
printf("Could not write on filesystem.\n");
|
|
||||||
close(target_fd);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
lseek(target_fd, 0L, SEEK_SET);
|
|
||||||
size_t fs_size = lseek(target_fd, 0L, SEEK_END);
|
|
||||||
printf("FS size : %ld\n", fs_size);
|
|
||||||
if (fs_size < INITRD_MAX_FS_SIZE - 1) {
|
|
||||||
printf("Extend FS size to : %d\n", INITRD_MAX_FS_SIZE - 1);
|
|
||||||
lseek(target_fd, INITRD_MAX_FS_SIZE - 1, SEEK_SET);
|
|
||||||
write(target_fd, 0, 1);
|
|
||||||
}
|
|
||||||
close(target_fd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
set timeout=1
|
||||||
|
set default=0
|
||||||
|
|
||||||
|
menuentry "MentOS" {
|
||||||
|
multiboot /boot/kernel-bootloader.bin
|
||||||
|
boot
|
||||||
|
}
|
||||||
+31
-23
@@ -2,27 +2,20 @@
|
|||||||
# Author: Enrico Fraccaroli
|
# Author: Enrico Fraccaroli
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Set the minimum required version of cmake.
|
# Set the minimum required version of cmake.
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 3.1...3.22)
|
||||||
# Initialize the project.
|
# Initialize the project.
|
||||||
project(libc C ASM)
|
project(libc C ASM)
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Set the default build type to Debug.
|
# ASSEMBLY
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
message(STATUS "Setting build type to 'Debug' as none was specified.")
|
|
||||||
set(CMAKE_BUILD_TYPE
|
|
||||||
"Debug"
|
|
||||||
CACHE STRING "Choose the type of build." FORCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
# Enable the assembly language.
|
# Enable the assembly language.
|
||||||
enable_language(ASM)
|
enable_language(ASM)
|
||||||
# Find the NASM compiler.
|
# Find the NASM compiler.
|
||||||
find_program(ASM_COMPILER
|
find_program(ASM_COMPILER NAMES nasm HINTS /usr/bin/ /usr/local/bin/)
|
||||||
NAMES nasm
|
# Mark the variable ASM_COMPILER as advanced.
|
||||||
HINTS /usr/bin/ ${CMAKE_SOURCE_DIR}/third_party/nasm/bin
|
mark_as_advanced(ASM_COMPILER)
|
||||||
)
|
|
||||||
# Check that we have found the compiler.
|
# Check that we have found the compiler.
|
||||||
if(NOT ASM_COMPILER)
|
if(NOT ASM_COMPILER)
|
||||||
message(FATAL_ERROR "ASM compiler not found!")
|
message(FATAL_ERROR "ASM compiler not found!")
|
||||||
@@ -42,25 +35,40 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|||||||
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
# C WARNINGs
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
# Warning flags.
|
# Warning flags.
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||||
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
|
||||||
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic-errors")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic-errors")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
||||||
|
|
||||||
|
# Disable some specific warnings.
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
|
||||||
# Set the C compiler options.
|
# Set the compiler options.
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdlib")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdlib")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-pic")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||||
|
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
|
||||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
|
||||||
@@ -89,24 +97,25 @@ add_library(
|
|||||||
${PROJECT_SOURCE_DIR}/src/setenv.c
|
${PROJECT_SOURCE_DIR}/src/setenv.c
|
||||||
${PROJECT_SOURCE_DIR}/src/assert.c
|
${PROJECT_SOURCE_DIR}/src/assert.c
|
||||||
${PROJECT_SOURCE_DIR}/src/abort.c
|
${PROJECT_SOURCE_DIR}/src/abort.c
|
||||||
|
|
||||||
${PROJECT_SOURCE_DIR}/src/io/mm_io.c
|
${PROJECT_SOURCE_DIR}/src/io/mm_io.c
|
||||||
${PROJECT_SOURCE_DIR}/src/io/port_io.c
|
${PROJECT_SOURCE_DIR}/src/io/port_io.c
|
||||||
|
|
||||||
${PROJECT_SOURCE_DIR}/src/ipc/ipc.c
|
${PROJECT_SOURCE_DIR}/src/ipc/ipc.c
|
||||||
|
|
||||||
${PROJECT_SOURCE_DIR}/src/sys/unistd.c
|
${PROJECT_SOURCE_DIR}/src/sys/unistd.c
|
||||||
${PROJECT_SOURCE_DIR}/src/sys/errno.c
|
${PROJECT_SOURCE_DIR}/src/sys/errno.c
|
||||||
${PROJECT_SOURCE_DIR}/src/sys/utsname.c
|
${PROJECT_SOURCE_DIR}/src/sys/utsname.c
|
||||||
${PROJECT_SOURCE_DIR}/src/sys/ioctl.c
|
${PROJECT_SOURCE_DIR}/src/sys/ioctl.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/unistd/creat.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/getppid.c
|
${PROJECT_SOURCE_DIR}/src/unistd/getppid.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/getpid.c
|
${PROJECT_SOURCE_DIR}/src/unistd/getpid.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/exit.c
|
${PROJECT_SOURCE_DIR}/src/unistd/exit.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/setsid.c
|
${PROJECT_SOURCE_DIR}/src/unistd/setsid.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/getsid.c
|
${PROJECT_SOURCE_DIR}/src/unistd/getsid.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/unistd/setpgid.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/unistd/getpgid.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/setgid.c
|
${PROJECT_SOURCE_DIR}/src/unistd/setgid.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/getgid.c
|
${PROJECT_SOURCE_DIR}/src/unistd/getgid.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/unistd/setuid.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/unistd/getuid.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/fork.c
|
${PROJECT_SOURCE_DIR}/src/unistd/fork.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/read.c
|
${PROJECT_SOURCE_DIR}/src/unistd/read.c
|
||||||
${PROJECT_SOURCE_DIR}/src/unistd/write.c
|
${PROJECT_SOURCE_DIR}/src/unistd/write.c
|
||||||
@@ -129,7 +138,6 @@ add_library(
|
|||||||
${PROJECT_SOURCE_DIR}/src/unistd/interval.c
|
${PROJECT_SOURCE_DIR}/src/unistd/interval.c
|
||||||
${PROJECT_SOURCE_DIR}/src/libc_start.c
|
${PROJECT_SOURCE_DIR}/src/libc_start.c
|
||||||
${PROJECT_SOURCE_DIR}/src/debug.c
|
${PROJECT_SOURCE_DIR}/src/debug.c
|
||||||
|
|
||||||
${PROJECT_SOURCE_DIR}/src/crt0.S
|
${PROJECT_SOURCE_DIR}/src/crt0.S
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/// @file array.h
|
||||||
|
/// @brief
|
||||||
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
/// Function for allocating memory for the array.
|
||||||
|
#define ARRAY_ALLOC kmalloc
|
||||||
|
/// Function for freeing the memory for the array.
|
||||||
|
#define ARRAY_FREE kfree
|
||||||
|
#else
|
||||||
|
/// Function for allocating memory for the array.
|
||||||
|
#define ARRAY_ALLOC malloc
|
||||||
|
/// Function for freeing the memory for the array.
|
||||||
|
#define ARRAY_FREE free
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// @brief Declares a new dynamic-size array structure.
|
||||||
|
#define DECLARE_ARRAY(type, name) \
|
||||||
|
typedef struct arr_##name##_t { \
|
||||||
|
const unsigned size; \
|
||||||
|
type *buffer; \
|
||||||
|
} arr_##name##_t; \
|
||||||
|
arr_##name##_t alloc_arr_##name(unsigned len) \
|
||||||
|
{ \
|
||||||
|
arr_##name##_t a = { len, len > 0 ? ARRAY_ALLOC(sizeof(type) * len) : NULL }; \
|
||||||
|
memset(a.buffer, 0, sizeof(type) * len); \
|
||||||
|
return a; \
|
||||||
|
} \
|
||||||
|
static inline void free_arr_##name(arr_##name##_t *arr) \
|
||||||
|
{ \
|
||||||
|
ARRAY_FREE(arr->buffer); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef ARRAY_ALLOC malloc
|
||||||
|
#undef ARRAY_FREE free
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file assert.h
|
/// @file assert.h
|
||||||
/// @brief Defines the function and pre-processor macro for assertions.
|
/// @brief Defines the function and pre-processor macro for assertions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/// @file ioctls.h
|
/// @file ioctls.h
|
||||||
/// @brief Input/Output ConTroL (IOCTL) numbers.
|
/// @brief Input/Output ConTroL (IOCTL) numbers.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stat.h
|
/// @file stat.h
|
||||||
/// @brief Defines the structure used by the functiosn fstat(), lstat(), and stat().
|
/// @brief Defines the structure used by the functiosn fstat(), lstat(), and stat().
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file termios-struct.h
|
/// @file termios-struct.h
|
||||||
/// @brief Definition of the `termios` structure.
|
/// @brief Definition of the `termios` structure.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -25,21 +24,23 @@ typedef struct termios {
|
|||||||
cc_t c_cc[NCCS]; ///< control characters
|
cc_t c_cc[NCCS]; ///< control characters
|
||||||
speed_t c_ispeed; ///< input speed
|
speed_t c_ispeed; ///< input speed
|
||||||
speed_t c_ospeed; ///< output speed
|
speed_t c_ospeed; ///< output speed
|
||||||
} termios;
|
} termios_t;
|
||||||
|
|
||||||
/// @brief These flags generally control higher-level aspects of input processing than the input
|
//These flags generally control higher-level aspects of input processing than
|
||||||
/// modes flags described in Input Modes, such as echoing, signals, and the choice of canonical
|
// the input modes flags described in Input Modes, such as echoing, signals, and
|
||||||
/// or noncanonical input.
|
// the choice of canonical or noncanonical input.
|
||||||
enum {
|
|
||||||
ISIG = 000001U, ///< Controls whether the INTR, QUIT, and SUSP characters are recognized.
|
#define ISIG 0x00000080 ///< Controls whether the INTR, QUIT, and SUSP characters are recognized.
|
||||||
ICANON = 000002U, ///< Enables canonical input processing mode.
|
#define ICANON 0x00000100 ///< Enables canonical input processing mode.
|
||||||
ECHO = 000010U, ///< Echo input characters.
|
#define ECHO 0x00000008 ///< Echo input characters.
|
||||||
ECHOE = 000020U, ///< If ICANON is set, the ERASE character erases the preceding character.
|
#define ECHOE 0x00000002 ///< If ICANON is set, the ERASE character erases the preceding character.
|
||||||
ECHOK = 000040U, ///< If ICANON is set, the KILL character erases the current line.
|
#define ECHOK 0x00000004 ///< If ICANON is set, the KILL character erases the current line.
|
||||||
ECHONL = 000100U, ///< If ICANON is set, echo the NL character even if ECHO is not set.
|
#define ECHONL 0x00000010 ///< If ICANON is set, echo the NL character even if ECHO is not set.
|
||||||
NOFLSH = 000200U, ///< Do not clear in/out queues when receiving INTR, QUIT, and SUSP.
|
#define NOFLSH 0x80000000 ///< Do not clear in/out queues when receiving INTR, QUIT, and SUSP.
|
||||||
TOSTOP = 000400U, ///< Allows SIGTTOU signals generated by background processes.
|
#define TOSTOP 0x00400000 ///< Allows SIGTTOU signals generated by background processes.
|
||||||
ECHOCTL = 001000U, ///< If this and ECHO are set, control characters with ‘^’ are echoed.
|
#define ECHOCTL 0x00000040 ///< If this and ECHO are set, control characters with ‘^’ are echoed.
|
||||||
ECHOKE = 004000U, ///< If ICANON is set, KILL is echoed by erasing each character on the line.
|
#define ECHOKE 0x00000001 ///< If ICANON is set, KILL is echoed by erasing each character on the line.
|
||||||
IEXTEN = 100000U, ///< Enables implementation-defined input processing.
|
#define IEXTEN 0x00000400 ///< Enables implementation-defined input processing.
|
||||||
};
|
|
||||||
|
/// @brief Mask for extracting control values.
|
||||||
|
#define CTRL(x) (x & 037)
|
||||||
+6
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file ctype.h
|
/// @file ctype.h
|
||||||
/// @brief Functions related to character handling.
|
/// @brief Functions related to character handling.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -16,6 +15,11 @@ int isdigit(int c);
|
|||||||
/// @return 1 on success, 0 otherwise.
|
/// @return 1 on success, 0 otherwise.
|
||||||
int isalpha(int c);
|
int isalpha(int c);
|
||||||
|
|
||||||
|
/// @brief Check if the given value is a control character.
|
||||||
|
/// @param c The input character.
|
||||||
|
/// @return 1 on success, 0 otherwise.
|
||||||
|
int iscntrl(int c);
|
||||||
|
|
||||||
/// @brief Check if the given value is either a letter or a digit.
|
/// @brief Check if the given value is either a letter or a digit.
|
||||||
/// @param c The input character.
|
/// @param c The input character.
|
||||||
/// @return 1 on success, 0 otherwise.
|
/// @return 1 on success, 0 otherwise.
|
||||||
|
|||||||
+4
-4
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file debug.h
|
/// @file debug.h
|
||||||
/// @brief Debugging primitives.
|
/// @brief Debugging primitives.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -36,9 +35,10 @@ void dbg_printf(const char *file, const char *fun, int line, const char *format,
|
|||||||
const char *to_human_size(unsigned long bytes);
|
const char *to_human_size(unsigned long bytes);
|
||||||
|
|
||||||
/// @brief Transforms the given value to a binary string.
|
/// @brief Transforms the given value to a binary string.
|
||||||
/// @param value The decimal value.
|
/// @param value to print.
|
||||||
|
/// @param length of the binary output.
|
||||||
/// @return String representing the binary value.
|
/// @return String representing the binary value.
|
||||||
const char *dec_to_binary(unsigned long value);
|
const char *dec_to_binary(unsigned long value, unsigned length);
|
||||||
|
|
||||||
/// Prints a debugging message.
|
/// Prints a debugging message.
|
||||||
#define pr_debug(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__ __VA_ARGS__)
|
#define pr_debug(...) dbg_printf(__FILENAME__, __func__, __LINE__, __DEBUG_HEADER__ __VA_ARGS__)
|
||||||
|
|||||||
+16
-16
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file fcntl.h
|
/// @file fcntl.h
|
||||||
/// @brief Headers of functions fcntl() and open().
|
/// @brief Headers of functions fcntl() and open().
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -20,20 +19,21 @@
|
|||||||
/// @brief The file modes.
|
/// @brief The file modes.
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
#define S_IRWXU 0000700U ///< RWX mask for user.
|
#define S_ISUID 0x0800 ///< Set user id on execution
|
||||||
#define S_IRUSR 0000400U ///< R for user.
|
#define S_ISGID 0x0400 ///< Set group id on execution
|
||||||
#define S_IWUSR 0000200U ///< W for user.
|
#define S_ISVTX 0x0200 ///< Save swapped text even after use (Sticky Bit)
|
||||||
#define S_IXUSR 0000100U ///< X for user.
|
#define S_IRWXU 0x01C0 ///< rwx------- : User can read/write/execute
|
||||||
|
#define S_IRUSR 0x0100 ///< -r-------- : User can read
|
||||||
#define S_IRWXG 0000070U ///< RWX mask for group.
|
#define S_IWUSR 0x0080 ///< --w------- : User can write
|
||||||
#define S_IRGRP 0000040U ///< R for group.
|
#define S_IXUSR 0x0040 ///< ---x------ : User can execute
|
||||||
#define S_IWGRP 0000020U ///< W for group.
|
#define S_IRWXG 0x0038 ///< ----rwx--- : Group can read/write/execute
|
||||||
#define S_IXGRP 0000010U ///< X for group.
|
#define S_IRGRP 0x0020 ///< ----r----- : Group can read
|
||||||
|
#define S_IWGRP 0x0010 ///< -----w---- : Group can write
|
||||||
#define S_IRWXO 0000007U ///< RWX mask for group.
|
#define S_IXGRP 0x0008 ///< ------x--- : Group can execute
|
||||||
#define S_IROTH 0000004U ///< R for group.
|
#define S_IRWXO 0x0007 ///< -------rwx : Others can read/write/execute
|
||||||
#define S_IWOTH 0000002U ///< W for group.
|
#define S_IROTH 0x0004 ///< -------r-- : Others can read
|
||||||
#define S_IXOTH 0000001U ///< X for group.
|
#define S_IWOTH 0x0002 ///< --------w- : Others can write
|
||||||
|
#define S_IXOTH 0x0001 ///< ---------x : Others can execute
|
||||||
|
|
||||||
#define S_ISDIR(m) (((m)&0170000) == 0040000) ///< directory.
|
#define S_ISDIR(m) (((m)&0170000) == 0040000) ///< directory.
|
||||||
#define S_ISCHR(m) (((m)&0170000) == 0020000) ///< char special
|
#define S_ISCHR(m) (((m)&0170000) == 0020000) ///< char special
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file fcvt.h
|
/// @file fcvt.h
|
||||||
/// @brief Declare the functions required to turn double values into a string.
|
/// @brief Declare the functions required to turn double values into a string.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+52
-56
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file grp.h
|
/// @file grp.h
|
||||||
/// @brief Defines the structures and functions for managing groups.
|
/// @brief Defines the structures and functions for managing groups.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -11,66 +10,63 @@
|
|||||||
/// Maximum number of users per group
|
/// Maximum number of users per group
|
||||||
#define MAX_MEMBERS_PER_GROUP 64
|
#define MAX_MEMBERS_PER_GROUP 64
|
||||||
|
|
||||||
///@brief Contains user group informations
|
/// @brief Contains user group informations.
|
||||||
typedef struct group{
|
typedef struct group {
|
||||||
|
/// The name of the group.
|
||||||
|
char *gr_name;
|
||||||
|
/// Encrypted password.
|
||||||
|
char *gr_passwd;
|
||||||
|
/// Group ID.
|
||||||
|
gid_t gr_gid;
|
||||||
|
/// List of group members.
|
||||||
|
char *gr_mem[MAX_MEMBERS_PER_GROUP + 1];
|
||||||
|
} group_t;
|
||||||
|
|
||||||
char* gr_name; // the name of the group
|
/// @brief Provides access to the group database entry for `uid`.
|
||||||
gid_t gr_gid; // numerical group ID
|
/// @param gid The gid to search inside the database.
|
||||||
char* gr_passwd; // password
|
/// @return A pointer to the structure containing the database entry.
|
||||||
|
group_t *getgrgid(gid_t gid);
|
||||||
|
|
||||||
//pointer to a null-terminated array of character pointers to member names
|
/// @brief Provides access to the group database entry for `name`.
|
||||||
char* gr_mem[MAX_MEMBERS_PER_GROUP + 1];
|
/// @param name The name to search inside the database.
|
||||||
|
/// @return A pointer to the structure containing the database entry.
|
||||||
} group;
|
group_t *getgrnam(const char *name);
|
||||||
|
|
||||||
///@brief Provides access to the group database entry for `uid`.
|
/// @brief Provides the same information as getgrgid but it stores the results
|
||||||
///@param gid The gid to search inside the database.
|
/// inside group, and the string information are store store inside `buf`.
|
||||||
///@return A pointer to the structure containing the database entry.
|
/// @param gid The uid to search inside the database.
|
||||||
struct group* getgrgid(gid_t gid);
|
/// @param group The structure containing pointers to the entry fields.
|
||||||
|
/// @param buf The buffer where the strings should be stored.
|
||||||
|
/// @param buflen The lenght of the buffer.
|
||||||
|
/// @param result A pointer to the result or NULL is stored here.
|
||||||
|
/// @return If the entry was found returns zero and set *result to group, if the
|
||||||
|
/// entry was not found returns zero and set *result to NULL, on failure returns
|
||||||
|
/// a number and sets and set *result to NULL.
|
||||||
|
int getgrgid_r(gid_t gid, group_t *group, char *buf, size_t buflen, group_t **result);
|
||||||
|
|
||||||
///@brief Provides access to the group database entry for `name`.
|
/// @brief Provides the same information as getgrnam but it stores the results
|
||||||
///@param name The name to search inside the database.
|
///inside group, and the string information are store store inside `buf`.
|
||||||
///@return A pointer to the structure containing the database entry.
|
/// @param name The name to search inside the database.
|
||||||
struct group* getgrnam(const char* name);
|
/// @param group The structure containing pointers to the entry fields.
|
||||||
|
/// @param buf The buffer where the strings should be stored.
|
||||||
|
/// @param buflen The lenght of the buffer.
|
||||||
|
/// @param result A pointer to the result or NULL is stored here.
|
||||||
|
/// @return If the entry was found returns zero and set *result to group, if the
|
||||||
|
/// entry was not found returns zero and set *result to NULL, on failure returns
|
||||||
|
/// a number and sets and set *result to NULL.
|
||||||
|
int getgrnam_r(const char *name, group_t *group, char *buf, size_t buflen, group_t **result);
|
||||||
|
|
||||||
///@brief Provides the same information as getgrgid but it stores the
|
/// @brief Returns a pointer to a structure containing the broken-out fields of
|
||||||
/// results inside group, and the string information are store store
|
/// an entry in the group database.
|
||||||
/// inside `buf`.
|
/// @return pointer to the group entry.
|
||||||
///@param gid The uid to search inside the database.
|
/// @details When first called returns a pointer to a group structure containing
|
||||||
///@param group The structure containing pointers to the entry fields.
|
/// the first entry in the group database. Thereafter, it returns a pointer to a
|
||||||
///@param buf The buffer where the strings should be stored.
|
/// group structure containing the next group structure in the group database,
|
||||||
///@param buflen The lenght of the buffer.
|
/// so successive calls may be used to search the entire database.
|
||||||
///@param result A pointer to the result or NULL is stored here.
|
group_t *getgrent(void);
|
||||||
///@return If the entry was found returns zero and set *result to group,
|
|
||||||
/// if the entry was not found returns zero and set *result to NULL,
|
|
||||||
/// on failure returns a number and sets and set *result to NULL.
|
|
||||||
int getgrgid_r(gid_t gid, struct group* group, char* buf, size_t buflen, struct group ** result);
|
|
||||||
|
|
||||||
///@brief Provides the same information as getgrnam but it stores the
|
/// @brief Rewinds the group database to allow repeated searches.
|
||||||
/// results inside group, and the string information are store store
|
|
||||||
/// inside `buf`.
|
|
||||||
///@param name The name to search inside the database.
|
|
||||||
///@param group The structure containing pointers to the entry fields.
|
|
||||||
///@param buf The buffer where the strings should be stored.
|
|
||||||
///@param buflen The lenght of the buffer.
|
|
||||||
///@param result A pointer to the result or NULL is stored here.
|
|
||||||
///@return If the entry was found returns zero and set *result to group,
|
|
||||||
/// if the entry was not found returns zero and set *result to NULL,
|
|
||||||
/// on failure returns a number and sets and set *result to NULL.
|
|
||||||
int getgrnam_r(const char* name, struct group* group, char* buf, size_t buflen, struct group** result);
|
|
||||||
|
|
||||||
|
|
||||||
///@brief Returns a pointer to a structure containing the broken-out
|
|
||||||
/// fields of an entry in the group database.
|
|
||||||
/// When first called returns a pointer to a group structure
|
|
||||||
/// containing the first entry in the group database.
|
|
||||||
/// Thereafter, it returns a pointer to a group structure
|
|
||||||
/// containing the next group structure in the group database,
|
|
||||||
/// so successive calls may be used to search the entire database.
|
|
||||||
struct group* getgrent(void);
|
|
||||||
|
|
||||||
///@brief Rewinds the group database to allow repeated searches.
|
|
||||||
void endgrent(void);
|
void endgrent(void);
|
||||||
|
|
||||||
///@brief May be called to close the group database when processing is complete.
|
/// @brief May be called to close the group database when processing is complete.
|
||||||
void setgrent(void);
|
void setgrent(void);
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file mm_io.h
|
/// @file mm_io.h
|
||||||
/// @brief Memory Mapped IO functions.
|
/// @brief Memory Mapped IO functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file port_io.h
|
/// @file port_io.h
|
||||||
/// @brief Byte I/O on ports prototypes.
|
/// @brief Byte I/O on ports prototypes.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file ipc.h
|
/// @file ipc.h
|
||||||
/// @brief Inter-Process Communication (IPC) structures.
|
/// @brief Inter-Process Communication (IPC) structures.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+67
-12
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file msg.h
|
/// @file msg.h
|
||||||
/// @brief Definition of structure for managing message queues.
|
/// @brief Definition of structure for managing message queues.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -18,15 +17,15 @@ typedef unsigned int msgqnum_t;
|
|||||||
typedef unsigned int msglen_t;
|
typedef unsigned int msglen_t;
|
||||||
|
|
||||||
/// @brief Buffer to use with the message queue IPC.
|
/// @brief Buffer to use with the message queue IPC.
|
||||||
struct msgbuf {
|
typedef struct msgbuf {
|
||||||
/// Type of the message.
|
/// Type of the message.
|
||||||
long mtype;
|
long mtype;
|
||||||
/// Text of the message.
|
/// Text of the message.
|
||||||
char mtext[1];
|
char mtext[1];
|
||||||
};
|
} msgbuf_t;
|
||||||
|
|
||||||
/// @brief Message queue data structure.
|
/// @brief Message queue data structure.
|
||||||
struct msqid_ds {
|
typedef struct msqid_ds {
|
||||||
/// Ownership and permissions.
|
/// Ownership and permissions.
|
||||||
struct ipc_perm msg_perm;
|
struct ipc_perm msg_perm;
|
||||||
/// Time of last msgsnd(2).
|
/// Time of last msgsnd(2).
|
||||||
@@ -45,26 +44,82 @@ struct msqid_ds {
|
|||||||
pid_t msg_lspid;
|
pid_t msg_lspid;
|
||||||
/// PID of last msgrcv(2).
|
/// PID of last msgrcv(2).
|
||||||
pid_t msg_lrpid;
|
pid_t msg_lrpid;
|
||||||
};
|
} msqid_ds_t;
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
|
/// @brief Get a System V message queue identifier.
|
||||||
|
/// @param key can be used either to obtain the identifier of a previously
|
||||||
|
/// created message queue, or to create a new set.
|
||||||
|
/// @param msgflg controls the behaviour of the function.
|
||||||
|
/// @return the message queue identifier, -1 on failure, and errno is set to
|
||||||
|
/// indicate the error.
|
||||||
long sys_msgget(key_t key, int msgflg);
|
long sys_msgget(key_t key, int msgflg);
|
||||||
|
|
||||||
long sys_msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg);
|
/// @brief Used to send messages.
|
||||||
|
/// @param msqid the message queue identifier.
|
||||||
|
/// @param msgp points to a used-defined msgbuf.
|
||||||
|
/// @param msgsz specifies the size in bytes of mtext.
|
||||||
|
/// @param msgflg specifies the action to be taken in case of specific events.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
|
long sys_msgsnd(int msqid, msgbuf_t *msgp, size_t msgsz, int msgflg);
|
||||||
|
|
||||||
long sys_msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg);
|
/// @brief Used to receive messages.
|
||||||
|
/// @param msqid the message queue identifier.
|
||||||
|
/// @param msgp points to a used-defined msgbuf.
|
||||||
|
/// @param msgsz specifies the size in bytes of mtext.
|
||||||
|
/// @param msgtyp specifies the type of message requested, as follows:
|
||||||
|
/// - msgtyp == 0: the first message on the queue is received.
|
||||||
|
/// - msgtyp > 0: the first message of type, msgtyp, is received.
|
||||||
|
/// - msgtyp < 0: the first message of the lowest type that is less than or
|
||||||
|
/// equal to the absolute value of msgtyp is received.
|
||||||
|
/// @param msgflg specifies the action to be taken in case of specific events.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
|
long sys_msgrcv(int msqid, msgbuf_t *msgp, size_t msgsz, long msgtyp, int msgflg);
|
||||||
|
|
||||||
long sys_msgctl(int msqid, int cmd, struct msqid_ds *buf);
|
/// @brief Message queue control operations.
|
||||||
|
/// @param msqid the message queue identifier.
|
||||||
|
/// @param cmd The command to perform.
|
||||||
|
/// @param buf used with IPC_STAT and IPC_SET.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
|
long sys_msgctl(int msqid, int cmd, msqid_ds_t *buf);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
/// @brief Get a System V message queue identifier.
|
||||||
|
/// @param key can be used either to obtain the identifier of a previously
|
||||||
|
/// created message queue, or to create a new set.
|
||||||
|
/// @param msgflg controls the behaviour of the function.
|
||||||
|
/// @return the message queue identifier, -1 on failure, and errno is set to
|
||||||
|
/// indicate the error.
|
||||||
long msgget(key_t key, int msgflg);
|
long msgget(key_t key, int msgflg);
|
||||||
|
|
||||||
long msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg);
|
/// @brief Used to send messages.
|
||||||
|
/// @param msqid the message queue identifier.
|
||||||
|
/// @param msgp points to a used-defined msgbuf.
|
||||||
|
/// @param msgsz specifies the size in bytes of mtext.
|
||||||
|
/// @param msgflg specifies the action to be taken in case of specific events.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
|
long msgsnd(int msqid, msgbuf_t *msgp, size_t msgsz, int msgflg);
|
||||||
|
|
||||||
long msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg);
|
/// @brief Used to receive messages.
|
||||||
|
/// @param msqid the message queue identifier.
|
||||||
|
/// @param msgp points to a used-defined msgbuf.
|
||||||
|
/// @param msgsz specifies the size in bytes of mtext.
|
||||||
|
/// @param msgtyp specifies the type of message requested, as follows:
|
||||||
|
/// - msgtyp == 0: the first message on the queue is received.
|
||||||
|
/// - msgtyp > 0: the first message of type, msgtyp, is received.
|
||||||
|
/// - msgtyp < 0: the first message of the lowest type that is less than or
|
||||||
|
/// equal to the absolute value of msgtyp is received.
|
||||||
|
/// @param msgflg specifies the action to be taken in case of specific events.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
|
long msgrcv(int msqid, msgbuf_t *msgp, size_t msgsz, long msgtyp, int msgflg);
|
||||||
|
|
||||||
long msgctl(int msqid, int cmd, struct msqid_ds *buf);
|
/// @brief Message queue control operations.
|
||||||
|
/// @param msqid the message queue identifier.
|
||||||
|
/// @param cmd The command to perform.
|
||||||
|
/// @param buf used with IPC_STAT and IPC_SET.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
|
long msgctl(int msqid, int cmd, msqid_ds_t *buf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+37
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file sem.h
|
/// @file sem.h
|
||||||
/// @brief Definition of structure for managing semaphores.
|
/// @brief Definition of structure for managing semaphores.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -23,18 +22,54 @@ struct sembuf {
|
|||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
|
/// @brief Get a System V semaphore set identifier.
|
||||||
|
/// @param key can be used either to obtain the identifier of a previously
|
||||||
|
/// created semaphore set, or to create a new set.
|
||||||
|
/// @param nsems number of semaphores.
|
||||||
|
/// @param semflg controls the behaviour of the function.
|
||||||
|
/// @return the semaphore set identifier, -1 on failure, and errno is set to
|
||||||
|
/// indicate the error.
|
||||||
long sys_semget(key_t key, int nsems, int semflg);
|
long sys_semget(key_t key, int nsems, int semflg);
|
||||||
|
|
||||||
|
/// @brief Performs operations on selected semaphores in the set.
|
||||||
|
/// @param semid the semaphore set identifier.
|
||||||
|
/// @param sops specifies operations to be performed on single semaphores.
|
||||||
|
/// @param nsops number of operations.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
long sys_semop(int semid, struct sembuf *sops, unsigned nsops);
|
long sys_semop(int semid, struct sembuf *sops, unsigned nsops);
|
||||||
|
|
||||||
|
/// @brief Performs control operations on a semaphore set.
|
||||||
|
/// @param semid the semaphore set identifier.
|
||||||
|
/// @param semnum the n-th semaphore of the set on which we perform the operations.
|
||||||
|
/// @param cmd the command to perform.
|
||||||
|
/// @param arg
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
long sys_semctl(int semid, int semnum, int cmd, unsigned long arg);
|
long sys_semctl(int semid, int semnum, int cmd, unsigned long arg);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
/// @brief Get a System V semaphore set identifier.
|
||||||
|
/// @param key can be used either to obtain the identifier of a previously
|
||||||
|
/// created semaphore set, or to create a new set.
|
||||||
|
/// @param nsems number of semaphores.
|
||||||
|
/// @param semflg controls the behaviour of the function.
|
||||||
|
/// @return the semaphore set identifier, -1 on failure, and errno is set to
|
||||||
|
/// indicate the error.
|
||||||
long semget(key_t key, int nsems, int semflg);
|
long semget(key_t key, int nsems, int semflg);
|
||||||
|
|
||||||
|
/// @brief Performs operations on selected semaphores in the set.
|
||||||
|
/// @param semid the semaphore set identifier.
|
||||||
|
/// @param sops specifies operations to be performed on single semaphores.
|
||||||
|
/// @param nsops number of operations.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
long semop(int semid, struct sembuf *sops, unsigned nsops);
|
long semop(int semid, struct sembuf *sops, unsigned nsops);
|
||||||
|
|
||||||
|
/// @brief Performs control operations on a semaphore set.
|
||||||
|
/// @param semid the semaphore set identifier.
|
||||||
|
/// @param semnum the n-th semaphore of the set on which we perform the operations.
|
||||||
|
/// @param cmd the command to perform.
|
||||||
|
/// @param arg
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
long semctl(int semid, int semnum, int cmd, unsigned long arg);
|
long semctl(int semid, int semnum, int cmd, unsigned long arg);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+57
-8
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file shm.h
|
/// @file shm.h
|
||||||
/// @brief Definition of structure for managing shared memories.
|
/// @brief Definition of structure for managing shared memories.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -136,22 +135,72 @@ struct shmid_ds *find_shm_fromvaddr(void *shmvaddr);
|
|||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
|
||||||
long sys_shmat(int shmid, char *shmaddr, int shmflg);
|
/// @brief Get a System V shared memory identifier.
|
||||||
|
/// @param key can be used either to obtain the identifier of a previously
|
||||||
|
/// created shared memory, or to create a new one.
|
||||||
|
/// @param size of the shared memory, rounded up to a multiple of PAGE_SIZE.
|
||||||
|
/// @param flag controls the behaviour of the function.
|
||||||
|
/// @return the shared memory identifier, -1 on failure, and errno is set to
|
||||||
|
/// indicate the error.
|
||||||
long sys_shmget(key_t key, size_t size, int flag);
|
long sys_shmget(key_t key, size_t size, int flag);
|
||||||
|
|
||||||
long sys_shmdt(char *shmaddr);
|
/// @brief Attaches the shared memory segment identified by shmid to the address
|
||||||
|
/// space of the calling process.
|
||||||
|
/// @param shmid the shared memory identifier.
|
||||||
|
/// @param shmaddr the attaching address.
|
||||||
|
/// @param shmflg controls the behaviour of the function.
|
||||||
|
/// @return returns the address of the attached shared memory segment; on error
|
||||||
|
/// (void *) -1 is returned, and errno is set to indicate the error.
|
||||||
|
void * sys_shmat(int shmid, const void *shmaddr, int shmflg);
|
||||||
|
|
||||||
|
/// @brief Detaches the shared memory segment located at the address specified
|
||||||
|
/// by shmaddr from the address space of the calling process
|
||||||
|
/// @param shmaddr the address of the shared memory segment.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
|
long sys_shmdt(const void *shmaddr);
|
||||||
|
|
||||||
|
/// @brief Performs the control operation specified by cmd on the shared memory
|
||||||
|
/// segment whose identifier is given in shmid.
|
||||||
|
/// @param shmid the shared memory identifier.
|
||||||
|
/// @param cmd the command to perform.
|
||||||
|
/// @param buf is a pointer to a shmid_ds structure.
|
||||||
|
/// @return a non-negative value basedon on the requested operation, -1 on
|
||||||
|
/// failure and errno is set to indicate the error.
|
||||||
long sys_shmctl(int shmid, int cmd, struct shmid_ds *buf);
|
long sys_shmctl(int shmid, int cmd, struct shmid_ds *buf);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
long shmat(int shmid, char *shmaddr, int shmflg);
|
/// @brief Get a System V shared memory identifier.
|
||||||
|
/// @param key can be used either to obtain the identifier of a previously
|
||||||
|
/// created shared memory, or to create a new one.
|
||||||
|
/// @param size of the shared memory, rounded up to a multiple of PAGE_SIZE.
|
||||||
|
/// @param flag controls the behaviour of the function.
|
||||||
|
/// @return the shared memory identifier, -1 on failure, and errno is set to
|
||||||
|
/// indicate the error.
|
||||||
long shmget(key_t key, size_t size, int flag);
|
long shmget(key_t key, size_t size, int flag);
|
||||||
|
|
||||||
long shmdt(char *shmaddr);
|
/// @brief Attaches the shared memory segment identified by shmid to the address
|
||||||
|
/// space of the calling process.
|
||||||
|
/// @param shmid the shared memory identifier.
|
||||||
|
/// @param shmaddr the attaching address.
|
||||||
|
/// @param shmflg controls the behaviour of the function.
|
||||||
|
/// @return returns the address of the attached shared memory segment; on error
|
||||||
|
/// (void *) -1 is returned, and errno is set to indicate the error.
|
||||||
|
void * shmat(int shmid, const void *shmaddr, int shmflg);
|
||||||
|
|
||||||
|
/// @brief Detaches the shared memory segment located at the address specified
|
||||||
|
/// by shmaddr from the address space of the calling process
|
||||||
|
/// @param shmaddr the address of the shared memory segment.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
|
long shmdt(const void *shmaddr);
|
||||||
|
|
||||||
|
/// @brief Performs the control operation specified by cmd on the shared memory
|
||||||
|
/// segment whose identifier is given in shmid.
|
||||||
|
/// @param shmid the shared memory identifier.
|
||||||
|
/// @param cmd the command to perform.
|
||||||
|
/// @param buf is a pointer to a shmid_ds structure.
|
||||||
|
/// @return a non-negative value basedon on the requested operation, -1 on
|
||||||
|
/// failure and errno is set to indicate the error.
|
||||||
long shmctl(int shmid, int cmd, struct shmid_ds *buf);
|
long shmctl(int shmid, int cmd, struct shmid_ds *buf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file libgen.h
|
/// @file libgen.h
|
||||||
/// @brief String routines.
|
/// @brief String routines.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file limits.h
|
/// @file limits.h
|
||||||
/// @brief OS numeric limits.
|
/// @brief OS numeric limits.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file math.h
|
/// @file math.h
|
||||||
/// @brief Mathematical constants and functions.
|
/// @brief Mathematical constants and functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file pwd.h
|
/// @file pwd.h
|
||||||
/// @brief Contains the structure and functions for managing passwords.
|
/// @brief Contains the structure and functions for managing passwords.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
/// @file ring_buffer.h
|
||||||
|
/// @brief
|
||||||
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// @brief Declares a fixed-size ring-buffer.
|
||||||
|
#define DECLARE_FIXED_SIZE_RING_BUFFER(type, name, length, init) \
|
||||||
|
typedef struct fs_rb_##name##_t { \
|
||||||
|
unsigned size, read, write; \
|
||||||
|
type buffer[length]; \
|
||||||
|
} fs_rb_##name##_t; \
|
||||||
|
static inline void fs_rb_##name##_init(fs_rb_##name##_t *rb) \
|
||||||
|
{ \
|
||||||
|
rb->size = length; \
|
||||||
|
rb->read = rb->write = 0; \
|
||||||
|
char *dst = (char *)rb->buffer; \
|
||||||
|
long num = sizeof(type) * length; \
|
||||||
|
while (num--) *dst++ = (char)(init & 0xFF); \
|
||||||
|
} \
|
||||||
|
static inline unsigned fs_rb_##name##_step(fs_rb_##name##_t *rb, unsigned index) \
|
||||||
|
{ \
|
||||||
|
return (index == (rb->size - 1)) ? 0 : index + 1; \
|
||||||
|
} \
|
||||||
|
static inline void fs_rb_##name##_push_front(fs_rb_##name##_t *rb, type item) \
|
||||||
|
{ \
|
||||||
|
if (fs_rb_##name##_step(rb, rb->write) == rb->read) \
|
||||||
|
rb->read = fs_rb_##name##_step(rb, rb->read); \
|
||||||
|
rb->buffer[rb->write] = item; \
|
||||||
|
rb->write = fs_rb_##name##_step(rb, rb->write); \
|
||||||
|
} \
|
||||||
|
static inline type fs_rb_##name##_empty(fs_rb_##name##_t *rb) \
|
||||||
|
{ \
|
||||||
|
return rb->write == rb->read; \
|
||||||
|
} \
|
||||||
|
static inline type fs_rb_##name##_pop_back(fs_rb_##name##_t *rb) \
|
||||||
|
{ \
|
||||||
|
type item = init; \
|
||||||
|
if (!fs_rb_##name##_empty(rb)) { \
|
||||||
|
item = rb->buffer[rb->read]; \
|
||||||
|
rb->read = fs_rb_##name##_step(rb, rb->read); \
|
||||||
|
} \
|
||||||
|
return item; \
|
||||||
|
} \
|
||||||
|
static inline type fs_rb_##name##_pop_front(fs_rb_##name##_t *rb) \
|
||||||
|
{ \
|
||||||
|
if (fs_rb_##name##_empty(rb)) \
|
||||||
|
return init; \
|
||||||
|
rb->write = (rb->write > 0) ? rb->write - 1 : rb->size - 1; \
|
||||||
|
return rb->buffer[rb->write]; \
|
||||||
|
} \
|
||||||
|
static inline type fs_rb_##name##_get(fs_rb_##name##_t *rb, unsigned index) \
|
||||||
|
{ \
|
||||||
|
if (index < rb->size) \
|
||||||
|
return rb->buffer[index]; \
|
||||||
|
return init; \
|
||||||
|
} \
|
||||||
|
static inline type fs_rb_##name##_back(fs_rb_##name##_t *rb) \
|
||||||
|
{ \
|
||||||
|
if (fs_rb_##name##_empty(rb)) \
|
||||||
|
return init; \
|
||||||
|
return rb->buffer[rb->read]; \
|
||||||
|
} \
|
||||||
|
static inline type fs_rb_##name##_front(fs_rb_##name##_t *rb) \
|
||||||
|
{ \
|
||||||
|
if (fs_rb_##name##_empty(rb)) \
|
||||||
|
return init; \
|
||||||
|
return rb->buffer[(rb->write > 0) ? rb->write - 1 : rb->size - 1]; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __KERNEL__
|
||||||
|
/// Function for allocating memory for the ring buffer.
|
||||||
|
#define RING_BUFFER_ALLOC kmalloc
|
||||||
|
/// Function for freeing the memory for the ring buffer.
|
||||||
|
#define RING_BUFFER_FREE kfree
|
||||||
|
#else
|
||||||
|
/// Function for allocating memory for the ring buffer.
|
||||||
|
#define RING_BUFFER_ALLOC malloc
|
||||||
|
/// Function for freeing the memory for the ring buffer.
|
||||||
|
#define RING_BUFFER_FREE free
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// @brief Declares a dynamic-size ring-buffer.
|
||||||
|
#define DECLARE_RING_BUFFER(type, name, init) \
|
||||||
|
typedef struct rb_##name##_t { \
|
||||||
|
const unsigned size; \
|
||||||
|
unsigned read, write; \
|
||||||
|
type *buffer; \
|
||||||
|
} rb_##name##_t; \
|
||||||
|
static inline rb_##name##_t alloc_rb_##name(unsigned len) \
|
||||||
|
{ \
|
||||||
|
rb_##name##_t rb = { len, 0U, 0U, len > 0 ? RING_BUFFER_ALLOC(sizeof(type) * len) : NULL }; \
|
||||||
|
memset(rb.buffer, init, sizeof(type) * len); \
|
||||||
|
return rb; \
|
||||||
|
} \
|
||||||
|
static inline void free_rb_##name(rb_##name##_t *rb) \
|
||||||
|
{ \
|
||||||
|
RING_BUFFER_FREE(rb->buffer); \
|
||||||
|
} \
|
||||||
|
static inline unsigned step_rb_##name(rb_##name##_t *rb, unsigned index) \
|
||||||
|
{ \
|
||||||
|
return (index == (rb->size - 1)) ? 0 : index + 1; \
|
||||||
|
} \
|
||||||
|
static inline void push_rb_##name(rb_##name##_t *rb, type item) \
|
||||||
|
{ \
|
||||||
|
if (step_rb_##name(rb, rb->write) == rb->read) \
|
||||||
|
rb->read = step_rb_##name(rb, rb->read); \
|
||||||
|
rb->buffer[rb->write] = item; \
|
||||||
|
rb->write = step_rb_##name(rb, rb->write); \
|
||||||
|
} \
|
||||||
|
static inline void pop_rb_##name(rb_##name##_t *rb, type *item) \
|
||||||
|
{ \
|
||||||
|
*item = init; \
|
||||||
|
if (rb->write != rb->read) { \
|
||||||
|
*item = rb->buffer[rb->read]; \
|
||||||
|
rb->read = step_rb_##name(rb, rb->read); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
static inline void get_rb_##name(rb_##name##_t *rb, unsigned index, type *item) \
|
||||||
|
{ \
|
||||||
|
if (index < rb->size) \
|
||||||
|
*item = rb->buffer[index]; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef RING_BUFFER_ALLOC
|
||||||
|
#undef RING_BUFFER_FREE
|
||||||
+16
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file sched.h
|
/// @file sched.h
|
||||||
/// @brief Structures and functions for managing the scheduler.
|
/// @brief Structures and functions for managing the scheduler.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "sys/types.h"
|
#include "sys/types.h"
|
||||||
@@ -22,8 +21,23 @@ typedef struct sched_param_t {
|
|||||||
bool_t is_periodic;
|
bool_t is_periodic;
|
||||||
} sched_param_t;
|
} sched_param_t;
|
||||||
|
|
||||||
|
/// @brief Sets scheduling parameters.
|
||||||
|
/// @param pid pid of the process we want to change the parameters. If zero,
|
||||||
|
/// then the parameters of the calling process are set.
|
||||||
|
/// @param param The interpretation of the argument param depends on the
|
||||||
|
/// scheduling policy of the thread identified by pid.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
int sched_setparam(pid_t pid, const sched_param_t *param);
|
int sched_setparam(pid_t pid, const sched_param_t *param);
|
||||||
|
|
||||||
|
/// @brief Gets scheduling parameters.
|
||||||
|
/// @param pid pid of the process we want to retrieve the parameters. If zero,
|
||||||
|
/// then the parameters of the calling process are returned.
|
||||||
|
/// @param param The interpretation of the argument param depends on the
|
||||||
|
/// scheduling policy of the thread identified by pid.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
int sched_getparam(pid_t pid, sched_param_t *param);
|
int sched_getparam(pid_t pid, sched_param_t *param);
|
||||||
|
|
||||||
|
/// @brief Placed at the end of an infinite while loop, stops the process until,
|
||||||
|
/// its next period starts. The calling process must be a periodic one.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
int waitperiod();
|
int waitperiod();
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file signal.h
|
/// @file signal.h
|
||||||
/// @brief Signals definition.
|
/// @brief Signals definition.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stdarg.h
|
/// @file stdarg.h
|
||||||
/// @brief Contains the macros required to manage variable number of arguments.
|
/// @brief Contains the macros required to manage variable number of arguments.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stdbool.h
|
/// @file stdbool.h
|
||||||
/// @brief Defines the boolean values.
|
/// @brief Defines the boolean values.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stddef.h
|
/// @file stddef.h
|
||||||
/// @brief Define basic data types.
|
/// @brief Define basic data types.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stdint.h
|
/// @file stdint.h
|
||||||
/// @brief Standard integer data-types.
|
/// @brief Standard integer data-types.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+2
-5
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stdio.h
|
/// @file stdio.h
|
||||||
/// @brief Standard I/0 functions.
|
/// @brief Standard I/0 functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -23,6 +22,7 @@
|
|||||||
#define SEEK_CUR 1 ///< The file offset is set to its current location plus offset bytes.
|
#define SEEK_CUR 1 ///< The file offset is set to its current location plus offset bytes.
|
||||||
#define SEEK_END 2 ///< The file offset is set to the size of the file plus offset bytes.
|
#define SEEK_END 2 ///< The file offset is set to the size of the file plus offset bytes.
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
/// @brief Writes the given character to the standard output (stdout).
|
/// @brief Writes the given character to the standard output (stdout).
|
||||||
/// @param character The character to send to stdout.
|
/// @param character The character to send to stdout.
|
||||||
void putchar(int character);
|
void putchar(int character);
|
||||||
@@ -41,7 +41,6 @@ int getchar();
|
|||||||
/// @return The string received from standard input.
|
/// @return The string received from standard input.
|
||||||
char *gets(char *str);
|
char *gets(char *str);
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
/// @brief Same as getchar but reads from the given file descriptor.
|
/// @brief Same as getchar but reads from the given file descriptor.
|
||||||
/// @param fd The file descriptor from which it reads.
|
/// @param fd The file descriptor from which it reads.
|
||||||
/// @return The read character.
|
/// @return The read character.
|
||||||
@@ -108,7 +107,6 @@ int vsprintf(char *str, const char *fmt, va_list args);
|
|||||||
/// @return On success, the function returns the number of items of the
|
/// @return On success, the function returns the number of items of the
|
||||||
/// argument list successfully filled. EOF otherwise.
|
/// argument list successfully filled. EOF otherwise.
|
||||||
int scanf(const char *fmt, ...);
|
int scanf(const char *fmt, ...);
|
||||||
#endif
|
|
||||||
|
|
||||||
/// @brief Read formatted data from string.
|
/// @brief Read formatted data from string.
|
||||||
/// @param str String processed as source to retrieve the data.
|
/// @param str String processed as source to retrieve the data.
|
||||||
@@ -118,7 +116,6 @@ int scanf(const char *fmt, ...);
|
|||||||
/// argument list successfully filled. EOF otherwise.
|
/// argument list successfully filled. EOF otherwise.
|
||||||
int sscanf(const char *str, const char *fmt, ...);
|
int sscanf(const char *str, const char *fmt, ...);
|
||||||
|
|
||||||
#ifndef __KERNEL__
|
|
||||||
/// @brief The same as sscanf but the source is a file.
|
/// @brief The same as sscanf but the source is a file.
|
||||||
/// @param fd The file descriptor associated with the file.
|
/// @param fd The file descriptor associated with the file.
|
||||||
/// @param fmt Format string, following the same specifications as printf.
|
/// @param fmt Format string, following the same specifications as printf.
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stdlib.h
|
/// @file stdlib.h
|
||||||
/// @brief Useful generic functions and macros.
|
/// @brief Useful generic functions and macros.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file strerror.h
|
/// @file strerror.h
|
||||||
/// @brief Contains the function that transfornms an errno into a string.
|
/// @brief Contains the function that transfornms an errno into a string.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file string.h
|
/// @file string.h
|
||||||
/// @brief String routines.
|
/// @brief String routines.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file bitops.h
|
/// @file bitops.h
|
||||||
/// @brief Bitmasks functions.
|
/// @brief Bitmasks functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file dirent.h
|
/// @file dirent.h
|
||||||
/// @brief Functions used to manage directories.
|
/// @brief Functions used to manage directories.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file errno.h
|
/// @file errno.h
|
||||||
/// @brief System call errors definition.
|
/// @brief System call errors definition.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file ioctl.h
|
/// @file ioctl.h
|
||||||
/// @brief Input/Output ConTroL (IOCTL) functions.
|
/// @brief Input/Output ConTroL (IOCTL) functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file reboot.h
|
/// @file reboot.h
|
||||||
/// @brief Defines the values required to issue a reboot.
|
/// @brief Defines the values required to issue a reboot.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+10
-3
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stat.h
|
/// @file stat.h
|
||||||
/// @brief Stat functions.
|
/// @brief Stat functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -32,4 +31,12 @@ int mkdir(const char *path, mode_t mode);
|
|||||||
/// @brief Removes the given directory.
|
/// @brief Removes the given directory.
|
||||||
/// @param path The path to the directory to remove.
|
/// @param path The path to the directory to remove.
|
||||||
/// @return Returns a negative value on failure.
|
/// @return Returns a negative value on failure.
|
||||||
int rmdir(const char *path);
|
int rmdir(const char *path);
|
||||||
|
|
||||||
|
/// @brief Creates a new file or rewrite an existing one.
|
||||||
|
/// @param path path to the file.
|
||||||
|
/// @param mode mode for file creation.
|
||||||
|
/// @return file descriptor number, -1 otherwise and errno is set to indicate the error.
|
||||||
|
/// @details
|
||||||
|
/// It is equivalent to: open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
|
||||||
|
int creat(const char *path, mode_t mode);
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file types.h
|
/// @file types.h
|
||||||
/// @brief Collection of Kernel datatype
|
/// @brief Collection of Kernel datatype
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+35
-9
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file unistd.h
|
/// @file unistd.h
|
||||||
/// @brief Functions used to manage files.
|
/// @brief Functions used to manage files.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -28,14 +27,11 @@ ssize_t read(int fd, void *buf, size_t nbytes);
|
|||||||
/// @return The number of written bytes.
|
/// @return The number of written bytes.
|
||||||
ssize_t write(int fd, void *buf, size_t nbytes);
|
ssize_t write(int fd, void *buf, size_t nbytes);
|
||||||
|
|
||||||
/// @brief Opens the file specified by pathname.
|
/// @brief Opens the file specified by pathname.
|
||||||
/// @param pathname A pathname for a file.
|
/// @param pathname A pathname for a file.
|
||||||
/// @param flags Used to set the file status flags and file access modes
|
/// @param flags file status flags and file access modes of the open file description.
|
||||||
/// of the open file description.
|
/// @param mode the file mode bits be applied when a new file is created.
|
||||||
/// @param mode Specifies the file mode bits be applied when a new file
|
/// @return file descriptor number, -1 otherwise and errno is set to indicate the error.
|
||||||
/// is created.
|
|
||||||
/// @return Returns a file descriptor, a small, nonnegative integer for
|
|
||||||
/// use in subsequent system calls.
|
|
||||||
int open(const char *pathname, int flags, mode_t mode);
|
int open(const char *pathname, int flags, mode_t mode);
|
||||||
|
|
||||||
/// @brief Close a file descriptor.
|
/// @brief Close a file descriptor.
|
||||||
@@ -84,6 +80,19 @@ extern pid_t getsid(pid_t pid);
|
|||||||
/// Otherwise return -1 with errno : EPERM
|
/// Otherwise return -1 with errno : EPERM
|
||||||
extern pid_t setsid();
|
extern pid_t setsid();
|
||||||
|
|
||||||
|
///@brief returns the Process Group ID (PGID) of the process specified by pid.
|
||||||
|
/// If pid is zero, the process ID of the calling process is used.
|
||||||
|
/// @param pid process of which we want to know the PGID.
|
||||||
|
/// @return the PGID of the specified process.
|
||||||
|
pid_t getpgid(pid_t pid);
|
||||||
|
|
||||||
|
/// @brief Sets the Process Group ID (PGID) of the process specified by pid.
|
||||||
|
/// If pid is zero, the process ID of the calling process is used.
|
||||||
|
/// @param pid process of which we want to set the PGID.
|
||||||
|
/// @param pgid the PGID we want to set.
|
||||||
|
/// @return returns zero. On error, -1 is returned, and errno is set appropriately.
|
||||||
|
int setpgid(pid_t pid, pid_t pgid);
|
||||||
|
|
||||||
///@brief returns the group ID of the calling process.
|
///@brief returns the group ID of the calling process.
|
||||||
///@return GID of the current process
|
///@return GID of the current process
|
||||||
extern pid_t getgid();
|
extern pid_t getgid();
|
||||||
@@ -94,6 +103,16 @@ extern pid_t getgid();
|
|||||||
/// Otherwise returns -1 with errno set to :EINVAL or EPERM
|
/// Otherwise returns -1 with errno set to :EINVAL or EPERM
|
||||||
extern int setgid(pid_t pid);
|
extern int setgid(pid_t pid);
|
||||||
|
|
||||||
|
///@brief Returns the User ID of the calling process.
|
||||||
|
///@return User ID of the current process.
|
||||||
|
extern uid_t getuid();
|
||||||
|
|
||||||
|
///@brief Sets the effective User ID of the calling process.
|
||||||
|
///@param uid the new User ID.
|
||||||
|
///@return On success, zero is returned.
|
||||||
|
/// Otherwise returns -1 with errno set to :EINVAL or EPERM
|
||||||
|
extern int setuid(uid_t uid);
|
||||||
|
|
||||||
/// @brief Returns the parent process ID (PPID) of the calling process.
|
/// @brief Returns the parent process ID (PPID) of the calling process.
|
||||||
/// @return pid_t parent process identifier.
|
/// @return pid_t parent process identifier.
|
||||||
extern pid_t getppid();
|
extern pid_t getppid();
|
||||||
@@ -203,11 +222,13 @@ char *getcwd(char *buf, size_t size);
|
|||||||
|
|
||||||
/// @brief Changes the current working directory to the given path.
|
/// @brief Changes the current working directory to the given path.
|
||||||
/// @param path The new current working directory.
|
/// @param path The new current working directory.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
int chdir(char const *path);
|
int chdir(char const *path);
|
||||||
|
|
||||||
/// @brief Is identical to chdir(), the only difference is that the
|
/// @brief Is identical to chdir(), the only difference is that the
|
||||||
/// directory is given as an open file descriptor.
|
/// directory is given as an open file descriptor.
|
||||||
/// @param fd The file descriptor of the open directory.
|
/// @param fd The file descriptor of the open directory.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
int fchdir(int fd);
|
int fchdir(int fd);
|
||||||
|
|
||||||
/// Provide access to the directory entries.
|
/// Provide access to the directory entries.
|
||||||
@@ -220,4 +241,9 @@ int fchdir(int fd);
|
|||||||
int getdents(int fd, dirent_t *dirp, unsigned int count);
|
int getdents(int fd, dirent_t *dirp, unsigned int count);
|
||||||
|
|
||||||
/// @brief Send signal to calling thread after desired seconds.
|
/// @brief Send signal to calling thread after desired seconds.
|
||||||
|
/// @param seconds the amount of seconds.
|
||||||
|
/// @return If there is a previous alarm() request with time remaining, alarm()
|
||||||
|
/// shall return a non-zero value that is the number of seconds until the
|
||||||
|
/// previous request would have generated a SIGALRM signal. Otherwise, alarm()
|
||||||
|
/// shall return 0.
|
||||||
int alarm(int seconds);
|
int alarm(int seconds);
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file utsname.h
|
/// @file utsname.h
|
||||||
/// @brief Functions used to provide information about the machine & OS.
|
/// @brief Functions used to provide information about the machine & OS.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file wait.h
|
/// @file wait.h
|
||||||
/// @brief Event management functions.
|
/// @brief Event management functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file syscall_types.h
|
/// @file syscall_types.h
|
||||||
/// @brief System Call numbers.
|
/// @brief System Call numbers.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
+3
-4
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file termios.h
|
/// @file termios.h
|
||||||
/// @brief Defines the termios functions.
|
/// @brief Defines the termios functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -12,11 +11,11 @@
|
|||||||
/// @param fd
|
/// @param fd
|
||||||
/// @param termios_p
|
/// @param termios_p
|
||||||
/// @return
|
/// @return
|
||||||
extern int tcgetattr(int fd, termios *termios_p);
|
extern int tcgetattr(int fd, termios_t *termios_p);
|
||||||
|
|
||||||
/// @brief Set the state of FD to *TERMIOS_P.
|
/// @brief Set the state of FD to *TERMIOS_P.
|
||||||
/// @param fd
|
/// @param fd
|
||||||
/// @param optional_actions
|
/// @param optional_actions
|
||||||
/// @param termios_p
|
/// @param termios_p
|
||||||
/// @return
|
/// @return
|
||||||
extern int tcsetattr(int fd, int optional_actions, const termios *termios_p);
|
extern int tcsetattr(int fd, int optional_actions, const termios_t *termios_p);
|
||||||
|
|||||||
+28
-14
@@ -1,17 +1,22 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file time.h
|
/// @file time.h
|
||||||
/// @brief Time-related functions.
|
/// @brief Time-related functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
|
|
||||||
/// Domains of interval timers
|
/// @brief This timer counts down in real (i.e., wall clock) time. At each
|
||||||
#define ITIMER_REAL 0
|
/// expiration, a SIGALRM signal is generated.
|
||||||
|
#define ITIMER_REAL 0
|
||||||
|
/// @brief This timer counts down against the user-mode CPU time consumed by the
|
||||||
|
/// process. At each expiration, a SIGVTALRM signal is generated.
|
||||||
#define ITIMER_VIRTUAL 1
|
#define ITIMER_VIRTUAL 1
|
||||||
#define ITIMER_PROF 2
|
/// @brief This timer counts down against the total (i.e., both user and system)
|
||||||
|
/// CPU time consumed by the process. At each expiration, a SIGPROF signal is
|
||||||
|
/// generated.
|
||||||
|
#define ITIMER_PROF 2
|
||||||
|
|
||||||
/// Used to store time values.
|
/// Used to store time values.
|
||||||
typedef unsigned int time_t;
|
typedef unsigned int time_t;
|
||||||
@@ -38,16 +43,16 @@ typedef struct tm_t {
|
|||||||
int tm_isdst;
|
int tm_isdst;
|
||||||
} tm_t;
|
} tm_t;
|
||||||
|
|
||||||
/// Rappresents time
|
/// Rappresents time.
|
||||||
typedef struct _timeval {
|
typedef struct _timeval {
|
||||||
time_t tv_sec; /* seconds */
|
time_t tv_sec; ///< Seconds.
|
||||||
time_t tv_usec; /* microseconds */
|
time_t tv_usec; ///< Microseconds.
|
||||||
} timeval;
|
} timeval;
|
||||||
|
|
||||||
/// Rappresents a time interval
|
/// Rappresents a time interval.
|
||||||
typedef struct _itimerval {
|
typedef struct _itimerval {
|
||||||
timeval it_interval; /* next value */
|
timeval it_interval; ///< Next value.
|
||||||
timeval it_value; /* current value */
|
timeval it_value; ///< Current value.
|
||||||
} itimerval;
|
} itimerval;
|
||||||
|
|
||||||
/// @brief Specify intervals of time with nanosecond precision.
|
/// @brief Specify intervals of time with nanosecond precision.
|
||||||
@@ -102,9 +107,18 @@ int nanosleep(const timespec *req, timespec *rem);
|
|||||||
/// left to sleep, if the call was interrupted by a signal handler.
|
/// left to sleep, if the call was interrupted by a signal handler.
|
||||||
unsigned int sleep(unsigned int seconds);
|
unsigned int sleep(unsigned int seconds);
|
||||||
|
|
||||||
/// @brief Fills the structure pointed to by curr_value with the current setting for the timer specified by which.
|
/// @brief Fills the structure pointed to by curr_value with the current setting
|
||||||
|
/// for the timer specified by which.
|
||||||
|
/// @param which which timer.
|
||||||
|
/// @param curr_value where we place the timer value.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
int getitimer(int which, itimerval *curr_value);
|
int getitimer(int which, itimerval *curr_value);
|
||||||
|
|
||||||
/// @brief The system provides each process with three interval timers, each decrementing in a distinct time domain.
|
/// @brief The system provides each process with three interval timers, each
|
||||||
/// When any timer expires, a signal is sent to the process, and the timer (potentially) restarts.
|
/// decrementing in a distinct time domain. When any timer expires, a signal is
|
||||||
|
/// sent to the process, and the timer (potentially) restarts.
|
||||||
|
/// @param which which timer.
|
||||||
|
/// @param new_value the new value for the timer.
|
||||||
|
/// @param old_value output variable where the function places the previous value.
|
||||||
|
/// @return 0 on success, -1 on failure and errno is set to indicate the error.
|
||||||
int setitimer(int which, const itimerval *new_value, itimerval *old_value);
|
int setitimer(int which, const itimerval *new_value, itimerval *old_value);
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file abort.c
|
/// @file abort.c
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "sys/unistd.h"
|
#include "sys/unistd.h"
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file assert.c
|
/// @file assert.c
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
|||||||
+6
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file ctype.c
|
/// @file ctype.c
|
||||||
/// @brief Functions related to character handling.
|
/// @brief Functions related to character handling.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "ctype.h"
|
#include "ctype.h"
|
||||||
@@ -19,6 +18,11 @@ int isalpha(int c)
|
|||||||
return ((c >= 65 && c <= 90) || (c >= 97 && c <= 122));
|
return ((c >= 65 && c <= 90) || (c >= 97 && c <= 122));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int iscntrl(int c)
|
||||||
|
{
|
||||||
|
return ((c >= 0x00 && c <= 0x1F) || (c == 0x7F));
|
||||||
|
}
|
||||||
|
|
||||||
int isalnum(int c)
|
int isalnum(int c)
|
||||||
{
|
{
|
||||||
return (isalpha(c) || isdigit(c));
|
return (isalpha(c) || isdigit(c));
|
||||||
|
|||||||
+13
-10
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file debug.c
|
/// @file debug.c
|
||||||
/// @brief Debugging primitives.
|
/// @brief Debugging primitives.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
@@ -11,35 +10,39 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/bitops.h>
|
#include <sys/bitops.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
/// Serial port for QEMU.
|
/// Serial port for QEMU.
|
||||||
#define SERIAL_COM1 (0x03F8)
|
#define SERIAL_COM1 (0x03F8)
|
||||||
|
|
||||||
|
#define FG_RESET "\033[0m" ///< ANSI code for resetting.
|
||||||
|
|
||||||
void dbg_putchar(char c)
|
void dbg_putchar(char c)
|
||||||
{
|
{
|
||||||
#if (defined(DEBUG_STDIO) || defined(DEBUG_LOG))
|
|
||||||
outportb(SERIAL_COM1, (uint8_t)c);
|
outportb(SERIAL_COM1, (uint8_t)c);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg_puts(const char *s)
|
void dbg_puts(const char *s)
|
||||||
{
|
{
|
||||||
#if (defined(DEBUG_STDIO) || defined(DEBUG_LOG))
|
|
||||||
while ((*s) != 0)
|
while ((*s) != 0)
|
||||||
dbg_putchar(*s++);
|
dbg_putchar(*s++);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void __debug_print_header(const char *file, const char *fun, int line)
|
static inline void __debug_print_header(const char *file, const char *fun, int line)
|
||||||
{
|
{
|
||||||
static char tmp_prefix[BUFSIZ], final_prefix[BUFSIZ];
|
static char tmp_prefix[BUFSIZ], final_prefix[BUFSIZ];
|
||||||
|
dbg_puts(FG_RESET);
|
||||||
dbg_puts("[ LB |");
|
dbg_puts("[ LB |");
|
||||||
sprintf(tmp_prefix, "%s:%d", file, line);
|
sprintf(tmp_prefix, "%s:%d", file, line);
|
||||||
sprintf(final_prefix, " %-20s ", tmp_prefix);
|
sprintf(final_prefix, " %-20s ", tmp_prefix);
|
||||||
dbg_puts(final_prefix);
|
dbg_puts(final_prefix);
|
||||||
|
#if 0
|
||||||
dbg_putchar('|');
|
dbg_putchar('|');
|
||||||
sprintf(final_prefix, " %-25s ] ", fun);
|
sprintf(final_prefix, " %-25s ]", fun);
|
||||||
dbg_puts(final_prefix);
|
dbg_puts(final_prefix);
|
||||||
|
#else
|
||||||
|
dbg_putchar(']');
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg_printf(const char *file, const char *fun, int line, const char *format, ...)
|
void dbg_printf(const char *file, const char *fun, int line, const char *format, ...)
|
||||||
@@ -96,10 +99,10 @@ const char *to_human_size(unsigned long bytes)
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *dec_to_binary(unsigned long value)
|
const char *dec_to_binary(unsigned long value, unsigned length)
|
||||||
{
|
{
|
||||||
static char buffer[33];
|
static char buffer[33];
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0, j = 32 - min(max(0, length), 32); j < 32; ++i, ++j)
|
||||||
buffer[i] = bit_check(value, 31 - i) ? '1' : '0';
|
buffer[i] = bit_check(value, 31 - j) ? '1' : '0';
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file fcvt.c
|
/// @file fcvt.c
|
||||||
/// @brief Define the functions required to turn double values into a string.
|
/// @brief Define the functions required to turn double values into a string.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "fcvt.h"
|
#include "fcvt.h"
|
||||||
|
|||||||
+33
-37
@@ -1,10 +1,9 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file grp.c
|
/// @file grp.c
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "grp.h"
|
#include "grp.h"
|
||||||
#include "sys/unistd.h"
|
#include "sys/unistd.h"
|
||||||
#include "sys/errno.h"
|
#include "sys/errno.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
@@ -13,8 +12,9 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "fcntl.h"
|
#include "fcntl.h"
|
||||||
|
|
||||||
|
static int __fd = -1;
|
||||||
|
|
||||||
static inline void __parse_line(struct group* grp, char *buf)
|
static inline void __parse_line(group_t *grp, char *buf)
|
||||||
{
|
{
|
||||||
assert(grp && "Received null grp!");
|
assert(grp && "Received null grp!");
|
||||||
char *token;
|
char *token;
|
||||||
@@ -29,7 +29,7 @@ static inline void __parse_line(struct group* grp, char *buf)
|
|||||||
grp->gr_gid = atoi(token);
|
grp->gr_gid = atoi(token);
|
||||||
|
|
||||||
size_t found_users = 0;
|
size_t found_users = 0;
|
||||||
while((token = strtok(NULL, ",\n\0")) != NULL && found_users < MAX_MEMBERS_PER_GROUP) {
|
while ((token = strtok(NULL, ",\n\0")) != NULL && found_users < MAX_MEMBERS_PER_GROUP) {
|
||||||
grp->gr_mem[found_users] = token;
|
grp->gr_mem[found_users] = token;
|
||||||
found_users += 1;
|
found_users += 1;
|
||||||
}
|
}
|
||||||
@@ -90,45 +90,44 @@ static inline char *__search_entry(int fd, char *buf, int buflen, const char *na
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct group* getgrgid(gid_t gid) {
|
group_t *getgrgid(gid_t gid)
|
||||||
|
{
|
||||||
static group grp;
|
static group_t grp;
|
||||||
static char buffer[BUFSIZ];
|
static char buffer[BUFSIZ];
|
||||||
|
|
||||||
group *result;
|
group_t *result;
|
||||||
if (!getgrgid_r(gid, &grp, buffer, BUFSIZ, &result))
|
if (!getgrgid_r(gid, &grp, buffer, BUFSIZ, &result))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return &grp;
|
return &grp;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct group *getgrnam(const char* name) {
|
group_t *getgrnam(const char *name)
|
||||||
|
{
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
static group grp;
|
static group_t grp;
|
||||||
static char buffer[BUFSIZ];
|
static char buffer[BUFSIZ];
|
||||||
|
|
||||||
group *result;
|
group_t *result;
|
||||||
if (!getgrnam_r(name, &grp, buffer, BUFSIZ, &result))
|
if (!getgrnam_r(name, &grp, buffer, BUFSIZ, &result))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return &grp;
|
return &grp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getgrgid_r(gid_t gid, struct group* group, char* buf, size_t buflen, struct group ** result) {
|
int getgrgid_r(gid_t gid, group_t *group, char *buf, size_t buflen, group_t **result)
|
||||||
|
{
|
||||||
int fd = open("/etc/group", O_RDONLY, 0);
|
int fd = open("/etc/group", O_RDONLY, 0);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *entry = __search_entry(fd, buf, buflen, NULL, gid);
|
char *entry = __search_entry(fd, buf, buflen, NULL, gid);
|
||||||
if (entry != NULL) {
|
if (entry != NULL) {
|
||||||
|
|
||||||
// Close the file.
|
// Close the file.
|
||||||
close(fd);
|
close(fd);
|
||||||
// Parse the line.
|
// Parse the line.
|
||||||
@@ -143,18 +142,17 @@ int getgrgid_r(gid_t gid, struct group* group, char* buf, size_t buflen, struct
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getgrnam_r(const char* name, struct group* group, char* buf, size_t buflen, struct group** result) {
|
int getgrnam_r(const char *name, group_t *group, char *buf, size_t buflen, group_t **result)
|
||||||
|
{
|
||||||
int fd = open("/etc/group", O_RDONLY, 0);
|
int fd = open("/etc/group", O_RDONLY, 0);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *entry = __search_entry(fd, buf, buflen, name, 0);
|
char *entry = __search_entry(fd, buf, buflen, name, 0);
|
||||||
if (entry != NULL) {
|
if (entry != NULL) {
|
||||||
|
|
||||||
// Close the file.
|
// Close the file.
|
||||||
close(fd);
|
close(fd);
|
||||||
// Parse the line.
|
// Parse the line.
|
||||||
@@ -169,15 +167,14 @@ int getgrnam_r(const char* name, struct group* group, char* buf, size_t buflen,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd = -1;
|
group_t *getgrent(void)
|
||||||
struct group* getgrent(void) {
|
{
|
||||||
|
static group_t result;
|
||||||
|
|
||||||
static group result;
|
if (__fd == -1) {
|
||||||
|
|
||||||
if (fd == -1) {
|
|
||||||
//pr_debug("Opening group file\n");
|
//pr_debug("Opening group file\n");
|
||||||
fd = open("/etc/group", O_RDONLY, 0);
|
__fd = open("/etc/group", O_RDONLY, 0);
|
||||||
if (fd == -1) {
|
if (__fd == -1) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -188,8 +185,7 @@ struct group* getgrent(void) {
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
static char buffer[BUFSIZ];
|
static char buffer[BUFSIZ];
|
||||||
while ((ret = read(fd, &c, 1U))) {
|
while ((ret = read(__fd, &c, 1U))) {
|
||||||
|
|
||||||
// Skip carriage return.
|
// Skip carriage return.
|
||||||
if (c == '\r')
|
if (c == '\r')
|
||||||
continue;
|
continue;
|
||||||
@@ -224,15 +220,15 @@ struct group* getgrent(void) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void endgrent(void) {
|
void endgrent(void)
|
||||||
|
{
|
||||||
//pr_debug("Closing group file\n");
|
//pr_debug("Closing group file\n");
|
||||||
close(fd);
|
close(__fd);
|
||||||
fd = -1;
|
__fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setgrent(void) {
|
void setgrent(void)
|
||||||
|
{
|
||||||
//pr_debug("Resetting pointer to beginning of group file\n");
|
//pr_debug("Resetting pointer to beginning of group file\n");
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(__fd, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file mm_io.c
|
/// @file mm_io.c
|
||||||
/// @brief Memory Mapped IO functions implementation.
|
/// @brief Memory Mapped IO functions implementation.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "io/mm_io.h"
|
#include "io/mm_io.h"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file port_io.c
|
/// @file port_io.c
|
||||||
/// @brief Byte I/O on ports prototypes.
|
/// @brief Byte I/O on ports prototypes.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "io/port_io.h"
|
#include "io/port_io.h"
|
||||||
|
|||||||
+3
-4
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file ipc.c
|
/// @file ipc.c
|
||||||
/// @brief Inter-Process Communication (IPC) system call implementation.
|
/// @brief Inter-Process Communication (IPC) system call implementation.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "sys/unistd.h"
|
#include "sys/unistd.h"
|
||||||
@@ -12,11 +11,11 @@
|
|||||||
#include "ipc/shm.h"
|
#include "ipc/shm.h"
|
||||||
#include "ipc/msg.h"
|
#include "ipc/msg.h"
|
||||||
|
|
||||||
_syscall3(long, shmat, int, shmid, char *, shmaddr, int, shmflg)
|
_syscall3(void *, shmat, int, shmid, const void *, shmaddr, int, shmflg)
|
||||||
|
|
||||||
_syscall3(long, shmget, key_t, key, size_t, size, int, flag)
|
_syscall3(long, shmget, key_t, key, size_t, size, int, flag)
|
||||||
|
|
||||||
_syscall1(long, shmdt, char *, shmaddr)
|
_syscall1(long, shmdt, const void *, shmaddr)
|
||||||
|
|
||||||
_syscall3(long, shmctl, int, shmid, int, cmd, struct shmid_ds *, buf)
|
_syscall3(long, shmctl, int, shmid, int, cmd, struct shmid_ds *, buf)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/// @file libc_start.c
|
/// @file libc_start.c
|
||||||
/// @brief Contains the programs initialization procedure.
|
/// @brief Contains the programs initialization procedure.
|
||||||
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "sys/unistd.h"
|
#include "sys/unistd.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
@@ -33,8 +35,3 @@ int __libc_start_main(int (*main)(int, char **, char **), int argc, char *argv[]
|
|||||||
//dbg_print("== END %-30s =======================================\n", argv[0]);
|
//dbg_print("== END %-30s =======================================\n", argv[0]);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WARNING: This declaration must be here, because libc_start is compiled
|
|
||||||
// with all the programs, and all the programs NEED to have the `sigreturn`
|
|
||||||
// symbol. It must be this way, period.
|
|
||||||
_syscall0(int, sigreturn)
|
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file libgen.c
|
/// @file libgen.c
|
||||||
/// @brief String routines.
|
/// @brief String routines.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file math.c
|
/// @file math.c
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|||||||
+81
-49
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file pwd.c
|
/// @file pwd.c
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "pwd.h"
|
#include "pwd.h"
|
||||||
@@ -11,11 +10,12 @@
|
|||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
#include "fcntl.h"
|
#include "fcntl.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
static inline void __parse_line(passwd_t *pwd, char *buf)
|
static inline void __parse_line(passwd_t *pwd, char *buf)
|
||||||
{
|
{
|
||||||
assert(pwd && "Received null pwd!");
|
assert(pwd && "Received null pwd!");
|
||||||
char *token;
|
char *token, *ch;
|
||||||
// Parse the username.
|
// Parse the username.
|
||||||
if ((token = strtok(buf, ":")) != NULL)
|
if ((token = strtok(buf, ":")) != NULL)
|
||||||
pwd->pw_name = token;
|
pwd->pw_name = token;
|
||||||
@@ -35,59 +35,88 @@ static inline void __parse_line(passwd_t *pwd, char *buf)
|
|||||||
if ((token = strtok(NULL, ":")) != NULL)
|
if ((token = strtok(NULL, ":")) != NULL)
|
||||||
pwd->pw_dir = token;
|
pwd->pw_dir = token;
|
||||||
// Parse the shell.
|
// Parse the shell.
|
||||||
if ((token = strtok(NULL, ":")) != NULL)
|
if ((token = strtok(NULL, ":")) != NULL) {
|
||||||
pwd->pw_shell = token;
|
pwd->pw_shell = token;
|
||||||
|
// Find carriege return.
|
||||||
|
if ((ch = strchr(pwd->pw_shell, '\r')))
|
||||||
|
*ch = 0;
|
||||||
|
// Find newline.
|
||||||
|
if ((ch = strchr(pwd->pw_shell, '\n')))
|
||||||
|
*ch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char *__search_entry(int fd, char *buf, int buflen, const char *name, uid_t uid)
|
/// @brief Reads a line from the file.
|
||||||
|
/// @param fd the file descriptor.
|
||||||
|
/// @param buffer the buffer where we place the line.
|
||||||
|
/// @param buflen the length of the buffer.
|
||||||
|
/// @return the amount we read.
|
||||||
|
ssize_t __readline(int fd, char *buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
int ret;
|
memset(buffer, 0, buflen);
|
||||||
char c;
|
long num_read = read(fd, buffer, buflen);
|
||||||
int pos = 0;
|
if (num_read == 0) {
|
||||||
while ((ret = read(fd, &c, 1U))) {
|
return 0;
|
||||||
// Skip carriage return.
|
}
|
||||||
if (c == '\r')
|
char *newline = strchr(buffer, '\n');
|
||||||
continue;
|
if (newline == NULL) {
|
||||||
if (pos >= buflen) {
|
newline = strchr(buffer, EOF);
|
||||||
errno = ERANGE;
|
if (newline == NULL) {
|
||||||
return NULL;
|
newline = strchr(buffer, 0);
|
||||||
}
|
if (newline == NULL) {
|
||||||
// If we have found a newline or the EOF, parse the entry.
|
return 0;
|
||||||
if ((c == '\n') || (ret == EOF)) {
|
}
|
||||||
// Close the buffer.
|
}
|
||||||
buf[pos] = 0;
|
}
|
||||||
// Check the entry.
|
long newline_len = (int)(newline - buffer);
|
||||||
if (name) {
|
if (newline_len <= 0) {
|
||||||
if (strncmp(buf, name, strlen(name)) == 0)
|
return 0;
|
||||||
return buf;
|
}
|
||||||
} else {
|
buffer[newline_len] = 0;
|
||||||
int uid_start = -1, col_count = 0;
|
long rollback = newline_len - num_read + 1;
|
||||||
for (int i = 0; i < pos; ++i) {
|
if (rollback > 1) {
|
||||||
if (buf[i] == ':') {
|
return 0;
|
||||||
if (++col_count == 2) {
|
}
|
||||||
uid_start = i + 1;
|
lseek(fd, rollback, SEEK_CUR);
|
||||||
break;
|
return newline_len;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
static inline char *__search_entry(int fd, char *buffer, int buflen, const char *name, uid_t uid)
|
||||||
if ((uid_start != -1) && (uid_start < pos)) {
|
{
|
||||||
// Parse the uid.
|
while (__readline(fd, buffer, buflen)) {
|
||||||
int found_uid = atoi(&buf[uid_start]);
|
if (name != NULL) {
|
||||||
// Check the uid.
|
char *name_end = strchr(buffer, ':');
|
||||||
if (found_uid == uid)
|
if (name_end) {
|
||||||
return buf;
|
*name_end = '\0';
|
||||||
}
|
if (strncmp(buffer, name, strlen(name)) == 0) {
|
||||||
|
*name_end = ':';
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Name
|
||||||
|
char *ptr = strchr(buffer, ':');
|
||||||
|
if (ptr == NULL)
|
||||||
|
continue;
|
||||||
|
// Password
|
||||||
|
++ptr;
|
||||||
|
char *uid_start = strchr(ptr, ':');
|
||||||
|
if (uid_start == NULL)
|
||||||
|
continue;
|
||||||
|
++uid_start;
|
||||||
|
ptr = strchr(uid_start, ':');
|
||||||
|
if (ptr == NULL)
|
||||||
|
continue;
|
||||||
|
*ptr = '\0';
|
||||||
|
// Parse the uid.
|
||||||
|
int found_uid = atoi(uid_start);
|
||||||
|
// Check the uid.
|
||||||
|
if (found_uid == uid) {
|
||||||
|
*ptr = ':';
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
// Reset the index.
|
|
||||||
pos = 0;
|
|
||||||
// If we have reached the EOF stop.
|
|
||||||
if (ret == EOF)
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
buf[pos++] = c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errno = ENOENT;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +148,7 @@ int getpwnam_r(const char *name, passwd_t *pwd, char *buf, size_t buflen, passwd
|
|||||||
return 0;
|
return 0;
|
||||||
int fd = open("/etc/passwd", O_RDONLY, 0);
|
int fd = open("/etc/passwd", O_RDONLY, 0);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
pr_debug("Cannot open `/etc/passwd`\n");
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -132,6 +162,7 @@ int getpwnam_r(const char *name, passwd_t *pwd, char *buf, size_t buflen, passwd
|
|||||||
// Return success.
|
// Return success.
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
errno = ENOENT;
|
||||||
// Close the file.
|
// Close the file.
|
||||||
close(fd);
|
close(fd);
|
||||||
// Return fail.
|
// Return fail.
|
||||||
@@ -142,6 +173,7 @@ int getpwuid_r(uid_t uid, passwd_t *pwd, char *buf, size_t buflen, passwd_t **re
|
|||||||
{
|
{
|
||||||
int fd = open("/etc/passwd", O_RDONLY, 0);
|
int fd = open("/etc/passwd", O_RDONLY, 0);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
pr_debug("Cannot open `/etc/passwd`\n");
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+4
-3
@@ -1,6 +1,7 @@
|
|||||||
//
|
/// @file sched.c
|
||||||
// Created by enryf on 24/09/2020.
|
/// @brief Function for managing scheduler.
|
||||||
//
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "system/syscall_types.h"
|
#include "system/syscall_types.h"
|
||||||
#include "sys/errno.h"
|
#include "sys/errno.h"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/// @file setenv.c
|
/// @file setenv.c
|
||||||
/// @brief Defines the functions used to manipulate the environmental variables.
|
/// @brief Defines the functions used to manipulate the environmental variables.
|
||||||
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "sys/errno.h"
|
#include "sys/errno.h"
|
||||||
|
|||||||
+4
-3
@@ -1,6 +1,7 @@
|
|||||||
/// @file stdio.c
|
/// @file stdio.c
|
||||||
/// @brief Standard I/0 functions.
|
/// @brief Standard I/0 functions.
|
||||||
/// @date Apr 2019
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file stdlib.c
|
/// @file stdlib.c
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "system/syscall_types.h"
|
#include "system/syscall_types.h"
|
||||||
|
|||||||
+6
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file strerror.c
|
/// @file strerror.c
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "strerror.h"
|
#include "strerror.h"
|
||||||
@@ -15,6 +14,11 @@ char *strerror(int errnum)
|
|||||||
case 0:
|
case 0:
|
||||||
strcpy(error, "Success");
|
strcpy(error, "Success");
|
||||||
break;
|
break;
|
||||||
|
#ifdef EPERM
|
||||||
|
case EPERM:
|
||||||
|
strcpy(error, "Operation not permitted");
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#ifdef ENOENT
|
#ifdef ENOENT
|
||||||
case ENOENT:
|
case ENOENT:
|
||||||
strcpy(error, "No such file or directory");
|
strcpy(error, "No such file or directory");
|
||||||
|
|||||||
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file string.c
|
/// @file string.c
|
||||||
/// @brief String routines.
|
/// @brief String routines.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file errno.c
|
/// @file errno.c
|
||||||
/// @brief Stores the error number.
|
/// @brief Stores the error number.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "sys/errno.h"
|
#include "sys/errno.h"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file ioctl.c
|
/// @file ioctl.c
|
||||||
/// @brief Input/Output ConTroL (IOCTL) functions implementation.
|
/// @brief Input/Output ConTroL (IOCTL) functions implementation.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "sys/ioctl.h"
|
#include "sys/ioctl.h"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file unistd.c
|
/// @file unistd.c
|
||||||
/// @brief Functions used to manage files.
|
/// @brief Functions used to manage files.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "sys/unistd.h"
|
#include "sys/unistd.h"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file utsname.c
|
/// @file utsname.c
|
||||||
/// @brief Functions used to provide information about the machine & OS.
|
/// @brief Functions used to provide information about the machine & OS.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "sys/utsname.h"
|
#include "sys/utsname.h"
|
||||||
|
|||||||
+3
-4
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file termios.c
|
/// @file termios.c
|
||||||
/// @brief
|
/// @brief
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "termios.h"
|
#include "termios.h"
|
||||||
@@ -9,7 +8,7 @@
|
|||||||
#include "sys/errno.h"
|
#include "sys/errno.h"
|
||||||
#include "bits/ioctls.h"
|
#include "bits/ioctls.h"
|
||||||
|
|
||||||
int tcgetattr(int fd, termios *termios_p)
|
int tcgetattr(int fd, termios_t *termios_p)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
__asm__ volatile("int $0x80"
|
__asm__ volatile("int $0x80"
|
||||||
@@ -23,7 +22,7 @@ int tcgetattr(int fd, termios *termios_p)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tcsetattr(int fd, int optional_actions, const termios *termios_p)
|
int tcsetattr(int fd, int optional_actions, const termios_t *termios_p)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
__asm__ volatile("int $0x80"
|
__asm__ volatile("int $0x80"
|
||||||
|
|||||||
+3
-2
@@ -1,7 +1,6 @@
|
|||||||
/// MentOS, The Mentoring Operating system project
|
|
||||||
/// @file time.c
|
/// @file time.c
|
||||||
/// @brief Clock functions.
|
/// @brief Clock functions.
|
||||||
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
|
/// @copyright (c) 2014-2022 This file is distributed under the MIT License.
|
||||||
/// See LICENSE.md for details.
|
/// See LICENSE.md for details.
|
||||||
|
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
@@ -19,6 +18,7 @@ static const char *months[] = {
|
|||||||
"July", "August", "September", "October", "November", "December"
|
"July", "August", "September", "October", "November", "December"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief Time function.
|
||||||
_syscall1(time_t, time, time_t *, t)
|
_syscall1(time_t, time, time_t *, t)
|
||||||
|
|
||||||
time_t difftime(time_t time1, time_t time2)
|
time_t difftime(time_t time1, time_t time2)
|
||||||
@@ -378,6 +378,7 @@ size_t strftime(char *str, size_t maxsize, const char *format, const tm_t *timep
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief nanosleep function.
|
||||||
_syscall2(int, nanosleep, const timespec *, req, timespec *, rem)
|
_syscall2(int, nanosleep, const timespec *, req, timespec *, rem)
|
||||||
|
|
||||||
unsigned int sleep(unsigned int seconds)
|
unsigned int sleep(unsigned int seconds)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user