Displaying 20 results from an estimated 27 matches for "trimr".
Did you mean:
trier
2016 Jun 16
1
[PATCH] mllib: Add isspace, triml, trimr and trim functions.
...* || c = '\v' *)
+
+ let triml ?(test = isspace) str =
+ let i = ref 0 in
+ let n = ref (String.length str) in
+ while !n > 0 && test str.[!i]; do
+ decr n;
+ incr i
+ done;
+ if !i = 0 then str
+ else String.sub str !i !n
+
+ let trimr ?(test = isspace) str =
+ let n = ref (String.length str) in
+ while !n > 0 && test str.[!n-1]; do
+ decr n
+ done;
+ if !n = String.length str then str
+ else String.sub str 0 !n
+
+ (* Note OCaml stdlib has a function with the same name and
+ * di...
2016 Dec 09
0
Re: [PATCH] generator: Share Common_utils code.
...*)
Ditto.
> -let triml ?(test = isspace) str =
> - let i = ref 0 in
> - let n = ref (String.length str) in
> - while !n > 0 && test str.[!i]; do
> - decr n;
> - incr i
> - done;
> - if !i = 0 then str
> - else String.sub str !i !n
> -
> -let trimr ?(test = isspace) str =
> - let n = ref (String.length str) in
> - while !n > 0 && test str.[!n-1]; do
> - decr n
> - done;
> - if !n = String.length str then str
> - else String.sub str 0 !n
> -
> -let trim ?(test = isspace) str =
> - trimr ~test (tri...
2020 Jan 22
3
[PATCH 1/1] sparsify: support LUKS-encrypted partitions
...h. *)
+ else if vfs_type = "crypto_LUKS" then (
+ let out = command "lsblk" ["-n"; "-l"; "-o"; "NAME"; device] in
+ (* Example output: #lsblk -n -l -o NAME /dev/sda5
+ * sda5
+ * lukssda5
+ *)
+ match String.trimr @@ snd @@ String.split "\n" out with
+ | "" -> None
+ | part ->
+ let mnt = Mountable.of_path @@ "/dev/mapper/" ^ part in
+ Some [mnt, Blkid.vfs_type mnt]
+ )
(* A single btrfs device can turn into many volumes. *)
else if vfs_...
2017 Jul 14
0
[PATCH 03/27] daemon: Reimplement ‘file’ API in OCaml.
...(* We need to remove the trailing \n from output of file(1).
+ *
+ * Some upstream versions of file add a space at the end of the
+ * output. This is fixed in the Fedora version, but we might as
+ * well fix it here too. (RHBZ#928995).
+ *)
+ String.trimr out
+ )
+ else (* it's a device *) (
+ let out = command "file" ["-zbsL"; path] in
+ String.trimr out
+ )
diff --git a/daemon/file.mli b/daemon/file.mli
new file mode 100644
index 000000000..bd49bad0b
--- /dev/null
+++ b/daemon/file.mli
@@ -0,0 +1,19 @@
+(* guestfs-...
2020 Jan 21
12
[PATCH 0/1] WIP: Support LUKS-encrypted partitions
The following patch attempts to implement sparsification of
LUKS-encrypted partitions. It uses lsblk to pair the underlying LUKS
block device with its mapped name. Also, --allow-discards was added
by default to luks_open().
There are several potential issues that I can think of:
1) If and entire device is encrypted (not just one of more partitions),
the lsblk trick might not work.
2) The
2020 Jan 21
0
[PATCH 1/1] WIP: sparsify: Support LUKS-encrypted partitions
...h. *)
+ else if vfs_type = "crypto_LUKS" then (
+ let out = command "lsblk" ["-n"; "-l"; "-o"; "NAME"; device] in
+ (* Example output: #lsblk -n -l -o NAME /dev/sda5
+ * sda5
+ * lukssda5
+ *)
+ match String.trimr @@ snd @@ String.split "\n" out with
+ | "" -> None
+ | part -> let mnt = Mountable.of_path @@ "/dev/mapper/" ^ part in
+ Some [mnt, Blkid.vfs_type mnt]
+ )
(* A single btrfs device can turn into many volumes. *)
else if vfs_type = &q...
2020 Jan 22
0
Re: [PATCH 1/1] sparsify: support LUKS-encrypted partitions
...uot;crypto_LUKS" then (
> + let out = command "lsblk" ["-n"; "-l"; "-o"; "NAME"; device] in
> + (* Example output: #lsblk -n -l -o NAME /dev/sda5
> + * sda5
> + * lukssda5
> + *)
> + match String.trimr @@ snd @@ String.split "\n" out with
> + | "" -> None
> + | part ->
> + let mnt = Mountable.of_path @@ "/dev/mapper/" ^ part in
> + Some [mnt, Blkid.vfs_type mnt]
Now Some doesn't line up with let :-/
> { default...
2020 Jan 27
3
[PATCH v2 1/2] mltools, options: support --allow-discards when decrypting LUKS devices
---
mltools/tools_utils-c.c | 8 ++++----
mltools/tools_utils.ml | 6 +++---
mltools/tools_utils.mli | 8 ++++++--
options/decrypt.c | 5 +++--
options/inspect.c | 2 +-
options/options.h | 2 +-
6 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/mltools/tools_utils-c.c b/mltools/tools_utils-c.c
index 6c43b8d..1dcebc4 100644
--- a/mltools/tools_utils-c.c
+++
2016 Dec 08
4
[PATCH] generator: Share Common_utils code.
...| c = '\r' || c = '\t' (* || c = '\v' *)
-
-let triml ?(test = isspace) str =
- let i = ref 0 in
- let n = ref (String.length str) in
- while !n > 0 && test str.[!i]; do
- decr n;
- incr i
- done;
- if !i = 0 then str
- else String.sub str !i !n
-
-let trimr ?(test = isspace) str =
- let n = ref (String.length str) in
- while !n > 0 && test str.[!n-1]; do
- decr n
- done;
- if !n = String.length str then str
- else String.sub str 0 !n
-
-let trim ?(test = isspace) str =
- trimr ~test (triml ~test str)
-
-let rec find s sub =
- let...
2020 Jan 27
0
[PATCH v2 2/2] sparsify: support LUKS-encrypted partitions
...h. *)
+ else if vfs_type = "crypto_LUKS" then (
+ let out = command "lsblk" ["-n"; "-l"; "-o"; "NAME"; device] in
+ (* Example output: #lsblk -n -l -o NAME /dev/sda5
+ * sda5
+ * lukssda5
+ *)
+ match String.trimr @@ snd @@ String.split "\n" out with
+ | "" -> None
+ | part ->
+ let mnt = Mountable.of_path @@ "/dev/mapper/" ^ part in
+ Some [mnt, Blkid.vfs_type mnt]
+ )
(* A single btrfs device can turn into many volumes. *)
else if vfs_ty...
2017 Jul 21
3
[PATCH] common/mlstdutils: Add chomp function to remove \n from end of strings.
...+), 14 deletions(-)
diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml
index 374507662..b731b8fd5 100644
--- a/common/mlstdutils/std_utils.ml
+++ b/common/mlstdutils/std_utils.ml
@@ -229,6 +229,13 @@ module String = struct
let trim ?(test = Char.isspace) str =
trimr ~test (triml ~test str)
+ let chomp str =
+ let n = String.length str in
+ if n > 0 && str.[n-1] = '\n' then
+ String.sub str 0 (n-1)
+ else
+ str
+
let count_chars c str =
let count = ref 0 in
for i = 0 to String.length str -...
2017 Jul 14
0
[PATCH 04/27] daemon: Reimplement ‘vfs_type’ API in OCaml.
...kid"
+ [(* Adding -c option kills all caching, even on RHEL 5. *)
+ "-c"; "/dev/null";
+ "-o"; "value"; "-s"; tag; device] in
+ match r with
+ | 0 -> (* success *)
+ String.trimr out
+
+ | 2 -> (* means tag not found, we return "" *)
+ ""
+
+ | _ ->
+ failwithf "blkid: %s: %s" tag err
diff --git a/daemon/blkid.mli b/daemon/blkid.mli
new file mode 100644
index 000000000..59a86ac2c
--- /dev/null
+++ b/daemon...
2017 Jun 15
0
[PATCH v6 04/41] mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
...4;5;6;7;8]
+ )
+
+ let triml ?(test = Char.isspace) str =
+ let i = ref 0 in
+ let n = ref (String.length str) in
+ while !n > 0 && test str.[!i]; do
+ decr n;
+ incr i
+ done;
+ if !i = 0 then str
+ else String.sub str !i !n
+
+ let trimr ?(test = Char.isspace) str =
+ let n = ref (String.length str) in
+ while !n > 0 && test str.[!n-1]; do
+ decr n
+ done;
+ if !n = String.length str then str
+ else String.sub str 0 !n
+
+ let trim ?(test = Char.isspace) str =
+ trimr ~test (triml...
2017 Jun 03
3
[PATCH 0/3]: daemon: Reimplement ‘file’ API in OCaml.
This patch series is just FYI at the moment. However it
does pass the tests.
The daemon is a self-contained program. We don't need to write it all
in C. Writing parts of it in OCaml would make it simpler and less
error-prone. In particular if the daemon was written in a more sane
programming language then we could move the inspection code to run
entirely inside the appliance, which would
2020 Mar 05
5
[PATCH v2 0/4] daemon: Translate device names if Linux device is unstable (RHBZ#1804207).
v1 was here:
https://www.redhat.com/archives/libguestfs/2020-February/msg00220.html
This patch series is a little bit better. It's still a bit of a hack.
The _real_ fix for this is outlined in the TODO file (see patch 1) but
that requires a lot more work than we could do before 1.42 is
released, unless we delay 1.42 for a lot longer. I'm hoping with this
to have something which works
2017 Jun 03
12
[PATCH v2 00/12] Allow APIs to be implemented in OCaml.
Version 1 was here:
https://www.redhat.com/archives/libguestfs/2017-June/msg00003.html
This patch series reimplements a few more APIs in OCaml, including
some very important core APIs like ?list_filesystems? and ?mount?.
All the tests pass after this.
The selection of APIs that I have moved may look a little random, but
in fact they are all APIs consumed by the inspection code (and some
more
2017 Jun 19
16
[PATCH v7 00/13] Refactor utilities
This is just the utilities part of the patch series from:
https://www.redhat.com/archives/libguestfs/2017-June/msg00103.html
I believe this addresses everything raised in comments on that
patch series.
Rich.
2017 Jun 09
12
[PATCH 00/12] Refactor utility functions.
This turned out to be rather more involved than I thought.
We have lots of utility functions, spread all over the repository,
with not a lot of structure. This moves many of them under common/
and structures them so there are clear dependencies.
This doesn't complete the job by any means. Other items I had on my
to-do list for this change were:
- Split up mllib/common_utils into:
-
2017 Jun 12
32
[PATCH v5 00/32] Refactor utilities, implement some APIs in OCaml.
This is a combination of:
https://www.redhat.com/archives/libguestfs/2017-June/msg00046.html
[PATCH 00/12] Refactor utility functions.
plus:
https://www.redhat.com/archives/libguestfs/2017-June/msg00023.html
[PATCH v3 00/19] Allow APIs to be implemented in OCaml.
with the second patches rebased on top of the utility refactoring, and
some other adjustments and extensions.
This passes
2017 Apr 11
4
v2v: Implement -i vmx to read VMware vmx files directly (RHBZ#1441197).
https://bugzilla.redhat.com/show_bug.cgi?id=1441197