Skip to content

configure: allow shmem mount path to be a symlinked directory #5680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/app/shared/commands/configure/hugetlbfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,10 @@ fini( config_t const * config,
int pre_init ) {
(void)pre_init;

/* Not used by fdctl but might be created by other debugging tools
on the system. */

char normal_page_mount_path[ PATH_MAX ];
FD_TEST( fd_cstr_printf_check( normal_page_mount_path, PATH_MAX, NULL, "%s/.normal", config->hugetlbfs.mount_path ) );

const char * mount_path[ 3 ] = {
config->hugetlbfs.huge_page_mount_path,
config->hugetlbfs.gigantic_page_mount_path,
normal_page_mount_path,
config->hugetlbfs.normal_page_mount_path,
};

for( ulong i=0UL; i<3UL; i++ ) {
Expand Down Expand Up @@ -338,9 +332,16 @@ check( config_t const * config ) {
PARTIALLY_CONFIGURED( "mount `%s` is on unrecognized device, expected `none`", mount_path[ i ] );
}

/* Resolve symlinks for mount_path as the mounts table has the resolved paths */
char resolved_mount_path[ PATH_MAX ];
if( FD_UNLIKELY( !realpath( mount_path[ i ], resolved_mount_path ) ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use real syscall, e.g. readlink here instead of libc which might do other kinds of garbage underneath us. Also, failure to resolve is an FD_LOG_ERR, not a PARTIALLY_CONFIGURED (which is going to cause us to try blow away the directory).

FD_LOG_WARNING(( "realpath() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
PARTIALLY_CONFIGURED( "mount path `%s` cannot be resolved", mount_path[ i ] );
}

char * path1 = strtok_r( NULL, " ", &saveptr );
if( FD_UNLIKELY( !path1 ) ) FD_LOG_ERR(( "error parsing `/proc/self/mounts`, line `%s`", line ));
if( FD_UNLIKELY( strcmp( path1, mount_path[ i ] ) ) ) {
if( FD_UNLIKELY( strcmp( path1, resolved_mount_path ) ) ) {
if( FD_UNLIKELY( fclose( fp ) ) )
FD_LOG_ERR(( "error closing `/proc/self/mounts` (%i-%s)", errno, fd_io_strerror( errno ) ));
PARTIALLY_CONFIGURED( "mount `%s` is on unrecognized path, expected `%s`", path1, mount_path[ i ] );
Expand Down
Loading