From: Davidlohr Bueso <dave@xxxxxxx> Signed-off-by: Davidlohr Bueso <dave@xxxxxxx> --- fdisk/utils.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fdisk/utils.c b/fdisk/utils.c index 352a934..5bb4984 100644 --- a/fdisk/utils.c +++ b/fdisk/utils.c @@ -147,6 +147,12 @@ void fdisk_init_debug(int mask) /** * fdisk_new_context: + * @filename: path to the device to be handled + * @readonly: how to open the device + * + * If the @readonly flag is set to false, fdisk will attempt to open + * the device with read-write mode and will fallback to read-only if + * unsuccessful. * * Returns: newly allocated fdisk context */ @@ -155,10 +161,6 @@ struct fdisk_context *fdisk_new_context_from_filename(const char *fname, int rea int fd, errsv = 0; struct fdisk_context *cxt = NULL; - /* - * Attempt to open the device with r-w permissions - * by default, otherwise try read-only. - */ if (readonly == 1 || (fd = open(fname, O_RDWR)) < 0) { if ((fd = open(fname, O_RDONLY)) < 0) return NULL; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html