Commit 3c2e7f8d authored by Geoff Simmons's avatar Geoff Simmons

Use VRT_blob() to implement .id().

parent ff058352
......@@ -713,9 +713,7 @@ vmod_reader_id(VRT_CTX, struct VPFX(file_reader) *rdr)
uint32_t nsecs;
dev_t dev;
ino_t ino;
uintptr_t snap;
struct vrt_blob *blob;
char *data;
unsigned char *data;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
......@@ -730,29 +728,21 @@ vmod_reader_id(VRT_CTX, struct VPFX(file_reader) *rdr)
ino = rdr->info->ino;
AZ(pthread_rwlock_unlock(&rdr->lock));
snap = WS_Snapshot(ctx->ws);
if ((blob = WS_Alloc(ctx->ws, sizeof(*blob))) == NULL) {
VFAIL(ctx, "%s.id(): insufficient workspace for blob structure",
rdr->obj_name);
return NULL;
}
if ((data = WS_Alloc(ctx->ws, sizeof(secs) + sizeof(nsecs)
+ sizeof(dev) + sizeof(ino))) == NULL) {
WS_Reset(ctx->ws, snap);
VFAIL(ctx, "%s.id(): insufficient workspace for blob data",
rdr->obj_name);
return NULL;
}
blob->type = VMOD_FILE_ID_MAGIC;
blob->len = sizeof(secs) + sizeof(nsecs) + sizeof(dev) + sizeof(ino);
blob->blob = data;
memcpy(data, &secs, sizeof(secs));
memcpy(data + sizeof(secs), &nsecs, sizeof(nsecs));
memcpy(data + sizeof(secs) + sizeof(nsecs), &dev, sizeof(dev));
memcpy(data + sizeof(secs) + sizeof(nsecs) + sizeof(dev), &ino,
sizeof(ino));
return (blob);
return VRT_blob(ctx, "VMOD file id()", data, sizeof(secs) +
sizeof(nsecs) + sizeof(dev) + sizeof(ino),
VMOD_FILE_ID_MAGIC);
}
VCL_BLOB
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment