Fix a bug when returning the filehandle in creat() and return the filehandle
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 16 Apr 2013 04:37:03 +0000 (21:37 -0700)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 16 Apr 2013 04:37:03 +0000 (21:37 -0700)
of the object we created and not the filehandle of the parent directory

lib/libnfs.c

index 93cd62902a081d9fb7d3679e0a3c10011d05bdae..d2f60dac7cbc68d716f23212a8487f90ea07ab17 100644 (file)
@@ -1675,10 +1675,10 @@ static void nfs_create_2_cb(struct rpc_context *rpc, int status, void *command_d
        }
        memset(nfsfh, 0, sizeof(struct nfsfh));
 
-       /* steal the filehandle */
-       nfsfh->fh.data.data_len = data->fh.data.data_len;
-       nfsfh->fh.data.data_val = data->fh.data.data_val;
-       data->fh.data.data_val = NULL;
+       /* copy the filehandle */
+       nfsfh->fh.data.data_len = res->LOOKUP3res_u.resok.object.data.data_len;
+       nfsfh->fh.data.data_val = malloc(nfsfh->fh.data.data_len);
+       memcpy(nfsfh->fh.data.data_val, res->LOOKUP3res_u.resok.object.data.data_val, nfsfh->fh.data.data_len);
 
        data->cb(0, nfs, nfsfh, data->private_data);
        free_nfs_cb_data(data);