PATCH 2/4 - Time virtualization : unshare support
Subsystems (4)
RFC 1/1 PATCH 2/4 - Time virtualization : unshare support
Add time namespace support to unshare, controlled by CLONE_TIME.
include/linux/sched.h +1 -0
@@ -65,6 +65,7 @@ struct bio;#define CLONE_UNTRACED 0x00800000/* set if the tracing process can't force CLONE_PTRACE on this clone */ #define CLONE_CHILD_SETTID 0x01000000/* set the TID in the child */ #define CLONE_STOPPED 0x02000000/* Start in stopped state */ +#define CLONE_TIME 0x04000000/* Make a new time namespace */ /* * List of flags we want to share for kernel threads,
kernel/fork.c +33 -1
@@ -1563,6 +1563,25 @@ static int unshare_semundo(unsigned longreturn 0 ; } +static int unshare_time (unsigned long unshare_flags,struct time_ns **new) +{ +if (unshare_flags &CLONE_TIME ){ + *new =kmalloc (sizeof (struct time_ns ),GFP_KERNEL ); +if (*new ==NULL ) +return -ENOMEM ; +atomic_set (&(*new)->counter,1 ); + (*new)->offset =0 ; + } + +return 0 ; +} + +static void put_time_ns (struct time_ns *time) +{ +if (atomic_sub_and_test (1 , &time->counter)) +kfree (time); +} +/* * unshare allows a process to 'unshare' part of the process * context which was originally shared using clone. copy_*
@@ -1580,6 +1599,7 @@ asmlinkage long sys_unshare(unsigned lonstruct mm_struct *mm, *new_mm =NULL , *active_mm =NULL ;struct files_struct *fd, *new_fd =NULL ;struct sem_undo_list *new_ulist =NULL ; +struct time_ns *time, *new_time =NULL ;check_unshare_flags (&unshare_flags);
@@ -1603,8 +1623,11 @@ asmlinkage long sys_unshare(unsigned lon goto bad_unshare_cleanup_vm;if ((err =unshare_semundo (unshare_flags, &new_ulist))) goto bad_unshare_cleanup_fd; +if ((err =unshare_time (unshare_flags, &new_time))) + goto bad_unshare_cleanup_fd; -if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist) { +if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist || + new_time) {task_lock (current);
@@ -1641,9 +1664,18 @@ asmlinkage long sys_unshare(unsigned lon new_fd = fd; } +if (new_time) { + time = current->time_ns; + current->time_ns = new_time; + new_time = time; + } +task_unlock (current); } +if (new_time) +put_time_ns (new_time); + bad_unshare_cleanup_fd:if (new_fd)put_files_struct (new_fd);
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel