Dean Roehrich a écrit:
Can you give me a patch for the library to convert it from xfs_fid2_t to
dm_fid_t?
Let XFS continue to use xfs_fid2_t.
Ok, that's done. See the attached file.
I found another small error concerning the handle validity checks.
(I guess) In order to be sure the fsid is not null, you test the 32-bits
MSB against 0 and the 32-bits LSB against 0, of the fsid.
if (!handle.ha_fsid.val[0] || !handle.ha_fsid.val[1])
return(DM_HANDLE_BAD);
If my fsid is, by example, "0x00000000000009F4A", it is correct ? But
this test will detect the left part is null and so declares it BAD.
So I changed the test to verify only, the fsid value is not null.
if (! handle.ha_fsid)
return(DM_HANDLE_BAD);
Aurelien
diff -u libdm.orig/dm_handle.c libdm/dm_handle.c
--- libdm.orig/dm_handle.c 2005-05-18 09:54:42.000000000 +0200
+++ libdm/dm_handle.c 2005-05-18 13:00:20.000000000 +0200
@@ -32,8 +32,8 @@
*/
#ifdef linux
-#include <xfs/libxfs.h>
-#include <xfs/handle.h>
+#include <xfs/libxfs.h> /* Do we really need those includes ? */
+#include <xfs/handle.h>
#else
#include <sys/handle.h>
#include <errno.h>
@@ -153,8 +153,8 @@
dm_ino_t *inop,
dm_igen_t *igenp)
{
- xfs_handle_t handle;
- xfs_fid2_t *xfid2;
+ dm_handle_t handle;
+ dm_fid_t *dmfid;
fid_t *fidp;
if (hanp == DM_GLOBAL_HANP && hlen == DM_GLOBAL_HLEN)
@@ -164,7 +164,7 @@
return(DM_HANDLE_BAD);
memcpy(&handle, hanp, hlen);
- if (!handle.ha_fsid.val[0] || !handle.ha_fsid.val[1])
+ if (! handle.ha_fsid)
return(DM_HANDLE_BAD);
if (fsidp)
memcpy(fsidp, &handle.ha_fsid, sizeof(handle.ha_fsid));
@@ -176,18 +176,18 @@
if (fidp->fid_len != (hlen - sizeof(handle.ha_fsid) -
sizeof(fidp->fid_len)))
return(DM_HANDLE_BAD);
#else
- if (handle.ha_fid.fid_len != (hlen - sizeof(handle.ha_fsid) -
sizeof(handle.ha_fid.fid_len)))
+ if (handle.ha_fid.dm_fid_len != (hlen - sizeof(handle.ha_fsid) -
sizeof(handle.ha_fid.dm_fid_len)))
return(DM_HANDLE_BAD);
#endif
- xfid2 = (struct xfs_fid2 *)&handle.ha_fid;
- if (xfid2->fid_len == sizeof *xfid2 - sizeof xfid2->fid_len) {
- if (xfid2->fid_pad)
+ dmfid = (struct dm_fid_t *)&handle.ha_fid;
+ if (dmfid->dm_fid_len == sizeof *dmfid - sizeof dmfid->dm_fid_len) {
+ if (dmfid->dm_fid_pad)
return(DM_HANDLE_BAD);
if (inop)
- *inop = xfid2->fid_ino;
+ *inop = dmfid->dm_fid_ino;
if (igenp)
- *igenp = xfid2->fid_gen;
+ *igenp = dmfid->dm_fid_gen;
} else {
return(DM_HANDLE_BAD);
}
@@ -291,17 +291,17 @@
void **hanpp,
size_t *hlenp)
{
- xfs_fid2_t *xfid2;
+ dm_fid_t *fid;
/* XXX */
- xfs_handle_t handle;
+ dm_handle_t handle;
memcpy(&handle.ha_fsid, fsidp, sizeof(handle.ha_fsid));
- xfid2 = (struct xfs_fid2 *)&handle.ha_fid;
- xfid2->fid_pad = 0;
- xfid2->fid_gen = (__u32)*igenp;
- xfid2->fid_ino = *inop;
- xfid2->fid_len = sizeof(*xfid2) - sizeof(xfid2->fid_len);
- *hlenp = sizeof(*xfid2) + sizeof(handle.ha_fsid);
+ fid = (struct dm_fid *)&handle.ha_fid;
+ fid->dm_fid_pad = 0;
+ fid->dm_fid_gen = (__u32)*igenp;
+ fid->dm_fid_ino = *inop;
+ fid->dm_fid_len = sizeof(*fid) - sizeof(fid->dm_fid_len);
+ *hlenp = sizeof(*fid) + sizeof(handle.ha_fsid);
if ((*hanpp = malloc(*hlenp)) == NULL) {
errno = ENOMEM;
return -1;
|