Exemplo n.º 1
0
static int
xfs_fsal_inode2handle(int fd, ino_t ino, vfs_file_handle_t *fh)
{
	xfs_bstat_t bstat;
	struct xfs_filehandle hdl;
        void *data, *fhdata;
        size_t sz, fhsz;
        int rv;

        if(fh->handle_bytes < sizeof(hdl)) {
                errno = E2BIG;
                return -1;
        }
	if((xfs_fsal_bulkstat_inode(fd, ino, &bstat) < 0) ||
           (fd_to_handle(fd, &data, &sz) < 0))
		return -1;

        if ((rv = handle_to_fshandle(data, sz, &fhdata, &fhsz)) >= 0) {
                memset(&hdl, 0, sizeof(hdl));
                memcpy(&hdl.fh_fshdl, fhdata, fhsz);
                hdl.fh_sz_following = XFS_FILEHANDLE_SZ_FOLLOWING;
                hdl.fh_gen = bstat.bs_gen;
                hdl.fh_ino = bstat.bs_ino;

                memcpy(fh->handle, &hdl, sizeof(hdl));
                fh->handle_bytes = sizeof(hdl);
                free_handle(fhdata, fhsz);
        }

        free_handle(data, sz);
	return rv;
}
Exemplo n.º 2
0
static int xfs_fsal_inode2handle(int fd, ino_t ino, vfs_file_handle_t *fh)
{
	xfs_bstat_t bstat;
	xfs_handle_t *hdl = (xfs_handle_t *) fh->handle_data;
	void *data;
	size_t sz;

	if (fh->handle_len < sizeof(*hdl)) {
		errno = E2BIG;
		return -1;
	}

	/* Get the information pertinent to this inode, and
	 * the file handle for the reference fd.
	 */
	if ((xfs_fsal_bulkstat_inode(fd, ino, &bstat) < 0) ||
	    (fd_to_handle(fd, &data, &sz) < 0))
		return -1;

	/* Copy the fsid from the reference fd */
	memcpy(&hdl->ha_fsid, data, sizeof(xfs_fsid_t));

	/* Fill in the rest of the handle with the information
	 * pertinent to this inode.
	 */
	hdl->ha_fid.fid_len = sizeof(xfs_handle_t) -
			      sizeof(xfs_fsid_t) -
			      sizeof(hdl->ha_fid.fid_len);
	hdl->ha_fid.fid_pad = 0;
	hdl->ha_fid.fid_gen = bstat.bs_gen;
	hdl->ha_fid.fid_ino = bstat.bs_ino;

	fh->handle_len = sizeof(*hdl);

	free_handle(data, sz);
	return 0;
}