[PATCH] usr/tgtimg.c: use `ftruncate` to fix build with uClibc

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

 



From: Khem Raj <raj.khem@xxxxxxxxx>
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@xxxxxxxxx>
Signed-off-by: Paul Menzel <paulepanter@xxxxxxxxxxxxxxxxxxxxx>
---
 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

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux