/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#ifdef HAVE_LINUX_MEMFD_H
#endif
#include <stdio.h>
#include "alloc-util.h"
#include "fd-util.h"
#include "macro.h"
#include "memfd-util.h"
#include "missing.h"
#include "string-util.h"
#include "utf8.h"
_cleanup_free_ char *g = NULL;
int fd;
if (!name) {
/* If no name is specified we generate one. We include
* a hint indicating our library implementation, and
* add the thread name to it */
name = "sd";
else {
_cleanup_free_ char *e = NULL;
e = utf8_escape_invalid(pr);
if (!e)
return -ENOMEM;
g = strappend("sd-", e);
if (!g)
return -ENOMEM;
name = g;
}
}
if (fd < 0)
return -errno;
return fd;
}
void *q;
int sealed;
assert(p);
if (sealed < 0)
return sealed;
if (sealed)
else
if (q == MAP_FAILED)
return -errno;
*p = q;
return 0;
}
int r;
if (r < 0)
return -errno;
return 0;
}
int r;
if (r < 0)
return -errno;
}
int r;
if (r < 0)
return -errno;
return 0;
}
int r;
if (r < 0)
return -errno;
return 0;
}
int r;
assert(p);
if (fd < 0)
return fd;
if (r < 0)
return r;
if (r < 0)
return r;
r = fd;
fd = -1;
return r;
}