Changeset 2cd2ed3 in rtems


Ignore:
Timestamp:
05/04/12 11:26:07 (12 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
48e02af, 6fe700c
Parents:
078369f
git-author:
Sebastian Huber <sebastian.huber@…> (05/04/12 11:26:07)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/04/12 11:29:45)
Message:

nfsclient: Add rename operation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/nfsclient/src/nfs.c

    r078369f r2cd2ed3  
    20452045}
    20462046
     2047static int nfs_rename(
     2048        const rtems_filesystem_location_info_t *oldparentloc,
     2049        const rtems_filesystem_location_info_t *oldloc,
     2050        const rtems_filesystem_location_info_t *newparentloc,
     2051        const char *name,
     2052        size_t namelen
     2053)
     2054{
     2055        int rv = 0;
     2056        char *dupname = nfs_dupname(name, namelen);
     2057
     2058        if (dupname != NULL) {
     2059                NfsNode oldParentNode = oldparentloc->node_access;
     2060                NfsNode oldNode = oldloc->node_access;
     2061                NfsNode newParentNode = newparentloc->node_access;
     2062                Nfs nfs = oldParentNode->nfs;
     2063                const nfs_fh *toDirSrc = &SERP_FILE(newParentNode);
     2064                nfs_fh *toDirDst = &SERP_ARGS(oldParentNode).renamearg.to.dir;
     2065                nfsstat status;
     2066
     2067                SERP_ARGS(oldParentNode).renamearg.name = oldNode->str;
     2068                SERP_ARGS(oldParentNode).renamearg.to.name = dupname;
     2069                memcpy(toDirDst, toDirSrc, sizeof(*toDirDst));
     2070
     2071                rv = nfscall(
     2072                        nfs->server,
     2073                        NFSPROC_RENAME,
     2074                        (xdrproc_t) xdr_renameargs,
     2075                        &SERP_FILE(oldParentNode),
     2076                        (xdrproc_t) xdr_nfsstat,
     2077                        &status
     2078                );
     2079                if (rv == 0 && (errno = status) != NFS_OK) {
     2080                        rv = -1;
     2081                }
     2082
     2083                free(dupname);
     2084        } else {
     2085                rv = -1;
     2086        }
     2087
     2088        return rv;
     2089}
     2090
    20472091static void nfs_lock(rtems_filesystem_mount_table_entry_t *mt_entry)
    20482092{
     
    21052149        .symlink_h      = nfs_symlink,
    21062150        .readlink_h     = nfs_readlink,
    2107         .rename_h       = rtems_filesystem_default_rename,
     2151        .rename_h       = nfs_rename,
    21082152        .statvfs_h      = rtems_filesystem_default_statvfs
    21092153};
Note: See TracChangeset for help on using the changeset viewer.