devname.c (1a0fda2b547365c9453523592a445dfe21266d4b) | devname.c (9f365aa1d6aab0aca269b54fb5d216ac0e31a06f) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. 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 --- 23 unchanged lines hidden (view full) --- 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> 34__FBSDID("$FreeBSD$"); 35 36#include <sys/types.h> 37#include <sys/sysctl.h> 38 39#include <stdio.h> | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. 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 --- 23 unchanged lines hidden (view full) --- 32#endif /* LIBC_SCCS and not lint */ 33#include <sys/cdefs.h> 34__FBSDID("$FreeBSD$"); 35 36#include <sys/types.h> 37#include <sys/sysctl.h> 38 39#include <stdio.h> |
40#include <stdint.h> |
|
40#include <string.h> 41#include <sys/param.h> 42#include <sys/stat.h> 43 44char * 45devname_r(dev_t dev, mode_t type, char *buf, int len) 46{ 47 int i; --- 7 unchanged lines hidden (view full) --- 55 if (S_ISCHR(type)) { 56 j = len; 57 i = sysctlbyname("kern.devname", buf, &j, &dev, sizeof (dev)); 58 if (i == 0) 59 return (buf); 60 } 61 62 /* Finally just format it */ | 41#include <string.h> 42#include <sys/param.h> 43#include <sys/stat.h> 44 45char * 46devname_r(dev_t dev, mode_t type, char *buf, int len) 47{ 48 int i; --- 7 unchanged lines hidden (view full) --- 56 if (S_ISCHR(type)) { 57 j = len; 58 i = sysctlbyname("kern.devname", buf, &j, &dev, sizeof (dev)); 59 if (i == 0) 60 return (buf); 61 } 62 63 /* Finally just format it */ |
63 snprintf(buf, len, "#%c:%d:0x%x", 64 S_ISCHR(type) ? 'C' : 'B', major(dev), minor(dev)); | 64 snprintf(buf, len, "#%c:%#jx", 65 S_ISCHR(type) ? 'C' : 'B', (uintmax_t)dev); |
65 return (buf); 66} 67 68char * 69devname(dev_t dev, mode_t type) 70{ 71 static char buf[SPECNAMELEN + 1]; 72 73 return (devname_r(dev, type, buf, sizeof(buf))); 74} | 66 return (buf); 67} 68 69char * 70devname(dev_t dev, mode_t type) 71{ 72 static char buf[SPECNAMELEN + 1]; 73 74 return (devname_r(dev, type, buf, sizeof(buf))); 75} |