From: Jim Meyering <meyering(a)redhat.com>
* src/generator.ml: Update all rules to handle Dev_or_Path.
(the above changes to generator.ml are mostly mechanical)
Emit a use of REQUIRE_ROOT_OR_RESOLVE_DEVICE.
* daemon/upload.c (do_download): Remove use of
REQUIRE_ROOT_OR_RESOLVE_DEVICE, now that it's automatically done
in calling code.
* daemon/file.c (do_file): Likewise.
---
daemon/file.c | 2 -
daemon/upload.c | 2 -
src/generator.ml | 66 ++++++++++++++++++++++++++++-------------------------
3 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/daemon/file.c b/daemon/file.c
index ed3221d..212aff2 100644
--- a/daemon/file.c
+++ b/daemon/file.c
@@ -361,8 +361,6 @@ do_file (const char *path)
char *buf;
int len;
- REQUIRE_ROOT_OR_RESOLVE_DEVICE (path, return NULL);
-
if (strncmp (path, "/dev/", 5) == 0)
buf = (char *) path;
else {
diff --git a/daemon/upload.c b/daemon/upload.c
index aede24a..143fa82 100644
--- a/daemon/upload.c
+++ b/daemon/upload.c
@@ -93,8 +93,6 @@ do_download (const char *filename)
int fd, r, is_dev;
char buf[GUESTFS_MAX_CHUNK_SIZE];
- REQUIRE_ROOT_OR_RESOLVE_DEVICE (filename, return -1);
-
is_dev = strncmp (filename, "/dev/", 5) == 0;
if (!is_dev) CHROOT_IN;
diff --git a/src/generator.ml b/src/generator.ml
index 072b9f4..70ccbef 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -3738,7 +3738,7 @@ let mapi f xs =
loop 0 xs
let name_of_argt = function
- | Pathname n | Device n | String n | OptString n | StringList n | Bool n | Int n
+ | Pathname n | Device n | Dev_or_Path n | String n | OptString n | StringList n | Bool
n | Int n
| FileIn n | FileOut n -> n
let java_name_of_struct typ =
@@ -4125,7 +4125,7 @@ and generate_xdr () =
pr "struct %s_args {\n" name;
List.iter (
function
- | Pathname n | Device n | String n -> pr " string
%s<>;\n" n
+ | Pathname n | Device n | Dev_or_Path n | String n -> pr " string
%s<>;\n" n
| OptString n -> pr " str *%s;\n" n
| StringList n -> pr " str %s<>;\n" n
| Bool n -> pr " bool %s;\n" n
@@ -4486,7 +4486,7 @@ check_state (guestfs_h *g, const char *caller)
| args ->
List.iter (
function
- | Pathname n | Device n | String n ->
+ | Pathname n | Device n | Dev_or_Path n | String n ->
pr " args.%s = (char *) %s;\n" n n
| OptString n ->
pr " args.%s = %s ? (char **) &%s : NULL;\n" n n n
@@ -4691,7 +4691,7 @@ and generate_daemon_actions () =
pr " struct guestfs_%s_args args;\n" name;
List.iter (
function
- | Device n
+ | Device n | Dev_or_Path n
| Pathname n
| String n -> ()
| OptString n -> pr " char *%s;\n" n
@@ -4720,6 +4720,9 @@ and generate_daemon_actions () =
| Device n ->
pr " char *%s = args.%s;\n" n n;
pr " RESOLVE_DEVICE (%s, goto done);" n;
+ | Dev_or_Path n ->
+ pr " char *%s = args.%s;\n" n n;
+ pr " REQUIRE_ROOT_OR_RESOLVE_DEVICE (%s, goto done);" n;
| String n -> pr " char *%s = args.%s;\n" n n
| OptString n -> pr " %s = args.%s ? *args.%s : NULL;\n" n n
n
| StringList n ->
@@ -5633,6 +5636,7 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
| OptString n, "NULL" -> ()
| Pathname n, arg
| Device n, arg
+ | Dev_or_Path n, arg
| String n, arg
| OptString n, arg ->
pr " const char *%s = \"%s\";\n" n (c_quote arg);
@@ -5681,7 +5685,7 @@ and generate_test_command_call ?(expect_error = false) ?test
test_name cmd =
function
| OptString _, "NULL" -> pr ", NULL"
| Pathname n, _
- | Device n, _
+ | Device n, _ | Dev_or_Path n, _
| String n, _
| OptString n, _ ->
pr ", %s" n
@@ -5931,7 +5935,7 @@ and generate_fish_cmds () =
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n
| FileIn n
@@ -5953,7 +5957,7 @@ and generate_fish_cmds () =
fun i ->
function
| Pathname name
- | Device name | String name -> pr " %s = argv[%d];\n" name i
+ | Device name | Dev_or_Path name | String name -> pr " %s =
argv[%d];\n" name i
| OptString name ->
pr " %s = strcmp (argv[%d], \"\") != 0 ? argv[%d] :
NULL;\n"
name i i
@@ -6186,7 +6190,7 @@ and generate_fish_actions_pod () =
pr " %s" name;
List.iter (
function
- | Pathname n | Device n | String n -> pr " %s" n
+ | Pathname n | Device n | Dev_or_Path n | String n -> pr " %s" n
| OptString n -> pr " %s" n
| StringList n -> pr " '%s ...'" n
| Bool _ -> pr " true|false"
@@ -6253,7 +6257,7 @@ and generate_prototype ?(extern = true) ?(static = false)
?(semicolon = true)
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n ->
next ();
@@ -6516,7 +6520,7 @@ copy_table (char * const * argv)
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| FileIn n
| FileOut n ->
@@ -6569,7 +6573,7 @@ copy_table (char * const * argv)
function
| StringList n ->
pr " ocaml_guestfs_free_strings (%s);\n" n;
- | Pathname _ | Device _ | String _ | OptString _ | Bool _ | Int _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ | OptString _ | Bool _ | Int
_
| FileIn _ | FileOut _ -> ()
) (snd style);
@@ -6653,7 +6657,7 @@ and generate_ocaml_prototype ?(is_external = false) name style =
pr "%s : t -> " name;
List.iter (
function
- | Pathname _ | Device _ | String _ | FileIn _ | FileOut _ -> pr "string ->
"
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ | FileIn _ | FileOut _ -> pr
"string -> "
| OptString _ -> pr "string option -> "
| StringList _ -> pr "string array -> "
| Bool _ -> pr "bool -> "
@@ -6798,7 +6802,7 @@ DESTROY (g)
iteri (
fun i ->
function
- | Pathname n | Device n | String n | FileIn n | FileOut n ->
+ | Pathname n | Device n | Dev_or_Path n | String n | FileIn n | FileOut n
->
pr " char *%s;\n" n
| OptString n ->
(*
http://www.perlmonks.org/?node_id=554277
@@ -6814,7 +6818,7 @@ DESTROY (g)
let do_cleanups () =
List.iter (
function
- | Pathname _ | Device _ | String _ | OptString _ | Bool _ | Int _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ | OptString _ | Bool _ | Int
_
| FileIn _ | FileOut _ -> ()
| StringList n -> pr " free (%s);\n" n
) (snd style)
@@ -7186,7 +7190,7 @@ and generate_perl_prototype name style =
if !comma then pr ", ";
comma := true;
match arg with
- | Pathname n | Device n | String n
+ | Pathname n | Device n | Dev_or_Path n | String n
| OptString n | Bool n | Int n | FileIn n | FileOut n ->
pr "$%s" n
| StringList n ->
@@ -7434,7 +7438,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
List.iter (
function
- | Pathname n | Device n | String n | FileIn n | FileOut n ->
+ | Pathname n | Device n | Dev_or_Path n | String n | FileIn n | FileOut n ->
pr " const char *%s;\n" n
| OptString n -> pr " const char *%s;\n" n
| StringList n ->
@@ -7450,7 +7454,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " if (!PyArg_ParseTuple (args, (char *) \"O";
List.iter (
function
- | Pathname _ | Device _ | String _ | FileIn _ | FileOut _ -> pr "s"
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ | FileIn _ | FileOut _ ->
pr "s"
| OptString _ -> pr "z"
| StringList _ -> pr "O"
| Bool _ -> pr "i" (* XXX Python has booleans? *)
@@ -7460,7 +7464,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " &py_g";
List.iter (
function
- | Pathname n | Device n | String n | FileIn n | FileOut n -> pr ",
&%s" n
+ | Pathname n | Device n | Dev_or_Path n | String n | FileIn n | FileOut n ->
pr ", &%s" n
| OptString n -> pr ", &%s" n
| StringList n -> pr ", &py_%s" n
| Bool n -> pr ", &%s" n
@@ -7473,7 +7477,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
pr " g = get_handle (py_g);\n";
List.iter (
function
- | Pathname _ | Device _ | String _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " %s = get_string_list (py_%s);\n" n n;
@@ -7488,7 +7492,7 @@ py_guestfs_close (PyObject *self, PyObject *args)
List.iter (
function
- | Pathname _ | Device _ | String _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " free (%s);\n" n
@@ -7797,7 +7801,7 @@ static VALUE ruby_guestfs_close (VALUE gv)
List.iter (
function
- | Pathname n | Device n | String n | FileIn n | FileOut n ->
+ | Pathname n | Device n | Dev_or_Path n | String n | FileIn n | FileOut n ->
pr " Check_Type (%sv, T_STRING);\n" n;
pr " const char *%s = StringValueCStr (%sv);\n" n n;
pr " if (!%s)\n" n;
@@ -7849,7 +7853,7 @@ static VALUE ruby_guestfs_close (VALUE gv)
List.iter (
function
- | Pathname _ | Device _ | String _
+ | Pathname _ | Device _ | Dev_or_Path _ | String _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ -> ()
| StringList n ->
pr " free (%s);\n" n
@@ -8161,7 +8165,7 @@ and generate_java_prototype ?(public=false) ?(privat=false)
?(native=false)
match arg with
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n
| FileIn n
@@ -8280,7 +8284,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n
| FileIn n
@@ -8333,7 +8337,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| OptString n
| FileIn n
@@ -8363,7 +8367,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| FileIn n
| FileOut n ->
@@ -8396,7 +8400,7 @@ Java_com_redhat_et_libguestfs_GuestFS__1close
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| FileIn n
| FileOut n ->
@@ -8671,7 +8675,7 @@ last_error h = do
function
| FileIn n
| FileOut n
- | Pathname n | Device n | String n -> pr "withCString %s $ \\%s ->
" n n
+ | Pathname n | Device n | Dev_or_Path n | String n -> pr "withCString
%s $ \\%s -> " n n
| OptString n -> pr "maybeWith withCString %s $ \\%s -> " n n
| StringList n -> pr "withMany withCString %s $ \\%s -> withArray0
nullPtr %s $ \\%s -> " n n n n
| Bool _ | Int _ -> ()
@@ -8683,7 +8687,7 @@ last_error h = do
| Bool n -> sprintf "(fromBool %s)" n
| Int n -> sprintf "(fromIntegral %s)" n
| FileIn n | FileOut n
- | Pathname n | Device n | String n | OptString n | StringList n -> n
+ | Pathname n | Device n | Dev_or_Path n | String n | OptString n | StringList
n -> n
) (snd style) in
pr "withForeignPtr h (\\p -> c_%s %s)\n" name
(String.concat " " ("p" :: args));
@@ -8733,7 +8737,7 @@ and generate_haskell_prototype ~handle ?(hs = false) style =
List.iter (
fun arg ->
(match arg with
- | Pathname _ | Device _ | String _ -> pr "%s" string
+ | Pathname _ | Device _ | Dev_or_Path _ | String _ -> pr "%s" string
| OptString _ -> if hs then pr "Maybe String" else pr
"CString"
| StringList _ -> if hs then pr "[String]" else pr "Ptr
CString"
| Bool _ -> pr "%s" bool
@@ -8809,7 +8813,7 @@ print_strings (char * const* const argv)
List.iter (
function
| Pathname n
- | Device n
+ | Device n | Dev_or_Path n
| String n
| FileIn n
| FileOut n -> pr " printf (\"%%s\\n\", %s);\n" n
--
1.6.4.337.g5420e