diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-02-22 19:50:45 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-10-21 07:49:00 -0400 |
commit | 30c40d2c01f68c7eb1a41ab3552bdaf5dbf300d4 (patch) | |
tree | 38b69a80c4c0df13ef3b905f5195f6cadf930223 /fs/block_dev.c | |
parent | 9a1c3542768b5a58e45a9216921cd10a3bae1205 (diff) |
[PATCH] propagate mode through open_bdev_excl/close_bdev_excl
replace open_bdev_excl/close_bdev_excl with variants taking fmode_t.
superblock gets the value used to mount it stored in sb->s_mode
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r-- | fs/block_dev.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 05131baf3cf8..4b595904cefd 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1309,32 +1309,29 @@ fail: | |||
1309 | EXPORT_SYMBOL(lookup_bdev); | 1309 | EXPORT_SYMBOL(lookup_bdev); |
1310 | 1310 | ||
1311 | /** | 1311 | /** |
1312 | * open_bdev_excl - open a block device by name and set it up for use | 1312 | * open_bdev_exclusive - open a block device by name and set it up for use |
1313 | * | 1313 | * |
1314 | * @path: special file representing the block device | 1314 | * @path: special file representing the block device |
1315 | * @flags: %MS_RDONLY for opening read-only | 1315 | * @mode: FMODE_... combination to pass be used |
1316 | * @holder: owner for exclusion | 1316 | * @holder: owner for exclusion |
1317 | * | 1317 | * |
1318 | * Open the blockdevice described by the special file at @path, claim it | 1318 | * Open the blockdevice described by the special file at @path, claim it |
1319 | * for the @holder. | 1319 | * for the @holder. |
1320 | */ | 1320 | */ |
1321 | struct block_device *open_bdev_excl(const char *path, int flags, void *holder) | 1321 | struct block_device *open_bdev_exclusive(const char *path, fmode_t mode, void *holder) |
1322 | { | 1322 | { |
1323 | struct block_device *bdev; | 1323 | struct block_device *bdev; |
1324 | fmode_t mode = FMODE_READ; | ||
1325 | int error = 0; | 1324 | int error = 0; |
1326 | 1325 | ||
1327 | bdev = lookup_bdev(path); | 1326 | bdev = lookup_bdev(path); |
1328 | if (IS_ERR(bdev)) | 1327 | if (IS_ERR(bdev)) |
1329 | return bdev; | 1328 | return bdev; |
1330 | 1329 | ||
1331 | if (!(flags & MS_RDONLY)) | ||
1332 | mode |= FMODE_WRITE; | ||
1333 | error = blkdev_get(bdev, mode, 0); | 1330 | error = blkdev_get(bdev, mode, 0); |
1334 | if (error) | 1331 | if (error) |
1335 | return ERR_PTR(error); | 1332 | return ERR_PTR(error); |
1336 | error = -EACCES; | 1333 | error = -EACCES; |
1337 | if (!(flags & MS_RDONLY) && bdev_read_only(bdev)) | 1334 | if ((mode & FMODE_WRITE) && bdev_read_only(bdev)) |
1338 | goto blkdev_put; | 1335 | goto blkdev_put; |
1339 | error = bd_claim(bdev, holder); | 1336 | error = bd_claim(bdev, holder); |
1340 | if (error) | 1337 | if (error) |
@@ -1347,22 +1344,23 @@ blkdev_put: | |||
1347 | return ERR_PTR(error); | 1344 | return ERR_PTR(error); |
1348 | } | 1345 | } |
1349 | 1346 | ||
1350 | EXPORT_SYMBOL(open_bdev_excl); | 1347 | EXPORT_SYMBOL(open_bdev_exclusive); |
1351 | 1348 | ||
1352 | /** | 1349 | /** |
1353 | * close_bdev_excl - release a blockdevice openen by open_bdev_excl() | 1350 | * close_bdev_exclusive - close a blockdevice opened by open_bdev_exclusive() |
1354 | * | 1351 | * |
1355 | * @bdev: blockdevice to close | 1352 | * @bdev: blockdevice to close |
1353 | * @mode: mode, must match that used to open. | ||
1356 | * | 1354 | * |
1357 | * This is the counterpart to open_bdev_excl(). | 1355 | * This is the counterpart to open_bdev_exclusive(). |
1358 | */ | 1356 | */ |
1359 | void close_bdev_excl(struct block_device *bdev) | 1357 | void close_bdev_exclusive(struct block_device *bdev, fmode_t mode) |
1360 | { | 1358 | { |
1361 | bd_release(bdev); | 1359 | bd_release(bdev); |
1362 | blkdev_put(bdev, 0); /* move up in the next patches */ | 1360 | blkdev_put(bdev, mode); |
1363 | } | 1361 | } |
1364 | 1362 | ||
1365 | EXPORT_SYMBOL(close_bdev_excl); | 1363 | EXPORT_SYMBOL(close_bdev_exclusive); |
1366 | 1364 | ||
1367 | int __invalidate_device(struct block_device *bdev) | 1365 | int __invalidate_device(struct block_device *bdev) |
1368 | { | 1366 | { |