blob: 4e7a65b75a0513bc6cbed5f9feed52f780f95bf4 [file] [log] [blame]
Ben Chane31d2aa2011-06-15 13:52:59 -07001// 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 Datsenkof5553d12020-11-25 07:51:59 +110012#include <base/strings/string_piece.h>
13
Sergei Datsenkoe8faba52020-10-06 21:45:22 +110014#include "cros-disks/platform.h"
15
Ben Chane31d2aa2011-06-15 13:52:59 -070016namespace cros_disks {
17
Sergei Datsenkod2b83a12020-11-18 12:27:41 +110018// Checks if after applying all the "ro and "rw" options
19// in order, the resulting mount should be read-only.
20bool IsReadOnlyMount(const std::vector<std::string>& options);
21
Sergei Datsenkof5553d12020-11-25 07:51:59 +110022// Finds the last value assigned to a parameter named |name|. Returns true if
23// found.
24bool GetParamValue(const std::vector<std::string>& params,
25 base::StringPiece name,
Sergei Datsenko1bb0bdc2021-02-17 11:26:43 +110026 std::string* value) WARN_UNUSED_RESULT;
Sergei Datsenkof5553d12020-11-25 07:51:59 +110027
28// Adds a '|name|=|value|' parameter to the container.
29void SetParamValue(std::vector<std::string>* params,
30 base::StringPiece name,
31 base::StringPiece value);
32
Sergei Datsenko7e7c7642021-01-08 19:15:34 +110033// Returns whether params contain the exact param value.
34bool 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.
39size_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.
44size_t RemoveParamsWithSameName(std::vector<std::string>* params,
45 base::StringPiece name);
46
Sergei Datsenko1bb0bdc2021-02-17 11:26:43 +110047// Joins params into a comma separated string. Returns false if comma is
48// encountered in an element.
49bool JoinParamsIntoOptions(const std::vector<std::string>& params,
50 std::string* out) WARN_UNUSED_RESULT;
51
Ben Chane31d2aa2011-06-15 13:52:59 -070052} // namespace cros_disks
53
54#endif // CROS_DISKS_MOUNT_OPTIONS_H_