Thanks Stefan. I will send next version with incorporating your suggestions. > dpath is leaked in the success case. I suggest writing the function like > this: static int get_dirfd(FsContext *fs_ctx, const char *path) > { > int fd; > char *dpath; > char *last_component; > > /* path can not contain ".." */ > last_component = strrchr(path, '/'); > if (last_component && !strcmp(last_component, "/..")) { > error_report("9p path request contains \"..\": %s\n", path); > errno = EFAULT; > return -1; > } > dpath = qemu_strdup(path); > fd = passthrough_request(fs_ctx, NULL, dirname(dpath), 0, NULL, > T_OPEN); qemu_free(dpath); > if (fd < 0) { > errno = -fd; > fd = -1; > } > return fd; > }
Ok, I will rewrite the function as you mentioned. > > > -static int local_utimensat(FsContext *s, const char *path, > > - const struct timespec *buf) > > +static int local_utimensat(FsContext *fs_ctx, const char *path, > > + const struct timespec *buf) > > > > { > > > > - return qemu_utimensat(AT_FDCWD, rpath(s, path), buf, > > AT_SYMLINK_NOFOLLOW); + if (fs_ctx->fs_sm == SM_PASSTHROUGH) { > > + int fd, retval; > > + fd = passthrough_request(fs_ctx, NULL, path, > > + O_RDONLY | O_NONBLOCK | O_NOFOLLOW, NULL, > > T_OPEN); + if (fd < 0) { > > + errno = -fd; > > + return -1; > > + } > > + retval = futimens(fd, buf); > > + close(fd); > > + return retval; > > errno is clobbered here. I will fix it. ---- M. Mohan Kumar