summaryrefslogtreecommitdiffstats
path: root/CGroup
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-11-03 19:59:44 +0000
committertv <tv@shackspace.de>2014-11-03 19:59:44 +0000
commit7a9aac48f2fce05bd6fd8daf9cb3a52098a841eb (patch)
tree80d03b045c15567ad0e73cd8a852eadb4dbb3b5b /CGroup
parentd16a7dcba44fe7f506987f46527409504f119d08 (diff)
Reduce redundancy in CGroup documentation.
Diffstat (limited to 'CGroup')
-rw-r--r--CGroup/Types.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/CGroup/Types.hs b/CGroup/Types.hs
index 53ff4fa..98422f3 100644
--- a/CGroup/Types.hs
+++ b/CGroup/Types.hs
@@ -6,9 +6,12 @@
--
module CGroup.Types
- ( CGroup
+ (
+ -- * CGroup
+ CGroup
, cgroup
, cgroupPath
+ -- * Other types
, ProcessID
) where
@@ -16,18 +19,16 @@ import Data.Monoid
import qualified System.FilePath as FP
--- | A 'CGroup' is defined by a mount point and a cgroup name.
---
--- The mount point specifies where the cgroup hierarchy is mounted.
--- The cgroup name is a 'FilePath' relative to the mount point.
+-- | A 'CGroup' is defined by two 'FilePath's, a mount point and a cgroup
+-- name. The mount point specifies where the cgroup hierarchy is mounted.
+-- The cgroup name is a directory, relative to the mount point.
data CGroup = CGroup { mountPoint, cgroupName :: FilePath }
deriving Show
--- | @'cgroup' mountPoint cgroupName@ is a smart constructor for 'CGroup'.
---
--- It will return 'Nothing' if @cgroupName@ could point outside
--- @mountPoint@ in order to prevent directory traversal attacks.
+-- | Smart constructor. Takes a mount point and a cgroup name.
+-- It will return 'Nothing' if the cgroup could point outside the mount point,
+-- i.e. if the cgroup name is an absolute path, or contains @".."@.
cgroup :: FilePath -> FilePath -> Maybe CGroup
cgroup mp0 cgn0
| ".." `elem` parts = Nothing
@@ -41,11 +42,10 @@ cgroup mp0 cgn0
normaliseCGroupName = FP.dropTrailingPathSeparator . FP.normalise
--- | @'cgroupPath' g@ returns the absolute 'FilePath' of cgroup @g@.
+-- | Path of a cgroup's tasks file.
cgroupPath :: CGroup -> FilePath
cgroupPath CGroup { mountPoint = mp, cgroupName = cgn } =
mp <> cgn
--- | A 'ProcessID' defines a task / process.
type ProcessID = Int