jail_getid.c (a9cefddd40444c1dc0c7fd69e69a2938f08bf9c6) jail_getid.c (067498ed56f6bcf15757a598db45ef374f6b946a)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2009 James Gritton.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 40 unchanged lines hidden (view full) ---

49jail_getid(const char *name)
50{
51 char *ep;
52 int jid;
53 struct iovec jiov[4];
54
55 jid = strtoul(name, &ep, 10);
56 if (*name && !*ep) {
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2009 James Gritton.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 40 unchanged lines hidden (view full) ---

49jail_getid(const char *name)
50{
51 char *ep;
52 int jid;
53 struct iovec jiov[4];
54
55 jid = strtoul(name, &ep, 10);
56 if (*name && !*ep) {
57 /*
58 * jid == 0 is a special case; it will not appear in the
59 * kernel's jail list, but naturally processes will be assigned
60 * to it because it is prison 0. Trivially return this one
61 * without a trip to the kernel, because it always exists but
62 * the lookup won't succeed.
63 */
64 if (jid == 0)
65 return jid;
57 jiov[0].iov_base = __DECONST(char *, "jid");
58 jiov[0].iov_len = sizeof("jid");
59 jiov[1].iov_base = &jid;
60 jiov[1].iov_len = sizeof(jid);
61 } else {
62 jiov[0].iov_base = __DECONST(char *, "name");
63 jiov[0].iov_len = sizeof("name");
64 jiov[1].iov_len = strlen(name) + 1;

--- 51 unchanged lines hidden ---
66 jiov[0].iov_base = __DECONST(char *, "jid");
67 jiov[0].iov_len = sizeof("jid");
68 jiov[1].iov_base = &jid;
69 jiov[1].iov_len = sizeof(jid);
70 } else {
71 jiov[0].iov_base = __DECONST(char *, "name");
72 jiov[0].iov_len = sizeof("name");
73 jiov[1].iov_len = strlen(name) + 1;

--- 51 unchanged lines hidden ---