database: relocate find_mountpoint()
parent
ae4008c4f2
commit
dfe2e141ca
|
@ -1338,35 +1338,6 @@ static void handle_alarm(int sig)
|
|||
{
|
||||
}
|
||||
|
||||
static char *find_mountpoint(int atfd, const char *rel_path)
|
||||
{
|
||||
struct mntent *me;
|
||||
struct stat st;
|
||||
FILE *f;
|
||||
char *ret = NULL;
|
||||
dev_t dev;
|
||||
|
||||
if (fstatat(atfd, rel_path, &st, 0) != 0)
|
||||
return NULL;
|
||||
dev = st.st_dev;
|
||||
|
||||
f = setmntent("/proc/mounts", "r");
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
while ((me = getmntent(f)) != NULL) {
|
||||
if (strcmp(me->mnt_fsname, "rootfs") == 0)
|
||||
continue;
|
||||
if (fstatat(atfd, me->mnt_dir, &st, 0) == 0 &&
|
||||
st.st_dev == dev) {
|
||||
ret = strdup(me->mnt_dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
endmntent(f);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void mark_in_cache(struct apk_database *db, int dirfd, const char *name, struct apk_package *pkg)
|
||||
{
|
||||
if (pkg == NULL)
|
||||
|
@ -1505,6 +1476,35 @@ static unsigned long map_statfs_flags(unsigned long f_flag)
|
|||
return mnt_flags;
|
||||
}
|
||||
|
||||
static char *find_mountpoint(int atfd, const char *rel_path)
|
||||
{
|
||||
struct mntent *me;
|
||||
struct stat st;
|
||||
FILE *f;
|
||||
char *ret = NULL;
|
||||
dev_t dev;
|
||||
|
||||
if (fstatat(atfd, rel_path, &st, 0) != 0)
|
||||
return NULL;
|
||||
dev = st.st_dev;
|
||||
|
||||
f = setmntent("/proc/mounts", "r");
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
while ((me = getmntent(f)) != NULL) {
|
||||
if (strcmp(me->mnt_fsname, "rootfs") == 0)
|
||||
continue;
|
||||
if (fstatat(atfd, me->mnt_dir, &st, 0) == 0 &&
|
||||
st.st_dev == dev) {
|
||||
ret = strdup(me->mnt_dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
endmntent(f);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int setup_cache(struct apk_database *db, struct apk_ctx *ac)
|
||||
{
|
||||
struct apk_out *out = &ac->out;
|
||||
|
|
Loading…
Reference in New Issue