cuse_lib.c (d14b53ee31ca06933a4f8ef2e48ce33cf3dd5ec9) | cuse_lib.c (58a8f6e9ecabba975f2cda8416bcc36c2073a7a8) |
---|---|
1/* $FreeBSD$ */ 2/*- 3 * Copyright (c) 2010-2022 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 149 unchanged lines hidden (view full) --- 158 } 159 } 160 CUSE_UNLOCK(); 161 162 return ((n << CUSE_ALLOC_UNIT_SHIFT) + remainder); 163} 164 165void * | 1/* $FreeBSD$ */ 2/*- 3 * Copyright (c) 2010-2022 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 149 unchanged lines hidden (view full) --- 158 } 159 } 160 CUSE_UNLOCK(); 161 162 return ((n << CUSE_ALLOC_UNIT_SHIFT) + remainder); 163} 164 165void * |
166cuse_vmalloc(int size) | 166cuse_vmalloc(unsigned size) |
167{ 168 struct cuse_alloc_info info; 169 unsigned long pgsize; 170 unsigned long x; 171 unsigned long m; 172 unsigned long n; 173 void *ptr; 174 int error; 175 176 /* some sanity checks */ | 167{ 168 struct cuse_alloc_info info; 169 unsigned long pgsize; 170 unsigned long x; 171 unsigned long m; 172 unsigned long n; 173 void *ptr; 174 int error; 175 176 /* some sanity checks */ |
177 if (f_cuse < 0 || size < 1 || (unsigned long)size > CUSE_ALLOC_BYTES_MAX) | 177 if (f_cuse < 0 || size < 1 || size > CUSE_ALLOC_BYTES_MAX) |
178 return (NULL); 179 180 memset(&info, 0, sizeof(info)); 181 182 pgsize = getpagesize(); 183 info.page_count = howmany(size, pgsize); 184 185 /* compute how many units the allocation needs */ --- 610 unchanged lines hidden --- | 178 return (NULL); 179 180 memset(&info, 0, sizeof(info)); 181 182 pgsize = getpagesize(); 183 info.page_count = howmany(size, pgsize); 184 185 /* compute how many units the allocation needs */ --- 610 unchanged lines hidden --- |