Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_stats.c
| Show First 20 Lines • Show All 1,101 Lines • ▼ Show 20 Lines | if (!error) { | ||||
| /* | /* | ||||
| * Clone src into dst except for the maxsz field. If dst is too | * Clone src into dst except for the maxsz field. If dst is too | ||||
| * small to hold all of src, only copy src's header and return | * small to hold all of src, only copy src's header and return | ||||
| * EOVERFLOW. | * EOVERFLOW. | ||||
| */ | */ | ||||
| #ifdef _KERNEL | #ifdef _KERNEL | ||||
| if (flags & SB_CLONE_USRDSTNOFAULT) | if (flags & SB_CLONE_USRDSTNOFAULT) | ||||
| copyout_nofault(src, *dst, | error = copyout_nofault(src, *dst, | ||||
| offsetof(struct statsblob, maxsz)); | offsetof(struct statsblob, maxsz)); | ||||
| else if (flags & SB_CLONE_USRDST) | else if (flags & SB_CLONE_USRDST) | ||||
| copyout(src, *dst, offsetof(struct statsblob, maxsz)); | error = copyout(src, *dst, | ||||
| offsetof(struct statsblob, maxsz)); | |||||
| else | else | ||||
| #endif | #endif | ||||
| memcpy(*dst, src, offsetof(struct statsblob, maxsz)); | memcpy(*dst, src, offsetof(struct statsblob, maxsz)); | ||||
| #ifdef _KERNEL | |||||
| if (error != 0) | |||||
| goto out; | |||||
| #endif | |||||
| if (dstmaxsz >= src->cursz) { | if (dstmaxsz >= src->cursz) { | ||||
| postcurszlen = src->cursz - | postcurszlen = src->cursz - | ||||
| offsetof(struct statsblob, cursz); | offsetof(struct statsblob, cursz); | ||||
| } else { | } else { | ||||
| error = EOVERFLOW; | error = EOVERFLOW; | ||||
| postcurszlen = sizeof(struct statsblob) - | postcurszlen = sizeof(struct statsblob) - | ||||
| offsetof(struct statsblob, cursz); | offsetof(struct statsblob, cursz); | ||||
| } | } | ||||
| #ifdef _KERNEL | #ifdef _KERNEL | ||||
| if (flags & SB_CLONE_USRDSTNOFAULT) | if (flags & SB_CLONE_USRDSTNOFAULT) | ||||
| copyout_nofault(&(src->cursz), &((*dst)->cursz), | error = copyout_nofault(&(src->cursz), &((*dst)->cursz), | ||||
| postcurszlen); | postcurszlen); | ||||
| else if (flags & SB_CLONE_USRDST) | else if (flags & SB_CLONE_USRDST) | ||||
| copyout(&(src->cursz), &((*dst)->cursz), postcurszlen); | error = copyout(&(src->cursz), &((*dst)->cursz), | ||||
| postcurszlen); | |||||
| else | else | ||||
| #endif | #endif | ||||
| memcpy(&((*dst)->cursz), &(src->cursz), postcurszlen); | memcpy(&((*dst)->cursz), &(src->cursz), postcurszlen); | ||||
| } | } | ||||
| #ifdef _KERNEL | |||||
| out: | |||||
| #endif | |||||
| return (error); | return (error); | ||||
| } | } | ||||
| int | int | ||||
| stats_v1_tpl_alloc(const char *name, uint32_t flags __unused) | stats_v1_tpl_alloc(const char *name, uint32_t flags __unused) | ||||
| { | { | ||||
| struct statsblobv1_tpl *tpl, **newtpllist; | struct statsblobv1_tpl *tpl, **newtpllist; | ||||
| ▲ Show 20 Lines • Show All 2,810 Lines • Show Last 20 Lines | |||||