/* Tclunk - close a file. */ Npfcall* diod_clunk (Npfid *fid) { Fid *f = fid->aux; Npfcall *ret; if (f->dir) { if (closedir(f->dir) < 0) { np_uerror (errno); goto error_quiet; } } else if (f->fd != -1) { if (close (f->fd) < 0) { np_uerror (errno); goto error_quiet; } } if (!(ret = np_create_rclunk ())) { np_uerror (ENOMEM); goto error; } return ret; error: errn (np_rerror (), "diod_clunk %s@%s:%s", fid->user->uname, np_conn_get_client_id (fid->conn), f->path); error_quiet: return NULL; }
Npfcall * np_clunk(Npreq *req, Npfcall *tc) { Npfid *fid = req->fid; Npfcall *rc = NULL; if (!fid) { np_uerror (EIO); goto done; } if (fid->type & P9_QTAUTH) { if (req->conn->srv->auth) { /* N.B. fidpool calls auth->clunk on last decref */ if (!(rc = np_create_rclunk())) np_uerror(ENOMEM); } else np_uerror(EIO); goto done; } if (fid->type & P9_QTTMP) { rc = np_ctl_clunk (fid); } else { if (!req->conn->srv->clunk) { np_uerror (ENOSYS); goto done; } rc = (*req->conn->srv->clunk)(fid); } done: if (rc && rc->type == P9_RCLUNK) np_fid_decref(fid); return rc; }
static Npfcall * myclunk (Npfid *fid) { Npfcall *ret; if (!(ret = np_create_rclunk ())) { np_uerror (ENOMEM); return NULL; } return ret; }
static void test_rclunk (void) { Npfcall *fc, *fc2; if (!(fc = np_create_rclunk ())) msg_exit ("out of memory in %s", __FUNCTION__); fc2 = _rcv_buf (fc, P9_RCLUNK, __FUNCTION__); free (fc); free (fc2); }
static Npfcall* openssl_clunk(Npfid *afid) { struct openssl_session_auth_context* ctx; ctx = (struct openssl_session_auth_context*)afid->aux; if ( ctx == NULL ) { return np_create_rerror("No session context",EINVAL,1); } pthread_join(ctx->auth_thread, NULL); pthread_mutex_destroy(&ctx->lock); pthread_cond_destroy(&ctx->cond); free(ctx->uname); free(ctx); done: np_fid_decref(afid); return np_create_rclunk(); }
/* Tclunk - close a file. */ Npfcall* diod_clunk (Npfid *fid) { Fid *f = fid->aux; Npfcall *ret = NULL; if (!(ret = np_create_rclunk ())) { np_uerror (ENOMEM); goto error; } return ret; error: errn (np_rerror (), "diod_clunk %s@%s:%s", fid->user->uname, np_conn_get_client_id (fid->conn), f->path); if (ret) free (ret); return NULL; }
static Npfcall * np_clunk(Npreq *req, Npfcall *tc) { Npconn *conn; Npfid *fid; Npfcall *rc; rc = NULL; conn = req->conn; fid = np_fid_find(conn, tc->fid); if (!fid) { np_werror(Eunknownfid, EIO); goto done; } else np_fid_incref(fid); req->fid = fid; if (fid->type&Qtauth) { if (conn->srv->auth) rc = conn->srv->auth->clunk(fid); else np_werror(Ebadusefid, EIO); goto done; } if (fid->omode!=(u16)~0 && fid->omode==Orclose) { rc = (*conn->srv->remove)(fid); if (rc->id == Rerror) goto done; free(rc); rc = np_create_rclunk(); } else rc = (*conn->srv->clunk)(fid); done: np_fid_decref(fid); return rc; }
/* Tclunk - close a file. */ Npfcall* diod_clunk (Npfid *fid) { Fid *f = fid->aux; Npfcall *ret; if (f->ioctx) { if (ioctx_close (fid, 1) < 0) goto error_quiet; } if (!(ret = np_create_rclunk ())) { np_uerror (ENOMEM); goto error; } return ret; error: errn (np_rerror (), "diod_clunk %s@%s:%s", fid->user->uname, np_conn_get_client_id (fid->conn), path_s (f->path)); error_quiet: return NULL; }