Skip to content

Commit

Permalink
volstream_open instead of open_memstream in vufs and pseudofile
Browse files Browse the repository at this point in the history
  • Loading branch information
rd235 committed Nov 23, 2024
1 parent cad9e1b commit 32f435c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 1 addition & 7 deletions libvumod/vu_mod_pseudofile.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ struct pseudofile {
void *pseudoprivate;
int flags;
FILE *f;
char *ptr;
size_t len;
};

int pseudofile_mode2type(mode_t mode) {
Expand Down Expand Up @@ -99,15 +97,13 @@ int pseudofile_open(pseudo_upcall upcall, void *pseudoprivate, int flags, void *
pseudofile->pseudoprivate = pseudoprivate;
pseudofile->flags = flags;
pseudofile->f = NULL;
pseudofile->ptr = NULL;
pseudofile->len = 0;

*private = pseudofile;
return 0;
}

static void pseudofile_load_contents(struct pseudofile *pseudofile) {
pseudofile->f = open_memstream(&pseudofile->ptr, &pseudofile->len);
pseudofile->f = volstream_open();
if ((pseudofile->flags & O_ACCMODE) != O_WRONLY && !(pseudofile->flags & O_TRUNC)) {
pseudofile->upcall(PSEUDOFILE_LOAD_CONTENTS, pseudofile->f, pseudofile->flags, pseudofile->pseudoprivate);
fflush(pseudofile->f);
Expand All @@ -124,8 +120,6 @@ int pseudofile_close(int fd, void *private) {
pseudofile->upcall(PSEUDOFILE_STORE_CLOSE, pseudofile->f, pseudofile->flags, pseudofile->pseudoprivate);
if (pseudofile->f)
fclose(pseudofile->f);
if (pseudofile->ptr)
free(pseudofile->ptr);
free(pseudofile);
}
return 0;
Expand Down
8 changes: 3 additions & 5 deletions vufs/vufs_getdents.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ static int vufs_seen_entry(char *s, char *list) {
}

static void vufs_filldir(unsigned int fd, struct vufs_t *vufs, struct vufs_fdprivate *vufs_fdprivate) {
char *seenlist = NULL;
size_t seenlistlen = 0;
FILE *seenf = open_memstream(&seenlist, &seenlistlen);
FILE *seenf = volstream_open();
void *seenlist = NULL;
DIR *dir;
struct dirent *de;
int dirfd;
Expand Down Expand Up @@ -112,6 +111,7 @@ static void vufs_filldir(unsigned int fd, struct vufs_t *vufs, struct vufs_fdpri
/* write the empty string as the end of the seen list */
fwrite("", 1, 1, seenf);
fflush(seenf);
volstream_getbuf(seenf, &seenlist, NULL);
/* ADD unseen entries in rdirfd (target) (if merge) */
if (vufs_fdprivate->path[0] == 0)
dirfd = openat(vufs->rdirfd, vufs->target, O_RDONLY | O_DIRECTORY);
Expand All @@ -127,8 +127,6 @@ static void vufs_filldir(unsigned int fd, struct vufs_t *vufs, struct vufs_fdpri
}
}
fclose(seenf);
if (seenlist != NULL)
free(seenlist);
fseeko(vufs_fdprivate->getdentsf, 0, SEEK_SET);
}

Expand Down

0 comments on commit 32f435c

Please sign in to comment.