Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp295941imm; Tue, 25 Sep 2018 22:02:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV61wbNMIqagMC6BCaLlu66h3o986zCPh1kAZ8Rl5g/IUzi31ZQ4rGWzJ5yB471kHFEEGT63m X-Received: by 2002:a17:902:8681:: with SMTP id g1-v6mr4114081plo.302.1537938122685; Tue, 25 Sep 2018 22:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537938122; cv=none; d=google.com; s=arc-20160816; b=BlC2cHZ234A5nFCIpiLGPK9t2NIsqU83jg2YdKpdnAQj4cCFP1X5L5Cfp9qrq0400G 3nuZgb8cXWZUTyfqx+0OMpEqycItFMmy5LrAbWitoolE0uTnXU0FQdQh3rHe0w2kO4iX XP6pMdZ5U+zPeNm7cnc1CFIkSbMJnnvpLU23eQbUws9r9X02EifzP4DTOQ960dhwaijt 0lBI+tMtsaBjR8H5jBwj7PCZn8uqZz/pWiAu5+6BxBC21P4cY2lG8CMS3AGml1hXprdX 9xWo1KrJx9XOe9KsKFJ0FopHlKLPqrChBNRZkd/0FNiBsz7LcgCNWxyBIoOTKhKE0g+u HiJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QoPyQr7vpgzR3J632GjQxYCFqNqqlkHqf2EduJborxI=; b=KyCOZ5zHcDCqiNiDesNzOe+f+nzh+RjJxxX45duP6yybwSuYjbT2a+SntCDUjhZBXP W0P9bIhsOyhDc9iUeMnBSsBSQTRYIhZlBTRWc7GF9HiwNxjqxQ6E7eNjV1xtOlzQ6s9n fZ1+DadoyUJugfPaMWzjrfrYgjKayUyqAq7wfdaplLwupH27Db/cHQ12FnaHPSr/rIwI pDTCFqUqoR4WETityMITLOeAzbLtxnz28M/ho1TadNNvez9gzBQELka7Hb75lrocAtYj WCp3hlxXihrxdaIjlxCDbEwqwl6tBsLZ6lORRTwo+RTZmbkDgW6Rt/VRRLIbyOtRDcRH vVVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si4244488pla.505.2018.09.25.22.01.47; Tue, 25 Sep 2018 22:02:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbeIZLMJ (ORCPT + 99 others); Wed, 26 Sep 2018 07:12:09 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:53560 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726289AbeIZLMJ (ORCPT ); Wed, 26 Sep 2018 07:12:09 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id 303C027DD1A From: Helen Koike To: dm-devel@redhat.com Cc: agk@redhat.com, snitzer@redhat.com, linux-kernel@vger.kernel.org, enric.balletbo@collabora.com, wad@chromium.org, linux-doc@vger.kernel.org, linux-lvm@redhat.com, kernel@collabora.com Subject: [PATCH 1/2] dm ioctl: add a device mapper ioctl function. Date: Wed, 26 Sep 2018 02:00:46 -0300 Message-Id: X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Enric Balletbo i Serra Add a dm_ioctl_cmd to issue the equivalent of a DM ioctl call in kernel. Signed-off-by: Enric Balletbo i Serra --- drivers/md/dm-ioctl.c | 50 +++++++++++++++++++++++++++++++++++ include/linux/device-mapper.h | 6 +++++ 2 files changed, 56 insertions(+) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index b810ea77e6b1..68ce2557c62b 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -2024,3 +2024,53 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid) return r; } + +/** + * dm_ioctl_cmd - Device mapper ioctl's + * @command: ioctl command + * @param: Pointer to device mapped ioctl struct + */ +int dm_ioctl_cmd(uint command, struct dm_ioctl *param) +{ + int r = 0; + int ioctl_flags; + unsigned int cmd; + ioctl_fn fn = NULL; + size_t input_param_size; + struct file *filp = NULL; + + if (_IOC_TYPE(command) != DM_IOCTL) + return -ENOTTY; + + /* DM_DEV_ARM_POLL is not supported */ + if (command == DM_DEV_ARM_POLL) + return -EINVAL; + + cmd = _IOC_NR(command); + + /* + * Nothing more to do for the version command. + */ + if (cmd == DM_VERSION_CMD) + return 0; + + fn = lookup_ioctl(cmd, &ioctl_flags); + if (!fn) { + DMWARN("dm_ioctl: unknown command 0x%x", command); + return -ENOTTY; + } + + input_param_size = param->data_size; + r = validate_params(cmd, param); + if (r) + return r; + + param->data_size = sizeof(*param); + r = fn(filp, param, input_param_size); + + if (unlikely(param->flags & DM_BUFFER_FULL_FLAG) && + unlikely(ioctl_flags & IOCTL_FLAGS_NO_PARAMS)) + DMERR("ioctl %d tried to output some data but has IOCTL_FLAGS_NO_PARAMS set", cmd); + + return r; +} diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 6fb0808e87c8..df5a5a60f9aa 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -12,6 +12,7 @@ #include #include #include +#include struct dm_dev; struct dm_target; @@ -424,6 +425,11 @@ void dm_remap_zone_report(struct dm_target *ti, struct bio *bio, sector_t start); union map_info *dm_get_rq_mapinfo(struct request *rq); +/* + * Device mapper ioctl function. + */ +int dm_ioctl_cmd(unsigned int command, struct dm_ioctl *param); + struct queue_limits *dm_get_queue_limits(struct mapped_device *md); /* -- 2.19.0