partx_SOURCES = partx.c partx.h \
$(top_srcdir)/lib/blkdev.c \
$(top_srcdir)/lib/tt.c \
+ $(top_srcdir)/lib/at.c \
$(top_srcdir)/lib/mbsalign.c \
$(top_srcdir)/lib/strutils.c \
$(top_srcdir)/lib/linux_version.c
#include "strutils.h"
#include "xalloc.h"
#include "partx.h"
+#include "at.h"
/* this is the default upper limit, could be modified by --nr */
#define SLICES_MAX 256
static int get_max_partno(const char *disk, dev_t devno)
{
- char path[PATH_MAX], *parent;
+ char path[PATH_MAX], *parent, *dirname = NULL;
struct stat st;
DIR *dir;
struct dirent *d;
if (!dir)
goto dflt;
- while ((d = readdir(dir))) {
+ dirname = xstrdup(path);
+
+ while ((d = readdir(dir))) {
int fd;
if (!strcmp(d->d_name, ".") ||
continue;
snprintf(path, sizeof(path), "%s/partition", d->d_name);
- fd = openat(dirfd(dir), path, O_RDONLY);
+ fd = open_at(dirfd(dir), dirname, path, O_RDONLY);
if (fd) {
int x = 0;
FILE *f = fdopen(fd, "r");
}
}
+ free(dirname);
closedir(dir);
return partno;
dflt: