struct rpc_context *rpc_init_udp_context(void) { struct rpc_context *rpc; rpc = rpc_init_context(); if (rpc != NULL) { rpc->is_udp = 1; } return rpc; }
static int Open(vlc_object_t *p_obj) { access_t *p_access = (access_t *)p_obj; access_sys_t *p_sys = calloc(1, sizeof (*p_sys)); if (unlikely(p_sys == NULL)) goto error; p_access->p_sys = p_sys; p_sys->b_auto_guid = var_InheritBool(p_obj, "nfs-auto-guid"); /* nfs_* functions need a decoded url */ p_sys->psz_url_decoded = vlc_uri_decode_duplicate(p_access->psz_url); if (p_sys->psz_url_decoded == NULL) goto error; /* Parse the encoded URL */ vlc_UrlParse(&p_sys->encoded_url, p_access->psz_url); if (p_sys->encoded_url.psz_option) { if (strstr(p_sys->encoded_url.psz_option, "uid") || strstr(p_sys->encoded_url.psz_option, "gid")) p_sys->b_auto_guid = false; } if (NfsInit(p_access, p_sys->psz_url_decoded) == -1) goto error; if (p_sys->p_nfs_url->path != NULL && p_sys->p_nfs_url->file != NULL) { /* The url has a valid path and file, mount the path and open/opendir * the file */ msg_Dbg(p_access, "nfs_mount: server: '%s', path: '%s'", p_sys->p_nfs_url->server, p_sys->p_nfs_url->path); if (nfs_mount_async(p_sys->p_nfs, p_sys->p_nfs_url->server, p_sys->p_nfs_url->path, nfs_mount_cb, p_access) < 0) { msg_Err(p_access, "nfs_mount_async failed"); goto error; } if (vlc_nfs_mainloop(p_access, nfs_mount_open_finished_cb) < 0) goto error; if (p_sys->psz_url_decoded_slash != NULL) { /* Retry to mount by adding a '/' to the path, see comment in * nfs_mount_cb */ nfs_destroy_url(p_sys->p_nfs_url); nfs_destroy_context(p_sys->p_nfs); p_sys->p_nfs_url = NULL; p_sys->p_nfs = NULL; if (NfsInit(p_access, p_sys->psz_url_decoded_slash) == -1 || p_sys->p_nfs_url->path == NULL || p_sys->p_nfs_url->file == NULL) goto error; if (nfs_mount_async(p_sys->p_nfs, p_sys->p_nfs_url->server, p_sys->p_nfs_url->path, nfs_mount_cb, p_access) < 0) { msg_Err(p_access, "nfs_mount_async failed"); goto error; } if (vlc_nfs_mainloop(p_access, nfs_mount_open_slash_finished_cb) < 0) goto error; } if (p_sys->p_nfsfh != NULL) { p_access->pf_read = FileRead; p_access->pf_seek = FileSeek; p_access->pf_control = FileControl; } else if (p_sys->p_nfsdir != NULL) { p_access->pf_readdir = DirRead; p_access->pf_seek = NULL; p_access->pf_control = DirControl; } else vlc_assert_unreachable(); } else { /* url is just a server: fetch exports point */ nfs_destroy_context(p_sys->p_nfs); p_sys->p_nfs = NULL; p_sys->p_mount = rpc_init_context(); if (p_sys->p_mount == NULL) { msg_Err(p_access, "rpc_init_context failed"); goto error; } p_sys->res.exports.ppsz_names = NULL; p_sys->res.exports.i_count = -1; if (mount_getexports_async(p_sys->p_mount, p_sys->p_nfs_url->server, mount_export_cb, p_access) < 0) { msg_Err(p_access, "mount_getexports_async failed"); goto error; } if (vlc_mount_mainloop(p_access, mount_getexports_finished_cb) < 0) goto error; p_access->pf_readdir = MountRead; p_access->pf_seek = NULL; p_access->pf_control = DirControl; } return VLC_SUCCESS; error: Close(p_obj); return VLC_EGENERIC; }