--- block.c.orig Mon May 8 18:34:02 2006 +++ block.c Mon May 8 19:07:30 2006 @@ -756,7 +756,8 @@ static int raw_create(const char *filename, int64_t total_size, const char *backing_file, int flags) { - int fd; + int fd, size, i; + unsigned char buf512[512]; if (flags || backing_file) return -ENOTSUP; @@ -767,6 +768,20 @@ return -EIO; ftruncate(fd, total_size * 512); close(fd); + + /* check to see if the filesystem handled sparseness correctly */ + fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE); + if (fd < 0) + return -EIO; // some weird badness happened here + size = lseek(fd, 0LL, SEEK_END); + close(fd); + + if (!size) + { + printf("Error: your filesystem does not appear to support sparse file\n"); + return -EIO; + } + return 0; }