| 697 | |
| 698 | |
| 699 | string getPersistentVolumePath( |
| 700 | const string& workDir, |
| 701 | const string& role, |
| 702 | const string& persistenceId) |
| 703 | { |
| 704 | // Role names might contain literal `/` if the role is part of a |
| 705 | // role hierarchy. Since `/` is not allowed in a directory name |
| 706 | // under Linux, we could either represent such sub-roles with |
| 707 | // sub-directories, or encode the `/` with some other identifier. |
| 708 | // To clearly distinguish artifacts in a volume from subroles we |
| 709 | // choose to encode `/` in role names as ` ` (literal space) as |
| 710 | // opposed to using subdirectories. Whitespace is not allowed as |
| 711 | // part of a role name. Also, practically all modern filesystems can |
| 712 | // use ` ` in filenames. There are some limitations in auxilary |
| 713 | // tooling which are not relevant here, e.g., many shell constructs |
| 714 | // require quotes around filesnames containing ` `; containers using |
| 715 | // persistent volumes would not see the ` ` as the role-related part |
| 716 | // of the path would not be part of a mapping into the container |
| 717 | // sandbox. |
| 718 | string serializableRole = strings::replace(role, "/", " "); |
| 719 | |
| 720 | return path::join( |
| 721 | workDir, "volumes", "roles", serializableRole, persistenceId); |
| 722 | } |
| 723 | |
| 724 | |
| 725 | string getPersistentVolumePath( |