/*************************************************************** SYS-CHDIR.C This file contains Linux/x86_64/LP64 implementation of __cpu_sys_cwd_init() and __cpu_sys_chdir(). PART OF : CPU - library . USAGE : Internal only . Copyright (C) 2026 by Andrew V.Kosteltsev. All Rights Reserved. ***************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include static __mpu_int64_t __cpu_open_directory( int dirfd, const char *path ) { int fd; if( !path ) return( -(__mpu_int64_t)__MCPU_EFAULT ); fd = openat( dirfd, path, O_PATH | O_DIRECTORY | O_CLOEXEC ); if( fd < 0 ) return( -(__mpu_int64_t)__cpu_errno_from_host( errno ) ); return( (__mpu_int64_t)fd ); } /* End of __cpu_open_directory() */ __mpu_int64_t __cpu_sys_cwd_init( void ) { return( __cpu_open_directory( AT_FDCWD, "." ) ); } /* End of __cpu_sys_cwd_init() */ __mpu_int64_t __cpu_sys_chdir( int dirfd, const char *path ) { return( __cpu_open_directory( dirfd, path ) ); } /* End of __cpu_sys_chdir() */