don't use PAGE_SIZE in userspace
PATCH 1/1 don't use PAGE_SIZE in userspace
PAGE_SIZE is not a constant on all architectures, getpagesize()
should be used from userspace. Thanks,
Alex
---
tools/blktap/drivers/block-qcow.c +2 -1
@@ -1353,7 +1353,8 @@ int qcow_create(const char *filename, uifree (ptr);/*adjust file length to 4 KByte boundary*/ - length =ROUNDUP (header_size + (l1_size *sizeof (uint64_t )),PAGE_SIZE ); + length =ROUNDUP (header_size + (l1_size *sizeof (uint64_t )), +getpagesize ());if (qtruncate (fd, length,0 )!=0 ) {DPRINTF ("ERROR truncating file\n" );return -1 ;
Quoted 13 lines · Alex Williamson
PAGE_SIZEis not a constant on all architectures,getpagesize()
should be used from userspace. Thanks,Alex
Signed-off-by Alex Williamson <[email protected]>---
diff -r
381f119b15a0tools/blktap/drivers/block-qcow.c
tools/blktap/drivers/block-qcow.c int qcow_create(const char *filename, ui · line 1357
Quoted 6 lines
tools/blktap/drivers/block-qcow.c +2
-1@@ -1353,7 +1353,8 @@ int qcow_create(const char *filename, uifree (ptr);/*adjust file length to 4 KByte boundary*/ - length =ROUNDUP (header_size + (l1_size *sizeof (uint64_t )),PAGE_SIZE ); + length =ROUNDUP (header_size + (l1_size *sizeof (uint64_t )), +getpagesize ());
How about updateing the comment above, aswell?
Yours Tony
linux.conf.au http://linux.conf.au/ || http://lca2007.linux.org.au/
Jan 15-20 2007 The Australian Linux Technical Conference!
Quoted 11 lines · Tony Breeds
Review
Quoted 8 lines · Alex Williamson
PAGE_SIZEis not a constant on all architectures,getpagesize()
should be used from userspace. Thanks,(quoted diff) +2
-1/*adjust file length to 4 KByte boundary*/ - length = ROUNDUP(header_size + (l1_size * sizeof(uint64_t)),PAGE_SIZE); + length = ROUNDUP(header_size + (l1_size * sizeof(uint64_t)), + getpagesize());How about updateing the comment above, aswell?
Oops, fixed. Thanks,
Alex
---
tools/blktap/drivers/block-qcow.c +3 -2
@@ -1352,8 +1352,9 @@ int qcow_create(const char *filename, uiprintf ("Created cksum: %d\n" ,exthdr.cksum);free (ptr); -/*adjust file length to 4 KByte boundary*/ - length =ROUNDUP (header_size + (l1_size *sizeof (uint64_t )),PAGE_SIZE ); +/*adjust file length to system page size boundary*/ + length =ROUNDUP (header_size + (l1_size *sizeof (uint64_t )), +getpagesize ());if (qtruncate (fd, length,0 )!=0 ) {DPRINTF ("ERROR truncating file\n" );return -1 ;