mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-07 11:39:04 +00:00
tree-wide: fix list_entry()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
1f7dd3d5a0
commit
d696c45e73
@ -3569,7 +3569,7 @@ int lxc_map_ids(struct list_head *idmap, pid_t pid)
|
|||||||
/* Check if we really need to use newuidmap and newgidmap.
|
/* Check if we really need to use newuidmap and newgidmap.
|
||||||
* If the user is only remapping their own {g,u}id, we don't need it.
|
* If the user is only remapping their own {g,u}id, we don't need it.
|
||||||
*/
|
*/
|
||||||
if (use_shadow && list_len(idmap) == 2) {
|
if (use_shadow && list_len(map, idmap, head) == 2) {
|
||||||
use_shadow = false;
|
use_shadow = false;
|
||||||
list_for_each_entry(map, idmap, head) {
|
list_for_each_entry(map, idmap, head) {
|
||||||
if (map->idtype == ID_TYPE_UID && map->range == 1 &&
|
if (map->idtype == ID_TYPE_UID && map->range == 1 &&
|
||||||
|
@ -4029,7 +4029,7 @@ static int get_config_idmaps(const char *key, char *retv, int inlen,
|
|||||||
else
|
else
|
||||||
memset(retv, 0, inlen);
|
memset(retv, 0, inlen);
|
||||||
|
|
||||||
listlen = list_len(&c->id_map);
|
listlen = list_len(map, &c->id_map, head);
|
||||||
list_for_each_entry(map, &c->id_map, head) {
|
list_for_each_entry(map, &c->id_map, head) {
|
||||||
ret = strnprintf(buf, sizeof(buf), "%c %lu %lu %lu",
|
ret = strnprintf(buf, sizeof(buf), "%c %lu %lu %lu",
|
||||||
(map->idtype == ID_TYPE_UID) ? 'u' : 'g',
|
(map->idtype == ID_TYPE_UID) ? 'u' : 'g',
|
||||||
@ -6293,7 +6293,7 @@ static int get_config_net_ipv4_address(const char *key, char *retv, int inlen,
|
|||||||
else
|
else
|
||||||
memset(retv, 0, inlen);
|
memset(retv, 0, inlen);
|
||||||
|
|
||||||
listlen = list_len(&netdev->ipv4_addresses);
|
listlen = list_len(inetdev, &netdev->ipv4_addresses, head);
|
||||||
|
|
||||||
list_for_each_entry(inetdev, &netdev->ipv4_addresses, head) {
|
list_for_each_entry(inetdev, &netdev->ipv4_addresses, head) {
|
||||||
if (!inet_ntop(AF_INET, &inetdev->addr, buf, sizeof(buf)))
|
if (!inet_ntop(AF_INET, &inetdev->addr, buf, sizeof(buf)))
|
||||||
@ -6326,7 +6326,7 @@ static int get_config_net_veth_ipv4_route(const char *key, char *retv, int inlen
|
|||||||
else
|
else
|
||||||
memset(retv, 0, inlen);
|
memset(retv, 0, inlen);
|
||||||
|
|
||||||
listlen = list_len(&netdev->priv.veth_attr.ipv4_routes);
|
listlen = list_len(inetdev, &netdev->priv.veth_attr.ipv4_routes, head);
|
||||||
list_for_each_entry(inetdev, &netdev->priv.veth_attr.ipv4_routes, head) {
|
list_for_each_entry(inetdev, &netdev->priv.veth_attr.ipv4_routes, head) {
|
||||||
if (!inet_ntop(AF_INET, &inetdev->addr, buf, sizeof(buf)))
|
if (!inet_ntop(AF_INET, &inetdev->addr, buf, sizeof(buf)))
|
||||||
return -errno;
|
return -errno;
|
||||||
@ -6384,7 +6384,7 @@ static int get_config_net_ipv6_address(const char *key, char *retv, int inlen,
|
|||||||
else
|
else
|
||||||
memset(retv, 0, inlen);
|
memset(retv, 0, inlen);
|
||||||
|
|
||||||
listlen = list_len(&netdev->ipv6_addresses);
|
listlen = list_len(inet6dev, &netdev->ipv6_addresses, head);
|
||||||
list_for_each_entry(inet6dev, &netdev->ipv6_addresses, head) {
|
list_for_each_entry(inet6dev, &netdev->ipv6_addresses, head) {
|
||||||
if (!inet_ntop(AF_INET6, &inet6dev->addr, buf, sizeof(buf)))
|
if (!inet_ntop(AF_INET6, &inet6dev->addr, buf, sizeof(buf)))
|
||||||
return -errno;
|
return -errno;
|
||||||
@ -6416,7 +6416,7 @@ static int get_config_net_veth_ipv6_route(const char *key, char *retv, int inlen
|
|||||||
else
|
else
|
||||||
memset(retv, 0, inlen);
|
memset(retv, 0, inlen);
|
||||||
|
|
||||||
listlen = list_len(&netdev->priv.veth_attr.ipv6_routes);
|
listlen = list_len(inet6dev, &netdev->priv.veth_attr.ipv6_routes, head);
|
||||||
list_for_each_entry(inet6dev, &netdev->priv.veth_attr.ipv6_routes, head) {
|
list_for_each_entry(inet6dev, &netdev->priv.veth_attr.ipv6_routes, head) {
|
||||||
if (!inet_ntop(AF_INET6, &inet6dev->addr, buf, sizeof(buf)))
|
if (!inet_ntop(AF_INET6, &inet6dev->addr, buf, sizeof(buf)))
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -169,6 +169,8 @@ static int exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
|||||||
int static_args = 23, ret;
|
int static_args = 23, ret;
|
||||||
int netnr = 0;
|
int netnr = 0;
|
||||||
struct mntent mntent;
|
struct mntent mntent;
|
||||||
|
struct lxc_netdev *netdev;
|
||||||
|
struct string_entry *strentry;
|
||||||
|
|
||||||
char buf[4096], ttys[32];
|
char buf[4096], ttys[32];
|
||||||
|
|
||||||
@ -232,7 +234,7 @@ static int exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
|||||||
if (ttys[0])
|
if (ttys[0])
|
||||||
static_args += 2;
|
static_args += 2;
|
||||||
|
|
||||||
static_args += list_len(&opts->c->lxc_conf->netdevs) * 2;
|
static_args += list_len(netdev, &opts->c->lxc_conf->netdevs, head) * 2;
|
||||||
} else {
|
} else {
|
||||||
return log_error_errno(-EINVAL, EINVAL, "Invalid criu operation specified");
|
return log_error_errno(-EINVAL, EINVAL, "Invalid criu operation specified");
|
||||||
}
|
}
|
||||||
@ -246,7 +248,7 @@ static int exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
|||||||
if (opts->user->action_script)
|
if (opts->user->action_script)
|
||||||
static_args += 2;
|
static_args += 2;
|
||||||
|
|
||||||
static_args += 2 * list_len(&opts->c->lxc_conf->mount_entries);
|
static_args += 2 * list_len(strentry, &opts->c->lxc_conf->mount_entries, head);
|
||||||
|
|
||||||
ret = strnprintf(log, sizeof(log), "%s/%s.log", opts->user->directory, opts->action);
|
ret = strnprintf(log, sizeof(log), "%s/%s.log", opts->user->directory, opts->action);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -453,7 +455,6 @@ static int exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
|
|||||||
DECLARE_ARG("--leave-running");
|
DECLARE_ARG("--leave-running");
|
||||||
} else if (strequal(opts->action, "restore")) {
|
} else if (strequal(opts->action, "restore")) {
|
||||||
struct lxc_conf *lxc_conf = opts->c->lxc_conf;
|
struct lxc_conf *lxc_conf = opts->c->lxc_conf;
|
||||||
struct lxc_netdev *netdev;
|
|
||||||
|
|
||||||
DECLARE_ARG("--root");
|
DECLARE_ARG("--root");
|
||||||
DECLARE_ARG(opts->c->lxc_conf->rootfs.mount);
|
DECLARE_ARG(opts->c->lxc_conf->rootfs.mount);
|
||||||
|
@ -961,15 +961,15 @@ static inline void hlist_move_list(struct hlist_head *old,
|
|||||||
pos && ({ n = pos->member.next; 1; }); \
|
pos && ({ n = pos->member.next; 1; }); \
|
||||||
pos = hlist_entry_safe(n, typeof(*pos), member))
|
pos = hlist_entry_safe(n, typeof(*pos), member))
|
||||||
|
|
||||||
static inline size_t list_len(struct list_head *list)
|
#define list_len(pos, head, member) \
|
||||||
{
|
({ \
|
||||||
size_t i = 0;
|
size_t __list_len__ = 0; \
|
||||||
|
\
|
||||||
list_for_each(list, list) {
|
list_for_each_entry(pos, head, member) { \
|
||||||
i++;
|
(__list_len__)++; \
|
||||||
}
|
} \
|
||||||
|
\
|
||||||
return i;
|
__list_len__; \
|
||||||
}
|
})
|
||||||
|
|
||||||
#endif /* __LXC_HLIST_H */
|
#endif /* __LXC_HLIST_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user