[PATCH 1/6] libxfs: provide a kernel-compatible kasprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christoph Hellwig <hch@xxxxxx>

The kernel-like kasprintf will be used by the new metadir code, as well
as the rmap data structures in xfs_repair.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx>
[djwong: tweak commit message]
Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 include/kmem.h |    3 +++
 libxfs/kmem.c  |   13 +++++++++++++
 2 files changed, 16 insertions(+)


diff --git a/include/kmem.h b/include/kmem.h
index 386b4a6be..8dfb2fb0b 100644
--- a/include/kmem.h
+++ b/include/kmem.h
@@ -65,4 +65,7 @@ static inline void kfree(const void *ptr)
 	free((void *)ptr);
 }
 
+__attribute__((format(printf,2,3)))
+char *kasprintf(gfp_t gfp, const char *fmt, ...);
+
 #endif
diff --git a/libxfs/kmem.c b/libxfs/kmem.c
index a2a3935d0..2e2935180 100644
--- a/libxfs/kmem.c
+++ b/libxfs/kmem.c
@@ -104,3 +104,16 @@ krealloc(void *ptr, size_t new_size, int flags)
 	}
 	return ptr;
 }
+
+char *kasprintf(gfp_t gfp, const char *fmt, ...)
+{
+	va_list ap;
+	char *p;
+
+	va_start(ap, fmt);
+	if (vasprintf(&p, fmt, ap) < 0)
+		p = NULL;
+	va_end(ap);
+
+	return p;
+}





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux