• Daniel Lezcano's avatar
    cgroup: make the mount options parsing more accurate · 32a8cf23
    Daniel Lezcano authored
    Current behavior:
    =================
    
    (1) When we mount a cgroup, we can specify the 'all' option which
        means to enable all the cgroup subsystems.  This is the default option
        when no option is specified.
    
    (2) If we want to mount a cgroup with a subset of the supported cgroup
        subsystems, we have to specify a subsystems name list for the mount
        option.
    
    (3) If we specify another option like 'noprefix' or 'release_agent',
        the actual code wants the 'all' or a subsystem name option specified
        also.  Not critical but a bit not friendly as we should assume (1) in
        this case.
    
    (4) Logically, the 'all' option is mutually exclusive with a subsystem
        name, but this is not detected.
    
    In other words:
     succeed : mount -t cgroup -o all,freezer cgroup /cgroup
    	=> is it 'all' or 'freezer' ?
     fails : mount -t cgroup -o noprefix cgroup /cgroup
    	=> succeed if we do '-o noprefix,all'
    
    The following patches consolidate a bit the mount options check.
    
    New behavior:
    =============
    
    (1) untouched
    (2) untouched
    (3) the 'all' option will be by default when specifying other than
        a subsystem name option
    (4) raises an error
    
    In other words:
     fails   : mount -t cgroup -o all,freezer cgroup /cgroup
     succeed : mount -t cgroup -o noprefix cgroup /cgroup
    
    For the sake of lisibility, the if ... then ... else ... if ...
    indentation when parsing the options has been changed to:
    if ... then
    	...
    	continue
    fi
    Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@free.fr>
    Signed-off-by: default avatarSerge E. Hallyn <serge.hallyn@canonical.com>
    Reviewed-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
    Reviewed-by: default avatarPaul Menage <menage@google.com>
    Cc: Eric W. Biederman <ebiederm@xmission.com>
    Cc: Jamal Hadi Salim <hadi@cyberus.ca>
    Cc: Matt Helsley <matthltc@us.ibm.com>
    Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    32a8cf23
cgroup.c 128 KB