2 * Copyright (C) 2004 IBM Corporation
4 * Author: Serge Hallyn <serue@us.ibm.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2 of the
12 #include <linux/module.h>
13 #include <linux/uts.h>
14 #include <linux/utsname.h>
15 #include <linux/err.h>
16 #include <linux/slab.h>
18 static struct uts_namespace
*create_uts_ns(void)
20 struct uts_namespace
*uts_ns
;
22 uts_ns
= kmalloc(sizeof(struct uts_namespace
), GFP_KERNEL
);
24 kref_init(&uts_ns
->kref
);
29 * Clone a new ns copying an original utsname, setting refcount to 1
30 * @old_ns: namespace to clone
31 * Return NULL on error (failure to kmalloc), new ns otherwise
33 static struct uts_namespace
*clone_uts_ns(struct uts_namespace
*old_ns
)
35 struct uts_namespace
*ns
;
39 return ERR_PTR(-ENOMEM
);
42 memcpy(&ns
->name
, &old_ns
->name
, sizeof(ns
->name
));
48 * Copy task tsk's utsname namespace, or clone it if flags
49 * specifies CLONE_NEWUTS. In latter case, changes to the
50 * utsname of this process won't be seen by parent, and vice
53 struct uts_namespace
*copy_utsname(unsigned long flags
, struct uts_namespace
*old_ns
)
55 struct uts_namespace
*new_ns
;
60 if (!(flags
& CLONE_NEWUTS
))
63 new_ns
= clone_uts_ns(old_ns
);
69 void free_uts_ns(struct kref
*kref
)
71 struct uts_namespace
*ns
;
73 ns
= container_of(kref
, struct uts_namespace
, kref
);
This page took 0.030996 seconds and 5 git commands to generate.