Example #1
0
static void
test_rlink (void)
{
    Npfcall *fc, *fc2;

    if (!(fc = np_create_rlink ()))
        msg_exit ("out of memory");
    fc2 = _rcv_buf (fc, P9_RLINK,  __FUNCTION__);

    free (fc);
    free (fc2);
}
Example #2
0
Npfcall*
diod_link (Npfid *dfid, Npfid *fid, Npstr *name)
{
    Fid *f = fid->aux;
    Npfcall *ret = NULL;
    Fid *df = dfid->aux;
    char *npath = NULL;
    int created = 0;

    if ((f->xflags & XFLAGS_RO)) {
        np_uerror (EROFS);
        goto error_quiet;
    }
    if (!(npath = _mkpath(df->path, name))) {
        np_uerror (ENOMEM);
        goto error;
    }
    if (link (f->path, npath) < 0) {
        np_uerror (errno);
        goto error_quiet;
    }
    created = 1;
    if (!((ret = np_create_rlink ()))) {
        np_uerror (ENOMEM);
        goto error;
    }
    free (npath);
    return ret;
error:
    errn (np_rerror (), "diod_link %s@%s:%s %s/%.*s",
          fid->user->uname, np_conn_get_client_id (fid->conn), f->path,
          df->path, name->len, name->str);
error_quiet:
    if (created && npath)
        (void)unlink (npath);
    if (npath)
        free (npath);
    if (ret)
        free (ret);
    return NULL;
}
Example #3
0
Npfcall*
diod_link (Npfid *dfid, Npfid *fid, Npstr *name)
{
    Npsrv *srv = fid->conn->srv;
    Fid *f = fid->aux;
    Npfcall *ret;
    Fid *df = dfid->aux;
    Path npath = NULL;

    if ((f->flags & DIOD_FID_FLAGS_ROFS)) {
        np_uerror (EROFS);
        goto error_quiet;
    }
    if (!(npath = path_append (srv, df->path, name))) {
        np_uerror (ENOMEM);
        goto error;
    }
    if (link (path_s (f->path), path_s (npath)) < 0) {
        np_uerror (errno);
        goto error_quiet;
    }
    if (!((ret = np_create_rlink ()))) {
        (void)unlink (path_s (npath));
        np_uerror (ENOMEM);
        goto error;
    }
    path_decref (srv, npath);
    return ret;
error:
    errn (np_rerror (), "diod_link %s@%s:%s %s/%.*s",
          fid->user->uname, np_conn_get_client_id (fid->conn), path_s (f->path),
          path_s (df->path), name->len, name->str);
error_quiet:
    if (npath)
        path_decref (srv, npath);
    return NULL;
}