X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libbb%2Ffind_root_device.c;h=8436cd664fcb28091299126baf82dfc5e3a59c4d;hb=b2320370be14811459718b9fe418efed75ea3615;hp=9779f7e82d190d064782fdd38aba50522ca74e66;hpb=706fdc98c3d30687d1ce359f58424c87e253017c;p=oweals%2Fbusybox.git diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c index 9779f7e82..8436cd664 100644 --- a/libbb/find_root_device.c +++ b/libbb/find_root_device.c @@ -4,7 +4,7 @@ * * Copyright (C) 1999-2004 by Erik Andersen * - * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ #include "libbb.h" @@ -29,14 +29,15 @@ static char *find_block_device_in_dir(struct arena *ap) char *retpath = NULL; int len, rem; - dir = opendir(ap->devpath); - if (!dir) - return NULL; - len = strlen(ap->devpath); rem = DEVNAME_MAX-2 - len; if (rem <= 0) return NULL; + + dir = opendir(ap->devpath); + if (!dir) + return NULL; + ap->devpath[len++] = '/'; while ((entry = readdir(dir)) != NULL) { @@ -62,7 +63,7 @@ static char *find_block_device_in_dir(struct arena *ap) return retpath; } -char *find_block_device(const char *path) +char* FAST_FUNC find_block_device(const char *path) { struct arena a;