1/*- 2 * Copyright (c) 2002 Poul-Henning Kamp 3 * Copyright (c) 2002 Networks Associates Technology, Inc. 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp 7 * and NAI Labs, the Security Research Division of Network Associates, Inc. 8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the --- 20 unchanged lines hidden (view full) --- 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sys/geom/geom_disk.c 196823 2009-09-04 09:39:06Z pjd $"); |
38 39#include "opt_geom.h" 40 41#include <sys/param.h> 42#include <sys/systm.h> 43#include <sys/kernel.h> 44#include <sys/sysctl.h> 45#include <sys/bio.h> 46#include <sys/conf.h> |
47#include <sys/ctype.h> |
48#include <sys/fcntl.h> 49#include <sys/malloc.h> 50#include <sys/sysctl.h> 51#include <sys/devicestat.h> 52#include <machine/md_var.h> 53 54#include <sys/lock.h> 55#include <sys/mutex.h> --- 340 unchanged lines hidden (view full) --- 396 if (gp != NULL) { 397 gp->softc = NULL; 398 g_wither_geom(gp, ENXIO); 399 } 400 g_free(dp); 401} 402 403/* |
404 * We only allow printable characters in disk ident, 405 * the rest is converted to 'x<HH>'. |
406 */ 407static void 408g_disk_ident_adjust(char *ident, size_t size) 409{ |
410 char *p, tmp[4], newid[DISK_IDENT_SIZE]; |
411 |
412 newid[0] = '\0'; 413 for (p = ident; *p != '\0'; p++) { 414 if (isprint(*p)) { 415 tmp[0] = *p; 416 tmp[1] = '\0'; 417 } else { 418 snprintf(tmp, sizeof(tmp), "x%02hhx", 419 *(unsigned char *)p); |
420 } |
421 if (strlcat(newid, tmp, sizeof(newid)) >= sizeof(newid)) 422 break; |
423 } 424 bzero(ident, size); 425 strlcpy(ident, newid, size); 426} 427 428struct disk * 429disk_alloc() 430{ --- 86 unchanged lines hidden --- |