[stgt] [PATCH] usr/tgtimg.c: use `ftruncate` to fix build with uClibc
Paul Menzel
paulepanter at users.sourceforge.net
Sun Jan 16 13:41:31 CET 2011
From: Khem Raj <raj.khem at gmail.com>
Date: Sat Jan 15 16:37:19 2011 -0800
uClibc does not provide `posix_fallocate` so use `ftruncate`.
This patch is taken from OpenEmbedded [1][2] and is build tested with distribution `minimal-uclibc` for `MACHINE = "beagleboard"` with OE revision 7e5ea0e6 [3].
[1] http://www.openembedded.org/
[2] http://cgit.openembedded.org/cgit.cgi/openembedded/commit/?id=992b4de5896e01316d315a7aef57e7c0ed0aca7b
[3] http://cgit.openembedded.org/cgit.cgi/openembedded/tree/?id=7e5ea0e6826d138349c40ff296e5b86cf46fead7
Signed-off-by: Khem Raj <raj.khem at gmail.com>
Signed-off-by: Paul Menzel <paulepanter at users.sourceforge.net>
---
usr/tgtimg.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/usr/tgtimg.c b/usr/tgtimg.c
index 169207a..e527322 100644
--- a/usr/tgtimg.c
+++ b/usr/tgtimg.c
@@ -438,8 +438,13 @@ static int sbc_new(int op, char *path, char *capacity, char *media_type)
perror("Failed creating file");
exit(2);
}
+#ifndef __UCLIBC__
if (posix_fallocate(fd, 0, size*1024*1024LL) == -1) {
perror("posix_fallocate failed.");
+#else
+ if (ftruncate (fd, size*1024*1024LL) == -1) {
+ perror("ftruncate failed.");
+#endif
exit(3);
}
--
1.7.2.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.wpkg.org/pipermail/stgt/attachments/20110116/8ef222c3/attachment.sig>
More information about the stgt
mailing list