MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sysctl_handle_long

Function sysctl_handle_long

freebsd/kern/kern_sysctl.c:1655–1693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1653 */
1654
1655int
1656sysctl_handle_long(SYSCTL_HANDLER_ARGS)
1657{
1658 int error = 0;
1659 long tmplong;
1660#ifdef SCTL_MASK32
1661 int tmpint;
1662#endif
1663
1664 /*
1665 * Attempt to get a coherent snapshot by making a copy of the data.
1666 */
1667 if (arg1)
1668 tmplong = *(long *)arg1;
1669 else
1670 tmplong = arg2;
1671#ifdef SCTL_MASK32
1672 if (req->flags & SCTL_MASK32) {
1673 tmpint = tmplong;
1674 error = SYSCTL_OUT(req, &tmpint, sizeof(int));
1675 } else
1676#endif
1677 error = SYSCTL_OUT(req, &tmplong, sizeof(long));
1678
1679 if (error || !req->newptr)
1680 return (error);
1681
1682 if (!arg1)
1683 error = EPERM;
1684#ifdef SCTL_MASK32
1685 else if (req->flags & SCTL_MASK32) {
1686 error = SYSCTL_IN(req, &tmpint, sizeof(int));
1687 *(long *)arg1 = (long)tmpint;
1688 }
1689#endif
1690 else
1691 error = SYSCTL_IN(req, arg1, sizeof(long));
1692 return (error);
1693}
1694
1695/*
1696 * Handle a 64 bit int, signed or unsigned.

Calls

no outgoing calls

Tested by

no test coverage detected