Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp422637imm; Thu, 30 Aug 2018 02:13:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYvgpeRtACo2u1OmqqNUgMDE6XFZ3USstUzC5y2gp5KfIzwK4/Pdq2FvyjrEA74V0q0ek8R X-Received: by 2002:a62:f5c1:: with SMTP id b62-v6mr9740369pfm.158.1535620420022; Thu, 30 Aug 2018 02:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535620419; cv=none; d=google.com; s=arc-20160816; b=KN1HW02UJJY+k/Eq4mfqRzwxYySkBPlUYRbcjOG2lqmLO4efE59Vy27e73gBvJYI0t JPM0GJFtBNUPKpK//zNXXXvsdOtZ0xnpXAmaFeKRw9mUc7orZlcRj7zuCfDlhUT1Ou5c CPVuMn2IBvYlmxCPzinVqjr56DSSs8h76iucsi+xCQZ5XxAuNMzmuhng/iQdp7jSWl2C DosJaEL83I2P2bZCdktRv2MqBmCmEyEPdKbDYzKkv93w/jVRqKi2hti5Vv3sN9kfzx+p Oep2Bs45DCDtEzxjIaS59fDUt7pBFmG6uuN1+sqDYUhgfjTL/7mJvSAGjKCznMh2xrdk J7bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=7gz6NYYEAen5wkJR7iq4KQ64/ir6y1XMGwdqDdDUtv4=; b=aJgsK9AO5Y/wUktKW0uOBjh09+vgkBjld4wX91+WxeBtxn2+GmB86/Aliv/CT/kUWO l5ETb9TuoOyaEfr0R9P9HifO6Nc47LlL/oY5Ua5wRSrXew1+TWoiWVfkDJ10lkl0xDPn ehVJv8XtgZw7ths2czt3dehkLVWu989DOBsOTTNwNiJt6daTKGgmup+Q9/B3U4JpOraq ZfZDtYzmfQ8fuxt3tAbKr4OzLR6Jth+fOjHplXkuWjUhMIny3qemeuH9owwqWJTsbgaG kr/vgjllHjACsrcwxOMrK02SwH7OeBj33HU3R7iQr0ZaEBQxr5UJq+KKde8VMrYvUzEp glyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NHpqB7Ac; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si5899896plq.163.2018.08.30.02.13.24; Thu, 30 Aug 2018 02:13:39 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NHpqB7Ac; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728065AbeH3NN2 (ORCPT + 99 others); Thu, 30 Aug 2018 09:13:28 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46947 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbeH3NN2 (ORCPT ); Thu, 30 Aug 2018 09:13:28 -0400 Received: by mail-pl1-f196.google.com with SMTP id a4-v6so3561850plm.13; Thu, 30 Aug 2018 02:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7gz6NYYEAen5wkJR7iq4KQ64/ir6y1XMGwdqDdDUtv4=; b=NHpqB7AcW1iZAHV8GWpD+vW5/g+yKMNKOry2sO0dTrFuoUT4+TXq66i3HrQxuAPOCk SbmCH9Sys0bHrMEqljWs7Ru4zZk7bIp9OcX10+y8A2tTnldbEKPHzo7CqdAvzTz3O4Qi 6ZZGsVcFZYZDxg/lmKLJp3LsrP9e+eFtfnXmNP+eph1CJlrgbV7Smdhn0vBSr1vJ1bdz +DXLg8gEsByJxrIxdoml57Vcb89Ed06aJQ2pGRBne9CoM0Il4c0Xfh1MyKaXpdj5o9RS O12wuXCgjOV8pRVUb8+XkTznAss2n11mGQ00B7tr96r5pJflDvu8Xs4UINRK09fvPzD3 KWrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7gz6NYYEAen5wkJR7iq4KQ64/ir6y1XMGwdqDdDUtv4=; b=BPIrwrJsT/uDmbCzCLOEcX0dc6/l2jxVgKnmu9ENI2Cir+S/jIJ6AGFX6yJC47AD5s IBikJZZWbJj5bWF+AYnh7SDC3D0oNFx9cxq8A2lysgupK6dNTMlljTgj/ZwQ6tXIFOfN TIR2MyOQ+OJ5xVWkTBxLf3e0E4EH1Pff/4pZUonmaUKQ0Pvh152uhZAGChd33ajttnSc 0x4vSLeKZ+TkQ5/tfiADKMQJu24llO/O6qk4W+2uUALMS8P/k9Hk5NpeOSZI+cyfdVJR 1tqlovDXevRmP5wkMeQMsyE0ed3XwI7g9TyYEVNgECZAvTfFUOaByx2vvRaxvnmsQIUX AbSg== X-Gm-Message-State: APzg51DaFQXD0Rrnj7zCjveGYT2w6+yV7PtB4cpVsU7Ub9QNWcf7klLm geiV6FITahezw+5aGNH4Tql853oyYR88ug== X-Received: by 2002:a17:902:f20f:: with SMTP id gn15mr9294496plb.173.1535620338469; Thu, 30 Aug 2018 02:12:18 -0700 (PDT) Received: from suh.localdomain ([119.40.32.42]) by smtp.gmail.com with ESMTPSA id l6-v6sm8787858pfl.169.2018.08.30.02.12.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Aug 2018 02:12:17 -0700 (PDT) From: Su Hua To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Su Hua Subject: [PATCH] block: Add a check for fdisk Date: Thu, 30 Aug 2018 17:11:27 +0800 Message-Id: <1535620287-27189-1-git-send-email-suhua.tanke@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a block device is acquired in the form of FMODE_EXCL, I think it should not be allowed to perform partition operations, similar to when mount is executed. Signed-off-by: Su Hua --- block/partition-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/partition-generic.c b/block/partition-generic.c index 5a8975a..a8daa31 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -440,7 +440,7 @@ static int drop_partitions(struct gendisk *disk, struct block_device *bdev) struct hd_struct *part; int res; - if (bdev->bd_part_count || bdev->bd_super) + if (bdev->bd_part_count || bdev->bd_super || bdev->bd_holders) return -EBUSY; res = invalidate_partition(disk, 0); if (res) -- 2.7.4