Skip to contentSkip to conversation

don't use PAGE_SIZE in userspace

PATCH In review Alex Williamson 2 participants 3 messages Dec 20, 2006

lore
Share & tools
lore
#0 lore raw

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
diff -r 381f119b15a0 tools/blktap/drivers/block-qcow.c
@@ -1353,7 +1353,8 @@ int qcow_create(const char *filename, ui
 	free(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;
#1 lore raw
Quoted 13 lines · Alex Williamson

PAGE_SIZE is not a constant on all architectures, getpagesize()
should be used from userspace. Thanks,

Alex

---

diff -r 381f119b15a0 tools/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, ui
 	free(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!

#2 lore raw
Quoted 11 lines · Tony Breeds

Review

Quoted 8 lines · Alex Williamson

PAGE_SIZE is 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
diff -r 381f119b15a0 tools/blktap/drivers/block-qcow.c
@@ -1352,8 +1352,9 @@ int qcow_create(const char *filename, ui
 	printf("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;