Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115583590
D35585.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D35585.diff
View Options
diff --git a/lib/libcuse/cuse_lib.c b/lib/libcuse/cuse_lib.c
--- a/lib/libcuse/cuse_lib.c
+++ b/lib/libcuse/cuse_lib.c
@@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*-
- * Copyright (c) 2010-2012 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2010-2022 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -142,7 +142,7 @@
uint8_t *ptr_max;
uint8_t *ptr = _ptr;
unsigned long remainder;
- int n;
+ unsigned long n;
CUSE_LOCK();
for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) {
@@ -158,9 +158,10 @@
remainder = (ptr - ptr_min);
- remainder -= remainder % PAGE_SIZE;
+ remainder -= remainder %
+ (unsigned long)getpagesize();
- return ((n * PAGE_SIZE * CUSE_ALLOC_PAGES_MAX) + remainder);
+ return ((n * CUSE_ALLOC_BYTES_MAX) + remainder);
}
}
CUSE_UNLOCK();
@@ -172,9 +173,10 @@
cuse_vmalloc(int size)
{
struct cuse_alloc_info info;
+ unsigned long pgsize;
+ unsigned long n;
void *ptr;
int error;
- int n;
if (f_cuse < 0)
return (NULL);
@@ -184,7 +186,8 @@
if (size < 1)
return (NULL);
- info.page_count = howmany(size, PAGE_SIZE);
+ pgsize = getpagesize();
+ info.page_count = howmany(size, pgsize);
CUSE_LOCK();
for (n = 0; n != CUSE_ALLOC_UNIT_MAX; n++) {
@@ -212,10 +215,9 @@
else
break;
}
- ptr = mmap(NULL, info.page_count * PAGE_SIZE,
+ ptr = mmap(NULL, info.page_count * pgsize,
PROT_READ | PROT_WRITE,
- MAP_SHARED, f_cuse, CUSE_ALLOC_PAGES_MAX *
- PAGE_SIZE * n);
+ MAP_SHARED, f_cuse, CUSE_ALLOC_BYTES_MAX * n);
if (ptr == MAP_FAILED) {
diff --git a/sys/fs/cuse/cuse.c b/sys/fs/cuse/cuse.c
--- a/sys/fs/cuse/cuse.c
+++ b/sys/fs/cuse/cuse.c
@@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*-
- * Copyright (c) 2010-2020 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2010-2022 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -64,6 +64,13 @@
#include <fs/cuse/cuse_defs.h>
#include <fs/cuse/cuse_ioctl.h>
+#define CUSE_ALLOC_PAGES_MAX \
+ (CUSE_ALLOC_BYTES_MAX / PAGE_SIZE)
+
+#if (CUSE_ALLOC_PAGES_MAX == 0)
+#error "PAGE_SIZE is too big!"
+#endif
+
static int
cuse_modevent(module_t mod, int type, void *data)
{
diff --git a/sys/fs/cuse/cuse_ioctl.h b/sys/fs/cuse/cuse_ioctl.h
--- a/sys/fs/cuse/cuse_ioctl.h
+++ b/sys/fs/cuse/cuse_ioctl.h
@@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*-
- * Copyright (c) 2014 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2014-2022 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,13 +30,13 @@
#include <sys/ioccom.h>
#include <sys/types.h>
-#define CUSE_BUFFER_MAX PAGE_SIZE
+#define CUSE_BUFFER_MAX (1 << 12) /* bytes */
#define CUSE_DEVICES_MAX 64 /* units */
#define CUSE_BUF_MIN_PTR 0x10000UL
#define CUSE_BUF_MAX_PTR 0x20000UL
#define CUSE_ALLOC_UNIT_MAX 128 /* units */
/* All memory allocations must be less than the following limit */
-#define CUSE_ALLOC_PAGES_MAX (((16UL * 1024UL * 1024UL) + PAGE_SIZE - 1) / PAGE_SIZE)
+#define CUSE_ALLOC_BYTES_MAX (1UL << 24) /* bytes */
struct cuse_dev;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 26, 4:10 PM (12 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17806582
Default Alt Text
D35585.diff (3 KB)
Attached To
Mode
D35585: cuse(3): Remove PAGE_SIZE from libcuse.
Attached
Detach File
Event Timeline
Log In to Comment