static int fuse_nfs_release(const char *path, struct fuse_file_info *fi) { struct nfsfh *nfsfh = (struct nfsfh *)fi->fh; nfs_close(nfs, nfsfh); return 0; }
static void Close(vlc_object_t *p_obj) { access_t *p_access = (access_t *)p_obj; access_sys_t *p_sys = p_access->p_sys; if (p_sys->p_nfsfh != NULL) nfs_close(p_sys->p_nfs, p_sys->p_nfsfh); if (p_sys->p_nfsdir != NULL) nfs_closedir(p_sys->p_nfs, p_sys->p_nfsdir); if (p_sys->p_nfs != NULL) nfs_destroy_context(p_sys->p_nfs); if (p_sys->p_mount != NULL) { for (int i = 0; i < p_sys->res.exports.i_count; ++i) free(p_sys->res.exports.ppsz_names[i]); free(p_sys->res.exports.ppsz_names); rpc_destroy_context(p_sys->p_mount); } if (p_sys->p_nfs_url != NULL) nfs_destroy_url(p_sys->p_nfs_url); vlc_UrlClean(&p_sys->encoded_url); free(p_sys->psz_url_decoded); free(p_sys->psz_url_decoded_slash); free(p_sys); }
static void workspace_nfs_release(fuse_req_t req, struct workspace_fh_struct *fh) { struct resource_struct *resource=fh->object->resource; struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data; struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data; struct nfsfh *nfsfh=(struct nfsfh *) fh->handle.data; struct fuse_file_info *fi=fh->fi; logoutput("workspace_nfs_release"); if (nfsfh) { int result=0; pthread_mutex_lock(&nfs_export->mutex); result=nfs_close(nfs_ctx, nfsfh); pthread_mutex_unlock(&nfs_export->mutex); } free(fh); fi->fh=0; fuse_reply_err(req, 0); }
static void free_file_context(struct file_context *file_context) { if (file_context->fd != -1) { close(file_context->fd); } if (file_context->nfsfh != NULL) { nfs_close(file_context->nfs, file_context->nfsfh); } if (file_context->nfs != NULL) { nfs_destroy_context(file_context->nfs); } free(file_context); }
static void workspace_nfs_fsync(fuse_req_t req, int datasync, struct workspace_fh_struct *fh) { struct resource_struct *resource=fh->object->resource; struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data; struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data; struct nfsfh *nfsfh=(struct nfsfh *) fh->handle.data; int result=0; logoutput("workspace_nfs_fsync"); pthread_mutex_lock(&nfs_export->mutex); result=nfs_close(nfs_ctx, nfsfh); pthread_mutex_unlock(&nfs_export->mutex); fuse_reply_err(req, abs(result)); }
int close(int fd) { if (nfs_fd_list[fd].is_nfs == 1) { int i; LD_NFS_DPRINTF(9, "close(%d)", fd); nfs_fd_list[fd].is_nfs = 0; nfs_close(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh); nfs_fd_list[fd].fh = NULL; nfs_destroy_context(nfs_fd_list[fd].nfs); nfs_fd_list[fd].nfs = NULL; free(discard_const(nfs_fd_list[fd].path)); nfs_fd_list[fd].path = NULL; return 0; } return real_close(fd); }
int main(int argc, char *argv[]) { int ret = 1; struct nfs_context *nfs = NULL; struct nfsfh *nfsfh = NULL; struct nfs_url *url = NULL; #ifdef WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { printf("Failed to start Winsock2\n"); exit(10); } #endif #ifdef AROS aros_init_socket(); #endif if (argc < 3) { fprintf(stderr, "No URL specified.\n"); goto finished; } nfs = nfs_init_context(); if (nfs == NULL) { printf("failed to init context\n"); goto finished; } url = nfs_parse_url_full(nfs, argv[argc - 1]); if (url == NULL) { fprintf(stderr, "%s\n", nfs_get_error(nfs)); goto finished; } if (nfs_mount(nfs, url->server, url->path) != 0) { fprintf(stderr, "Failed to mount nfs share : %s\n", nfs_get_error(nfs)); goto finished; } if (!strncmp(argv[1], "creat", 5)) { ret = nfs_creat(nfs, url->file, 0600, &nfsfh); } else if (!strncmp(argv[1], "unlink", 6)) { ret = nfs_unlink(nfs, url->file); } else if (!strncmp(argv[1], "mkdir", 5)) { ret = nfs_mkdir(nfs, url->file); } else if (!strncmp(argv[1], "rmdir", 5)) { ret = nfs_rmdir(nfs, url->file); } else if (!strncmp(argv[1], "stat", 4)) { struct nfs_stat_64 st; ret = nfs_stat64(nfs, url->file, &st); if (!ret) { switch (st.nfs_mode & S_IFMT) { #ifndef WIN32 case S_IFLNK: printf("l"); break; #endif case S_IFREG: printf("-"); break; case S_IFDIR: printf("d"); break; case S_IFCHR: printf("c"); break; case S_IFBLK: printf("b"); break; } printf("%c%c%c", "-r"[!!(st.nfs_mode & S_IRUSR)], "-w"[!!(st.nfs_mode & S_IWUSR)], "-x"[!!(st.nfs_mode & S_IXUSR)] ); printf("%c%c%c", "-r"[!!(st.nfs_mode & S_IRGRP)], "-w"[!!(st.nfs_mode & S_IWGRP)], "-x"[!!(st.nfs_mode & S_IXGRP)] ); printf("%c%c%c", "-r"[!!(st.nfs_mode & S_IROTH)], "-w"[!!(st.nfs_mode & S_IWOTH)], "-x"[!!(st.nfs_mode & S_IXOTH)] ); printf(" %2d", (int)st.nfs_nlink); printf(" %5d", (int)st.nfs_uid); printf(" %5d", (int)st.nfs_gid); printf(" %12" PRId64, st.nfs_size); printf("\n"); } } else { goto finished; } if (ret) { fprintf(stderr, "ERROR: %s\n", nfs_get_error(nfs)); } finished: if (ret > 0) { print_usage(); } nfs_destroy_url(url); if (nfs != NULL) { if (nfsfh) { nfs_close(nfs, nfsfh); } nfs_destroy_context(nfs); } return !!ret; }