@@ -856,9 +856,8 @@ int mount_custom(
856856 return 0 ;
857857}
858858
859- int setup_volatile_state (
859+ static int setup_volatile_state (
860860 const char * directory ,
861- VolatileMode mode ,
862861 bool userns , uid_t uid_shift , uid_t uid_range ,
863862 const char * selinux_apifs_context ) {
864863
@@ -868,11 +867,7 @@ int setup_volatile_state(
868867
869868 assert (directory );
870869
871- if (mode != VOLATILE_STATE )
872- return 0 ;
873-
874- /* --volatile=state means we simply overmount /var
875- with a tmpfs, and the rest read-only. */
870+ /* --volatile=state means we simply overmount /var with a tmpfs, and the rest read-only. */
876871
877872 r = bind_remount_recursive (directory , true, NULL );
878873 if (r < 0 )
@@ -893,9 +888,8 @@ int setup_volatile_state(
893888 return mount_verbose (LOG_ERR , "tmpfs" , p , "tmpfs" , MS_STRICTATIME , options );
894889}
895890
896- int setup_volatile (
891+ static int setup_volatile_yes (
897892 const char * directory ,
898- VolatileMode mode ,
899893 bool userns , uid_t uid_shift , uid_t uid_range ,
900894 const char * selinux_apifs_context ) {
901895
@@ -907,11 +901,8 @@ int setup_volatile(
907901
908902 assert (directory );
909903
910- if (mode != VOLATILE_YES )
911- return 0 ;
912-
913- /* --volatile=yes means we mount a tmpfs to the root dir, and
914- the original /usr to use inside it, and that read-only. */
904+ /* --volatile=yes means we mount a tmpfs to the root dir, and the original /usr to use inside it, and that
905+ read-only. */
915906
916907 if (!mkdtemp (template ))
917908 return log_error_errno (errno , "Failed to create temporary directory: %m" );
@@ -968,6 +959,25 @@ int setup_volatile(
968959 return r ;
969960}
970961
962+ int setup_volatile_mode (
963+ const char * directory ,
964+ VolatileMode mode ,
965+ bool userns , uid_t uid_shift , uid_t uid_range ,
966+ const char * selinux_apifs_context ) {
967+
968+ switch (mode ) {
969+
970+ case VOLATILE_YES :
971+ return setup_volatile_yes (directory , userns , uid_shift , uid_range , selinux_apifs_context );
972+
973+ case VOLATILE_STATE :
974+ return setup_volatile_state (directory , userns , uid_shift , uid_range , selinux_apifs_context );
975+
976+ default :
977+ return 0 ;
978+ }
979+ }
980+
971981/* Expects *pivot_root_new and *pivot_root_old to be initialised to allocated memory or NULL. */
972982int pivot_root_parse (char * * pivot_root_new , char * * pivot_root_old , const char * s ) {
973983 _cleanup_free_ char * root_new = NULL , * root_old = NULL ;
0 commit comments