Npfcall* diod_readlink(Npfid *fid) { Fid *f = fid->aux; Npfcall *ret = NULL; char target[PATH_MAX + 1]; int n; if ((n = readlink (f->path, target, sizeof(target))) < 0) { np_uerror (errno); goto error_quiet; } target[n] = '\0'; if (!(ret = np_create_rreadlink(target))) { np_uerror (ENOMEM); goto error; } return ret; error: errn (np_rerror (), "diod_readlink %s@%s:%s", fid->user->uname, np_conn_get_client_id (fid->conn), f->path); error_quiet: if (ret) free (ret); return NULL; }
static void test_rreadlink (void) { Npfcall *fc, *fc2; if (!(fc = np_create_rreadlink ("xyz"))) msg_exit ("out of memory"); fc2 = _rcv_buf (fc, P9_RREADLINK, __FUNCTION__); assert (np_str9cmp (&fc->u.rreadlink.target, &fc2->u.rreadlink.target) == 0); free (fc); free (fc2); }