Serge E. Hallyn | 4865ecf | 2006-10-02 02:18:14 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2004 IBM Corporation |
| 3 | * |
| 4 | * Author: Serge Hallyn <serue@us.ibm.com> |
| 5 | * |
| 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 |
| 9 | * License. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/uts.h> |
| 14 | #include <linux/utsname.h> |
| 15 | #include <linux/version.h> |
| 16 | |
| 17 | /* |
| 18 | * Copy task tsk's utsname namespace, or clone it if flags |
| 19 | * specifies CLONE_NEWUTS. In latter case, changes to the |
| 20 | * utsname of this process won't be seen by parent, and vice |
| 21 | * versa. |
| 22 | */ |
| 23 | int copy_utsname(int flags, struct task_struct *tsk) |
| 24 | { |
| 25 | struct uts_namespace *old_ns = tsk->nsproxy->uts_ns; |
| 26 | int err = 0; |
| 27 | |
| 28 | if (!old_ns) |
| 29 | return 0; |
| 30 | |
| 31 | get_uts_ns(old_ns); |
| 32 | |
| 33 | return err; |
| 34 | } |
| 35 | |
| 36 | void free_uts_ns(struct kref *kref) |
| 37 | { |
| 38 | struct uts_namespace *ns; |
| 39 | |
| 40 | ns = container_of(kref, struct uts_namespace, kref); |
| 41 | kfree(ns); |
| 42 | } |