Compare commits
No commits in common. "1e2c2fb973f59633cec6c9bb9920582895254bf1" and "00ee86920a73ca91333f84e58a74b30529eb9905" have entirely different histories.
1e2c2fb973
...
00ee86920a
|
@ -2,4 +2,8 @@
|
||||||
.idea/
|
.idea/
|
||||||
build/
|
build/
|
||||||
base/
|
base/
|
||||||
|
*.tar.*
|
||||||
|
toolchain/*/
|
||||||
|
|
||||||
|
!toolchain/local/
|
||||||
|
!base-sysroot.tar.gz
|
||||||
|
|
|
@ -127,8 +127,8 @@ namespace BAN
|
||||||
ASSERT(start <= m_size);
|
ASSERT(start <= m_size);
|
||||||
if (length == ~size_type(0))
|
if (length == ~size_type(0))
|
||||||
length = m_size - start;
|
length = m_size - start;
|
||||||
ASSERT(m_size - start >= length);
|
ASSERT(start + length <= m_size);
|
||||||
return Span(m_data + start, length);
|
return Span(m_data + start, m_size - start - length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
BOCHS_CONFIG_FILE=bochsrc
|
BOCHS_CONFIG_FILE=bochsrc
|
||||||
COM1_TERMINAL=kitty
|
COM1_TERMINAL=kitty
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
if [[ -z $BANAN_ARCH ]]; then
|
||||||
|
export BANAN_ARCH=x86_64
|
||||||
|
fi
|
||||||
|
|
||||||
export BANAN_SCRIPT_DIR=$(dirname $(realpath $0))
|
export BANAN_SCRIPT_DIR=$(dirname $(realpath $0))
|
||||||
source $BANAN_SCRIPT_DIR/config.sh
|
source $BANAN_SCRIPT_DIR/config.sh
|
||||||
|
|
||||||
make_build_dir () {
|
make_build_dir () {
|
||||||
|
if ! [[ -d $BANAN_BUILD_DIR ]]; then
|
||||||
mkdir -p $BANAN_BUILD_DIR
|
mkdir -p $BANAN_BUILD_DIR
|
||||||
cd $BANAN_BUILD_DIR
|
cd $BANAN_BUILD_DIR
|
||||||
if ! [[ -f "build.ninja" ]]; then
|
cmake --toolchain=$BANAN_TOOLCHAIN_DIR/Toolchain.txt -G Ninja $BANAN_ROOT_DIR $BANAN_CMAKE_ARGS
|
||||||
cmake --toolchain=$BANAN_TOOLCHAIN_DIR/Toolchain.txt -G Ninja $BANAN_ROOT_DIR
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
build_target () {
|
build_target () {
|
||||||
make_build_dir
|
make_build_dir
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ -z $1 ]]; then
|
||||||
echo "No target provided"
|
echo "No target provided"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -23,15 +27,6 @@ build_target () {
|
||||||
}
|
}
|
||||||
|
|
||||||
build_toolchain () {
|
build_toolchain () {
|
||||||
if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/$BANAN_TOOLCHAIN_TRIPLE_PREFIX-gcc ]]; then
|
|
||||||
echo "You already seem to have a toolchain."
|
|
||||||
read -e -p "Do you want to rebuild it [y/N]? " choice
|
|
||||||
if ! [[ "$choice" == [Yy]* ]]; then
|
|
||||||
echo "Aborting toolchain rebuild"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
$BANAN_TOOLCHAIN_DIR/build.sh
|
$BANAN_TOOLCHAIN_DIR/build.sh
|
||||||
build_target libc-install
|
build_target libc-install
|
||||||
$BANAN_TOOLCHAIN_DIR/build.sh libstdc++
|
$BANAN_TOOLCHAIN_DIR/build.sh libstdc++
|
||||||
|
@ -56,42 +51,57 @@ run_bochs () {
|
||||||
$BANAN_SCRIPT_DIR/bochs.sh $@
|
$BANAN_SCRIPT_DIR/bochs.sh $@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ "$1" == "toolchain" ]]; then
|
||||||
|
if [[ -f $BANAN_TOOLCHAIN_PREFIX/bin/$BANAN_TOOLCHAIN_TRIPLE_PREFIX-gcc ]]; then
|
||||||
|
echo "You already seem to have build toolchain."
|
||||||
|
read -e -p "Do you want to rebuild it [y/N]? " choice
|
||||||
|
if ! [[ "$choice" == [Yy]* ]]; then
|
||||||
|
echo "Aborting toolchain rebuild"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_toolchain
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "image" ]]; then
|
||||||
|
create_image
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "image-full" ]]; then
|
||||||
|
create_image full
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$(uname)" == "Linux" ]]; then
|
if [[ "$(uname)" == "Linux" ]]; then
|
||||||
QEMU_ACCEL="-accel kvm"
|
QEMU_ACCEL="-accel kvm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ "$1" == "qemu" ]]; then
|
||||||
echo "No argument given"
|
run_qemu -serial stdio $QEMU_ACCEL
|
||||||
exit 1
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $1 in
|
if [[ "$1" == "qemu-nographic" ]]; then
|
||||||
toolchain)
|
|
||||||
build_toolchain
|
|
||||||
;;
|
|
||||||
image)
|
|
||||||
create_image
|
|
||||||
;;
|
|
||||||
image-full)
|
|
||||||
create_image full
|
|
||||||
;;
|
|
||||||
qemu)
|
|
||||||
run_qemu -serial stdio $QEMU_ACCEL
|
|
||||||
;;
|
|
||||||
qemu-nographic)
|
|
||||||
run_qemu -nographic $QEMU_ACCEL
|
run_qemu -nographic $QEMU_ACCEL
|
||||||
;;
|
exit 0
|
||||||
qemu-debug)
|
fi
|
||||||
run_qemu -serial stdio -d int -no-reboot
|
|
||||||
;;
|
|
||||||
bochs)
|
|
||||||
run_bochs
|
|
||||||
;;
|
|
||||||
check-fs)
|
|
||||||
$BANAN_SCRIPT_DIR/check-fs.sh
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
build_target $1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
if [[ "$1" == "qemu-debug" ]]; then
|
||||||
|
run_qemu -serial stdio -d int -no-reboot
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "bochs" ]]; then
|
||||||
|
run_bochs
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" == "check-fs" ]]; then
|
||||||
|
$BANAN_SCRIPT_DIR/check-fs.sh
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_target $1
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
|
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
|
||||||
echo "You must set BANAN_DISK_IMAGE_PATH environment variable" >&2
|
echo "You must set BANAN_DISK_IMAGE_PATH environment variable" >&2
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
if [[ -z $BANAN_ROOT_DIR ]]; then
|
if [[ -z $BANAN_ROOT_DIR ]]; then
|
||||||
if ! [[ -z $BANAN_SCRIPT_DIR ]]; then
|
if [[ -z $BANAN_SCRIPT_DIR ]]; then
|
||||||
export BANAN_ROOT_DIR=$BANAN_SCRIPT_DIR/..
|
export BANAN_ROOT_DIR=$BANAN_SCRIPT_DIR/..
|
||||||
else
|
else
|
||||||
echo "You must set the BANAN_ROOT_DIR environment variable" >&2
|
echo "You must set the BANAN_ROOT_DIR environment variable" >&2
|
||||||
|
@ -8,7 +8,8 @@ if [[ -z $BANAN_ROOT_DIR ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $BANAN_ARCH ]]; then
|
if [[ -z $BANAN_ARCH ]]; then
|
||||||
export BANAN_ARCH=x86_64
|
echo "You must set the BANAN_ARCH environment variable" >&2
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export BANAN_TOOLCHAIN_DIR=$BANAN_ROOT_DIR/toolchain
|
export BANAN_TOOLCHAIN_DIR=$BANAN_ROOT_DIR/toolchain
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
|
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
|
||||||
echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2
|
echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2
|
||||||
|
@ -78,18 +79,18 @@ if [[ "$BANAN_UEFI_BOOT" == "1" ]]; then
|
||||||
sudo mkfs.fat $PARTITION1 > /dev/null
|
sudo mkfs.fat $PARTITION1 > /dev/null
|
||||||
sudo mount $PARTITION1 "$MOUNT_DIR"
|
sudo mount $PARTITION1 "$MOUNT_DIR"
|
||||||
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
|
sudo mkdir -p "$MOUNT_DIR/EFI/BOOT"
|
||||||
sudo "$BANAN_TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$BANAN_TOOLCHAIN_DIR/grub-memdisk.cfg"
|
sudo "$BANAN_TOOLCHAIN_PREFIX/bin/grub-mkstandalone" -O "$BANAN_ARCH-efi" -o "$MOUNT_DIR/EFI/BOOT/BOOTX64.EFI" "boot/grub/grub.cfg=$BANAN_TOOLCHAIN_PREFIX/grub-memdisk.cfg"
|
||||||
sudo umount "$MOUNT_DIR"
|
sudo umount "$MOUNT_DIR"
|
||||||
|
|
||||||
sudo mount $PARTITION2 "$MOUNT_DIR"
|
sudo mount $PARTITION2 "$MOUNT_DIR"
|
||||||
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
||||||
sudo cp "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
sudo cp "$BANAN_TOOLCHAIN_PREFIX/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
||||||
sudo umount "$MOUNT_DIR"
|
sudo umount "$MOUNT_DIR"
|
||||||
else
|
else
|
||||||
sudo mount $PARTITION2 "$MOUNT_DIR"
|
sudo mount $PARTITION2 "$MOUNT_DIR"
|
||||||
sudo grub-install --no-floppy --target=i386-pc --modules="normal ext2 multiboot" --boot-directory="$MOUNT_DIR/boot" $LOOP_DEV
|
sudo grub-install --no-floppy --target=i386-pc --modules="normal ext2 multiboot" --boot-directory="$MOUNT_DIR/boot" $LOOP_DEV
|
||||||
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
sudo mkdir -p "$MOUNT_DIR/boot/grub"
|
||||||
sudo cp "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
sudo cp "$BANAN_TOOLCHAIN_PREFIX/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg"
|
||||||
sudo umount "$MOUNT_DIR"
|
sudo umount "$MOUNT_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
|
if [[ -z $BANAN_DISK_IMAGE_PATH ]]; then
|
||||||
echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2
|
echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
*/
|
|
|
@ -10,16 +10,6 @@ if [[ -z $BANAN_SYSROOT ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $BANAN_ROOT_DIR ]]; then
|
|
||||||
echo "You must set the BANAN_ROOT_DIR environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $BANAN_BUILD_DIR ]]; then
|
|
||||||
echo "You must set the BANAN_BUILD_DIR environment variable" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $BANAN_TOOLCHAIN_DIR ]]; then
|
if [[ -z $BANAN_TOOLCHAIN_DIR ]]; then
|
||||||
echo "You must set the BANAN_TOOLCHAIN_DIR environment variable" >&2
|
echo "You must set the BANAN_TOOLCHAIN_DIR environment variable" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -40,16 +30,10 @@ if [[ -z $BANAN_ARCH ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
enter_clean_build () {
|
|
||||||
rm -rf build
|
|
||||||
mkdir build
|
|
||||||
cd build
|
|
||||||
}
|
|
||||||
|
|
||||||
build_binutils () {
|
build_binutils () {
|
||||||
echo "Building ${BINUTILS_VERSION}"
|
echo "Building ${BINUTILS_VERSION}"
|
||||||
|
|
||||||
cd $BANAN_BUILD_DIR/toolchain
|
cd $BANAN_TOOLCHAIN_DIR
|
||||||
|
|
||||||
if [ ! -f ${BINUTILS_VERSION}.tar.xz ]; then
|
if [ ! -f ${BINUTILS_VERSION}.tar.xz ]; then
|
||||||
wget https://ftp.gnu.org/gnu/binutils/${BINUTILS_VERSION}.tar.xz
|
wget https://ftp.gnu.org/gnu/binutils/${BINUTILS_VERSION}.tar.xz
|
||||||
|
@ -57,13 +41,13 @@ build_binutils () {
|
||||||
|
|
||||||
if [ ! -d $BINUTILS_VERSION ]; then
|
if [ ! -d $BINUTILS_VERSION ]; then
|
||||||
tar xvf ${BINUTILS_VERSION}.tar.xz
|
tar xvf ${BINUTILS_VERSION}.tar.xz
|
||||||
patch -s -p0 < $BANAN_TOOLCHAIN_DIR/${BINUTILS_VERSION}.patch
|
patch -s -p0 < ${BINUTILS_VERSION}.patch
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $BINUTILS_VERSION
|
mkdir -p build/${BINUTILS_VERSION}/
|
||||||
enter_clean_build
|
cd build/${BINUTILS_VERSION}/
|
||||||
|
|
||||||
../configure \
|
../../${BINUTILS_VERSION}/configure \
|
||||||
--target="$BANAN_TOOLCHAIN_TRIPLE_PREFIX" \
|
--target="$BANAN_TOOLCHAIN_TRIPLE_PREFIX" \
|
||||||
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
|
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
|
||||||
--with-sysroot="$BANAN_SYSROOT" \
|
--with-sysroot="$BANAN_SYSROOT" \
|
||||||
|
@ -77,7 +61,7 @@ build_binutils () {
|
||||||
build_gcc () {
|
build_gcc () {
|
||||||
echo "Building ${GCC_VERSION}"
|
echo "Building ${GCC_VERSION}"
|
||||||
|
|
||||||
cd $BANAN_BUILD_DIR/toolchain
|
cd $BANAN_TOOLCHAIN_DIR
|
||||||
|
|
||||||
if [ ! -f ${GCC_VERSION}.tar.xz ]; then
|
if [ ! -f ${GCC_VERSION}.tar.xz ]; then
|
||||||
wget https://ftp.gnu.org/gnu/gcc/${GCC_VERSION}/${GCC_VERSION}.tar.xz
|
wget https://ftp.gnu.org/gnu/gcc/${GCC_VERSION}/${GCC_VERSION}.tar.xz
|
||||||
|
@ -85,13 +69,13 @@ build_gcc () {
|
||||||
|
|
||||||
if [ ! -d $GCC_VERSION ]; then
|
if [ ! -d $GCC_VERSION ]; then
|
||||||
tar xvf ${GCC_VERSION}.tar.xz
|
tar xvf ${GCC_VERSION}.tar.xz
|
||||||
patch -s -p0 < $BANAN_TOOLCHAIN_DIR/${GCC_VERSION}.patch
|
patch -s -p0 < ${GCC_VERSION}.patch
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ${GCC_VERSION}
|
mkdir -p build/${GCC_VERSION}/
|
||||||
enter_clean_build
|
cd build/${GCC_VERSION}/
|
||||||
|
|
||||||
../configure \
|
../../${GCC_VERSION}/configure \
|
||||||
--target="$BANAN_TOOLCHAIN_TRIPLE_PREFIX" \
|
--target="$BANAN_TOOLCHAIN_TRIPLE_PREFIX" \
|
||||||
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
|
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
|
||||||
--with-sysroot="$BANAN_SYSROOT" \
|
--with-sysroot="$BANAN_SYSROOT" \
|
||||||
|
@ -106,7 +90,7 @@ build_gcc () {
|
||||||
build_grub () {
|
build_grub () {
|
||||||
echo "Building ${GRUB_VERSION}"
|
echo "Building ${GRUB_VERSION}"
|
||||||
|
|
||||||
cd $BANAN_BUILD_DIR/toolchain
|
cd $BANAN_TOOLCHAIN_DIR
|
||||||
|
|
||||||
if [ ! -f ${GRUB_VERSION}.tar.xz ]; then
|
if [ ! -f ${GRUB_VERSION}.tar.xz ]; then
|
||||||
wget https://ftp.gnu.org/gnu/grub/${GRUB_VERSION}.tar.xz
|
wget https://ftp.gnu.org/gnu/grub/${GRUB_VERSION}.tar.xz
|
||||||
|
@ -116,10 +100,10 @@ build_grub () {
|
||||||
tar xvf ${GRUB_VERSION}.tar.xz
|
tar xvf ${GRUB_VERSION}.tar.xz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $GRUB_VERSION
|
mkdir -p build/${GRUB_VERSION}/
|
||||||
enter_clean_build
|
cd build/${GRUB_VERSION}/
|
||||||
|
|
||||||
../configure \
|
../../${GRUB_VERSION}/configure \
|
||||||
--target="$BANAN_ARCH" \
|
--target="$BANAN_ARCH" \
|
||||||
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
|
--prefix="$BANAN_TOOLCHAIN_PREFIX" \
|
||||||
--with-platform="efi" \
|
--with-platform="efi" \
|
||||||
|
@ -130,35 +114,16 @@ build_grub () {
|
||||||
}
|
}
|
||||||
|
|
||||||
build_libstdcpp () {
|
build_libstdcpp () {
|
||||||
if ! [[ -d $BANAN_BUILD_DIR/toolchain/$GCC_VERSION/build ]]; then
|
cd build/${GCC_VERSION}/
|
||||||
echo "You have to build gcc first"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $BANAN_BUILD_DIR/toolchain/$GCC_VERSION/build
|
|
||||||
make -j $(nproc) all-target-libstdc++-v3
|
make -j $(nproc) all-target-libstdc++-v3
|
||||||
make install-target-libstdc++-v3
|
make install-target-libstdc++-v3
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# -ge 1 ]]; then
|
|
||||||
if [[ "$1" == "libstdc++" ]]; then
|
if [[ "$1" == "libstdc++" ]]; then
|
||||||
build_libstdcpp
|
build_libstdcpp
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "unrecognized arguments $@"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# NOTE: we have to manually create initial sysroot with libc headers
|
|
||||||
# since cmake cannot be invoked yet
|
|
||||||
echo "Syncing sysroot headers"
|
|
||||||
mkdir -p $BANAN_SYSROOT
|
|
||||||
sudo mkdir -p $BANAN_SYSROOT/usr/include
|
|
||||||
sudo rsync -a $BANAN_ROOT_DIR/libc/include/ $BANAN_SYSROOT/usr/include/
|
|
||||||
|
|
||||||
mkdir -p $BANAN_BUILD_DIR/toolchain
|
|
||||||
|
|
||||||
build_binutils
|
build_binutils
|
||||||
build_gcc
|
build_gcc
|
||||||
build_grub
|
build_grub
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
*/
|
|
@ -833,8 +833,6 @@ int main(int argc, char** argv)
|
||||||
if (signal(SIGINT, [](int) {}) == SIG_ERR)
|
if (signal(SIGINT, [](int) {}) == SIG_ERR)
|
||||||
perror("signal");
|
perror("signal");
|
||||||
|
|
||||||
tcgetattr(0, &old_termios);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
FILE* fp = fopen("/etc/hostname", "r");
|
FILE* fp = fopen("/etc/hostname", "r");
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
|
@ -878,6 +876,8 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
source_shellrc();
|
source_shellrc();
|
||||||
|
|
||||||
|
tcgetattr(0, &old_termios);
|
||||||
|
|
||||||
new_termios = old_termios;
|
new_termios = old_termios;
|
||||||
new_termios.c_lflag &= ~(ECHO | ICANON);
|
new_termios.c_lflag &= ~(ECHO | ICANON);
|
||||||
tcsetattr(0, TCSANOW, &new_termios);
|
tcsetattr(0, TCSANOW, &new_termios);
|
||||||
|
|
|
@ -45,7 +45,7 @@ int main()
|
||||||
|
|
||||||
while (ssize_t nread = read(fd, path_buffer, sizeof(path_buffer) - 1))
|
while (ssize_t nread = read(fd, path_buffer, sizeof(path_buffer) - 1))
|
||||||
{
|
{
|
||||||
if (nread < 0)
|
if (nread == -1)
|
||||||
{
|
{
|
||||||
perror("read");
|
perror("read");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue