return 1;
}
+static int
+check_path (guestfs_h *g, const char *filename)
+{
+ if (strchr (filename, ',') != NULL) {
+ error (g, _("filename cannot contain ',' (comma) character"));
+ return -1;
+ }
+ return 0;
+}
+
int
guestfs__add_drive_opts (guestfs_h *g, const char *filename,
const struct guestfs_add_drive_opts_argv *optargs)
char *abs_path = NULL;
int use_cache_off;
- if (strchr (filename, ',') != NULL) {
- error (g, _("filename cannot contain ',' (comma) character"));
+ if (check_path(g, filename) == -1)
return -1;
- }
readonly = optargs->bitmask & GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK
? optargs->readonly : 0;
int
guestfs__add_cdrom (guestfs_h *g, const char *filename)
{
- if (strchr (filename, ',') != NULL) {
- error (g, _("filename cannot contain ',' (comma) character"));
+ if (check_path(g, filename) == -1)
return -1;
- }
if (access (filename, F_OK) == -1) {
perrorf (g, "%s", filename);