- Document layout of KTR_STRUCT payload in a comment.
- Simplify ktrstruct() calling convention by having ktrstruct() use strlen() rather than requiring the caller to hand-code the length of constant strings. MFC after: 1 month
This commit is contained in:
parent
1d73ef9790
commit
a3052d6e08
@ -596,9 +596,8 @@ ktrcsw(out, user)
|
||||
}
|
||||
|
||||
void
|
||||
ktrstruct(name, namelen, data, datalen)
|
||||
ktrstruct(name, data, datalen)
|
||||
const char *name;
|
||||
size_t namelen;
|
||||
void *data;
|
||||
size_t datalen;
|
||||
{
|
||||
@ -608,11 +607,10 @@ ktrstruct(name, namelen, data, datalen)
|
||||
|
||||
if (!data)
|
||||
datalen = 0;
|
||||
buflen = namelen + 1 + datalen;
|
||||
buflen = strlen(name) + 1 + datalen;
|
||||
buf = malloc(buflen, M_KTRACE, M_WAITOK);
|
||||
bcopy(name, buf, namelen);
|
||||
buf[namelen] = '\0';
|
||||
bcopy(data, buf + namelen + 1, datalen);
|
||||
strcpy(buf, name);
|
||||
bcopy(data, buf + strlen(name) + 1, datalen);
|
||||
if ((req = ktr_getrequest(KTR_STRUCT)) == NULL) {
|
||||
free(buf, M_KTRACE);
|
||||
return;
|
||||
|
@ -154,6 +154,10 @@ struct ktr_csw {
|
||||
* KTR_STRUCT - misc. structs
|
||||
*/
|
||||
#define KTR_STRUCT 8
|
||||
/*
|
||||
* record contains null-terminated struct name followed by
|
||||
* struct contents
|
||||
*/
|
||||
struct sockaddr;
|
||||
struct stat;
|
||||
|
||||
@ -202,11 +206,11 @@ void ktrsysctl(int *name, u_int namelen);
|
||||
void ktrsysret(int, int, register_t);
|
||||
void ktrprocexit(struct thread *);
|
||||
void ktruserret(struct thread *);
|
||||
void ktrstruct(const char *, size_t, void *, size_t);
|
||||
void ktrstruct(const char *, void *, size_t);
|
||||
#define ktrsockaddr(s) \
|
||||
ktrstruct("sockaddr", 8, (s), ((struct sockaddr *)(s))->sa_len)
|
||||
ktrstruct("sockaddr", (s), ((struct sockaddr *)(s))->sa_len)
|
||||
#define ktrstat(s) \
|
||||
ktrstruct("stat", 4, (s), sizeof(struct stat))
|
||||
ktrstruct("stat", (s), sizeof(struct stat))
|
||||
|
||||
#else
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user