* need to lock the in-memory container. If loading the container's
* config file, take the disk lock.
*/
- if (strcmp(fname, c->configfile) == 0)
+ if (strequal(fname, c->configfile))
need_disklock = true;
if (need_disklock)
return false;
while ((direntp = readdir(dir))) {
- if (strcmp(direntp->d_name, ".") == 0)
+ if (strequal(direntp->d_name, "."))
continue;
- if (strcmp(direntp->d_name, "..") == 0)
+ if (strequal(direntp->d_name, ".."))
continue;
count++;
SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing...");
}
- if (strcmp(bdev->type, "dir") != 0 && strcmp(bdev->type, "btrfs") != 0) {
+ if (!strequal(bdev->type, "dir") && !strequal(bdev->type, "btrfs")) {
if (euid != 0) {
ERROR("Unprivileged users can only create "
"btrfs and directory-backed containers");
_exit(EXIT_FAILURE);
}
- if (strcmp(bdev->type, "overlay") == 0 ||
- strcmp(bdev->type, "overlayfs") == 0) {
+ if (strequal(bdev->type, "overlay") ||
+ strequal(bdev->type, "overlayfs")) {
/* If we create an overlay container we need to
* rsync the contents into
* <container-path>/<container-name>/rootfs.
static void do_clear_unexp_config_line(struct lxc_conf *conf, const char *key)
{
- if (!strcmp(key, "lxc.cgroup"))
+ if (strequal(key, "lxc.cgroup"))
return clear_unexp_config_line(conf, key, true);
- if (!strcmp(key, "lxc.network"))
+ if (strequal(key, "lxc.network"))
return clear_unexp_config_line(conf, key, true);
- if (!strcmp(key, "lxc.net"))
+ if (strequal(key, "lxc.net"))
return clear_unexp_config_line(conf, key, true);
/* Clear a network with a specific index. */
return clear_unexp_config_line(conf, key, true);
}
- if (!strcmp(key, "lxc.hook"))
+ if (strequal(key, "lxc.hook"))
return clear_unexp_config_line(conf, key, true);
return clear_unexp_config_line(conf, key, false);
#pragma GCC diagnostic ignored "-Wcast-align"
if (ifa->ifa_addr->sa_family == AF_INET) {
- if (family && strcmp(family, "inet"))
+ if (family && !strequal(family, "inet"))
continue;
address_ptr_tmp = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
} else {
- if (family && strcmp(family, "inet6"))
+ if (family && !strequal(family, "inet6"))
continue;
if (((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id != scope)
#pragma GCC diagnostic pop
- if (interface && strcmp(interface, ifa->ifa_name))
+ if (interface && !strequal(interface, ifa->ifa_name))
continue;
- else if (!interface && strcmp("lo", ifa->ifa_name) == 0)
+ else if (!interface && strequal("lo", ifa->ifa_name))
continue;
address_ptr = (char *)inet_ntop(ifa->ifa_addr->sa_family, address_ptr_tmp,
* Otherwise just take the memlock to protect the struct lxc_container
* while we're traversing it.
*/
- if (strcmp(c->configfile, alt_file) == 0)
+ if (strequal(c->configfile, alt_file))
need_disklock = true;
if (need_disklock)
return false;
while ((direntp = readdir(dir))) {
- if (!strcmp(direntp->d_name, "."))
+ if (strequal(direntp->d_name, "."))
continue;
- if (!strcmp(direntp->d_name, ".."))
+ if (strequal(direntp->d_name, ".."))
continue;
count++;
break;
/* For an overlay container the rootfs is considered immutable and
* cannot be removed when restoring from a snapshot.
*/
- if (storage && (!strcmp(storage->type, "overlay") ||
- !strcmp(storage->type, "overlayfs")) &&
+ if (storage && (strequal(storage->type, "overlay") ||
+ strequal(storage->type, "overlayfs")) &&
(storage->flags & LXC_STORAGE_INTERNAL_OVERLAY_RESTORE)) {
ret = strnprintf(path, len, "%s/%s/%s", p1, c->name, LXC_CONFIG_FNAME);
if (ret < 0)
if (!bdev)
return -1;
- if (strcmp(bdev->type, "dir") != 0) {
+ if (!strequal(bdev->type, "dir")) {
if (unshare(CLONE_NEWNS) < 0) {
ERROR("error unsharing mounts");
storage_put(bdev);
}
while ((direntp = readdir(dir))) {
- if (!strcmp(direntp->d_name, "."))
+ if (strequal(direntp->d_name, "."))
continue;
- if (!strcmp(direntp->d_name, ".."))
+ if (strequal(direntp->d_name, ".."))
continue;
ret = strnprintf(path2, sizeof(path2), "%s/%s/%s", snappath, direntp->d_name, LXC_CONFIG_FNAME);
* internal flag along to communicate this to various parts of the
* codebase.
*/
- if (!strcmp(bdev->type, "overlay") || !strcmp(bdev->type, "overlayfs"))
+ if (strequal(bdev->type, "overlay") || strequal(bdev->type, "overlayfs"))
bdev->flags |= LXC_STORAGE_INTERNAL_OVERLAY_RESTORE;
if (!newname)
return false;
}
- if (!strcmp(c->name, newname)) {
+ if (strequal(c->name, newname)) {
if (!container_destroy(c, bdev)) {
ERROR("Could not destroy existing container %s", newname);
lxc_container_put(snap);
}
}
- if (strcmp(bdev->type, "dir") != 0 && strcmp(bdev->type, "loop") != 0)
+ if (!strequal(bdev->type, "dir") && !strequal(bdev->type, "loop"))
flags = LXC_CLONE_SNAPSHOT | LXC_CLONE_MAYBE_SNAPSHOT;
- if (!strcmp(bdev->type, "overlay") || !strcmp(bdev->type, "overlayfs"))
+ if (strequal(bdev->type, "overlay") || strequal(bdev->type, "overlayfs"))
flags |= LXC_STORAGE_INTERNAL_OVERLAY_RESTORE;
rest = lxcapi_clone(snap, newname, c->config_path, flags, bdev->type,
}
while ((direntp = readdir(dir))) {
- if (!strcmp(direntp->d_name, "."))
+ if (strequal(direntp->d_name, "."))
continue;
- if (!strcmp(direntp->d_name, ".."))
+ if (strequal(direntp->d_name, ".."))
continue;
if (!do_snapshot_destroy(direntp->d_name, path)) {
}
/* Create a temporary file / dir under the shared mountpoint */
- if (!source || strcmp(source, "") == 0) {
+ if (!source || strequal(source, "")) {
/* If source is not specified, maybe we want to mount a filesystem? */
sb.st_mode = S_IFDIR;
} else {
return true;
for (size_t i = 0; i < nr_api_extensions; i++)
- if (strcmp(api_extensions[i], extension) == 0)
+ if (strequal(api_extensions[i], extension))
return true;
return false;