Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CROS_DISKS_MOUNT_OPTIONS_H_ |
| 6 | #define CROS_DISKS_MOUNT_OPTIONS_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <utility> |
| 10 | #include <vector> |
| 11 | |
Sergei Datsenko | f5553d1 | 2020-11-25 07:51:59 +1100 | [diff] [blame] | 12 | #include <base/strings/string_piece.h> |
| 13 | |
Sergei Datsenko | e8faba5 | 2020-10-06 21:45:22 +1100 | [diff] [blame] | 14 | #include "cros-disks/platform.h" |
| 15 | |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 16 | namespace cros_disks { |
| 17 | |
Sergei Datsenko | d2b83a1 | 2020-11-18 12:27:41 +1100 | [diff] [blame] | 18 | // Checks if after applying all the "ro and "rw" options |
| 19 | // in order, the resulting mount should be read-only. |
| 20 | bool IsReadOnlyMount(const std::vector<std::string>& options); |
| 21 | |
Sergei Datsenko | f5553d1 | 2020-11-25 07:51:59 +1100 | [diff] [blame] | 22 | // Finds the last value assigned to a parameter named |name|. Returns true if |
| 23 | // found. |
| 24 | bool GetParamValue(const std::vector<std::string>& params, |
| 25 | base::StringPiece name, |
Sergei Datsenko | 1bb0bdc | 2021-02-17 11:26:43 +1100 | [diff] [blame] | 26 | std::string* value) WARN_UNUSED_RESULT; |
Sergei Datsenko | f5553d1 | 2020-11-25 07:51:59 +1100 | [diff] [blame] | 27 | |
| 28 | // Adds a '|name|=|value|' parameter to the container. |
| 29 | void SetParamValue(std::vector<std::string>* params, |
| 30 | base::StringPiece name, |
| 31 | base::StringPiece value); |
| 32 | |
Sergei Datsenko | 7e7c764 | 2021-01-08 19:15:34 +1100 | [diff] [blame] | 33 | // Returns whether params contain the exact param value. |
| 34 | bool HasExactParam(const std::vector<std::string>& params, |
| 35 | base::StringPiece param); |
| 36 | |
| 37 | // Removes all elements equal to the provided and returns the count of |
| 38 | // removed elements. |
| 39 | size_t RemoveParamsEqualTo(std::vector<std::string>* params, |
| 40 | base::StringPiece param); |
| 41 | |
| 42 | // Removes all elements like '|name|=|value|' with the name equal to the |
| 43 | // provided and returns the count of removed elements. |
| 44 | size_t RemoveParamsWithSameName(std::vector<std::string>* params, |
| 45 | base::StringPiece name); |
| 46 | |
Sergei Datsenko | 1bb0bdc | 2021-02-17 11:26:43 +1100 | [diff] [blame] | 47 | // Joins params into a comma separated string. Returns false if comma is |
| 48 | // encountered in an element. |
| 49 | bool JoinParamsIntoOptions(const std::vector<std::string>& params, |
| 50 | std::string* out) WARN_UNUSED_RESULT; |
| 51 | |
Ben Chan | e31d2aa | 2011-06-15 13:52:59 -0700 | [diff] [blame] | 52 | } // namespace cros_disks |
| 53 | |
| 54 | #endif // CROS_DISKS_MOUNT_OPTIONS_H_ |