Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 13 Feb 2001 12:58:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 13 Feb 2001 12:58:06 -0500 Received: from smtp8.us.dell.com ([143.166.224.234]:39689 "EHLO smtp8.us.dell.com") by vger.kernel.org with ESMTP id ; Tue, 13 Feb 2001 12:57:58 -0500 Date: Tue, 13 Feb 2001 11:57:43 -0600 (CST) From: Michael E Brown Reply-To: Michael E Brown To: "Richard B. Johnson" cc: "Domsch, Matt" , , Andi Kleen Subject: [RFC][PATCH] block ioctl to read/write last sector (New! Improved!) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1500554619-416417569-982015326=:26194" Content-ID: Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---1500554619-416417569-982015326=:26194 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-ID: To address the concerns of Andi Kleen, with a good suggestion from Richard Johnson, I have revised my previous patch attempt. Please check this out and comment. Changelog: 1) use get_gendisk() instead of walking array manually 2) pass in struct instead of guessing.. + struct { + unsigned int block; + size_t content_length; + char *block_contents; + } blk_ioctl_parameter; 3) On write, read in previous contents in case userspace doesn't modify the whole block. (prevents garbage from being put in the remainder of the sector) On 7 Feb 2001, Andi Kleen wrote: > But what happens when you e.g. run a software blocksize of 4096 and the device > has >1 inaccessible 512 byte sector at the end? > I think it would be better to pass in a offset in 512 byte units to a special > ioctl (and do error checking in the driver for impossible requests) This has been addressed in the new patch. The new patch takes in an LBA offset and reads "LastLBA - offset" and returns the result to userspace. Checks are done so that only normally inaccessable blocks are accessible through this method. This is done to prevent any possible security consequences from arising because of this patch. Test code showing how to use this IOCTL have also been attached. Regards, Michael Brown ------Original Message------ Problem Summary: There is no function exported to userspace to read or write the last 512-byte sector of an odd-size disk. The block device uses 1K blocksize, and will prevent userspace from seeing the odd-block at the end of the disk, if the disk is odd-size. IA-64 architecture defines a new partitioning scheme where there is a backup of the partition table header in the last sector of the disk. While we can read and write to this sector in the kernel partition code, we have no way for userspace to update this partition block. Solution: As an interim solution, I propose the following IOCTLs for the block device layer: BLKGETLASTSECT and BLKSETLASTSECT. These ioctls will take a userspace pointer to a char[512] and read/write the last sector. Below is a patch to do this. I have attached the patch as well, because I've heard that Pine will eat patches. :-( ---1500554619-416417569-982015326=:26194 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="try-read.c" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="try-read.c" DQojaW5jbHVkZSA8c3lzL3R5cGVzLmg+DQojaW5jbHVkZSA8c3lzL3N0YXQu aD4NCiNpbmNsdWRlIDxzeXMvZmNudGwuaD4NCiNpbmNsdWRlIDxzdGRpby5o Pg0KDQojaW5jbHVkZSA8c3lzL2lvY3RsLmg+DQoNCiNkZWZpbmUgQkxLR0VU TEFTVFNFQ1QgIF9JTygweDEyLDEwOCkgLyogZ2V0IGxhc3Qgc2VjdG9yIG9m IGJsb2NrIGRldmljZSAqLw0KI2RlZmluZSBCTEtTRVRMQVNUU0VDVCAgX0lP KDB4MTIsMTA5KSAvKiBnZXQgbGFzdCBzZWN0b3Igb2YgYmxvY2sgZGV2aWNl ICovDQojZGVmaW5lIEJMS1NTWkdFVCAgX0lPKDB4MTIsMTA0KS8qIGdldCBi bG9jayBkZXZpY2Ugc2VjdG9yIHNpemUgKi8NCg0Kc3RydWN0IGJsa2Rldl9p b2N0bF9wYXJhbSB7DQoJdW5zaWduZWQgaW50IGJsb2NrOw0KCXNpemVfdCBj b250ZW50X2xlbmd0aDsNCgljaGFyICogYmxvY2tfY29udGVudHM7DQp9Ow0K DQptYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogIGludCBmaWxl ZGVzLCByYz0wLCBibGtzej0wOw0KICBjaGFyICpsYXN0YmxvY2s7DQogIHN0 cnVjdCBibGtkZXZfaW9jdGxfcGFyYW0gaW9jdGxfcGFyYW07DQoNCiAgaW9j dGxfcGFyYW0uYmxvY2sgPSAwOw0KDQogIGZpbGVkZXMgPSBvcGVuKCIvZGV2 L3NkYiIsIE9fUkRPTkxZICk7DQogIHByaW50ZigiICBvcGVuIGZpbGVkZXM6 ICVkXG4iLCBmaWxlZGVzKTsNCg0KICByYyA9IGlvY3RsKGZpbGVkZXMsIEJM S1NTWkdFVCwgJmJsa3N6KSA7DQogIGxhc3RibG9jayA9IChjaGFyICopIG1h bGxvYyggYmxrc3ogKyA4ICk7DQogIGlvY3RsX3BhcmFtLmNvbnRlbnRfbGVu Z3RoID0gYmxrc3o7DQogIHByaW50ZigiICBibG9jayBzaXplIGFwcGVhcnMg dG8gYmUgJWRcbiIsIGJsa3N6KTsNCg0KICBtZW1zZXQoIGxhc3RibG9jaywg J3onLCBibGtzeiArIDggICk7DQogIGlvY3RsX3BhcmFtLmJsb2NrX2NvbnRl bnRzID0gbGFzdGJsb2NrOw0KDQogIHJjID0gaW9jdGwoZmlsZWRlcywgQkxL R0VUTEFTVFNFQ1QsICZpb2N0bF9wYXJhbSkgOw0KICBwcmludGYoIiAgbGFz dCBzZWN0IGlvY3RsIHJjOiAlZFxuIiwgcmMpOw0KDQogIGxhc3RibG9ja1ti bGtzeiArIDFdID0gJ1wwJzsNCiAgcHJpbnRmKCIgIExhc3QgQmxvY2s6IFxu JXM8LS1cbiIsIGxhc3RibG9jayk7DQoNCiAgcmV0dXJuIDA7DQp9DQoNCg== ---1500554619-416417569-982015326=:26194 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="try-write.c" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="try-write.c" DQojaW5jbHVkZSA8c3lzL3R5cGVzLmg+DQojaW5jbHVkZSA8c3lzL3N0YXQu aD4NCiNpbmNsdWRlIDxzeXMvZmNudGwuaD4NCiNpbmN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ZigiICBibG9j ayBzaXplIGFwcGVhcnMgdG8gYmUgJWRcbiIsIGJsa3N6ICk7DQoNCiAgbWVt c2V0KCBsYXN0YmxvY2ssIG5ld2NoYXIsIGJsa3N6ICsgMiApOw0KICBpb2N0 bF9wYXJhbS5ibG9ja19jb250ZW50cyA9IGxhc3RibG9jazsNCg0KICByYyA9 IGlvY3RsKGZpbGVkZXMsIEJMS1NFVExBU1RTRUNULCAmaW9jdGxfcGFyYW0p IDsNCiAgcHJpbnRmKCIgIGxhc3Qgc2VjdCBpb2N0bCByYzogJWRcbiIsIHJj KTsNCg0KICByZXR1cm4gMDsNCn0NCg0K ---1500554619-416417569-982015326=:26194 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=patch-getlastsector-20010213 Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=patch-getlastsector-20010213 ZGlmZiAtcnVQIGxpbnV4L2RyaXZlcnMvYmxvY2svYmxrcGcuYyBsaW51eC1p b2N0bC9kcml2ZXJzL2Jsb2NrL2Jsa3BnLmMNCi0tLSBsaW51eC9kcml2ZXJz L2Jsb2NrL2Jsa3BnLmMJRnJpIE9jdCAyNyAwMTozNTo0NyAyMDAwDQorKysg bGludXgtaW9jdGwvZHJpdmVycy9ibG9jay9ibGtwZy5jCVR1ZSBGZWIgMTMg MTE6Mzk6MzcgMjAwMQ0KQEAgLTM5LDYgKzM5LDkgQEANCiANCiAjaW5jbHVk ZSA8YXNtL3VhY2Nlc3MuaD4NCiANCitzdGF0aWMgaW50IHNldF9sYXN0X3Nl Y3Rvcigga2Rldl90IGRldiwgY29uc3Qgdm9pZCAqcGFyYW0gKTsNCitzdGF0 aWMgaW50IGdldF9sYXN0X3NlY3Rvcigga2Rldl90IGRldiwgY29uc3Qgdm9p ZCAqcGFyYW0gKTsNCisNCiAvKg0KICAqIFdoYXQgaXMgdGhlIGRhdGEgZGVz Y3JpYmluZyBhIHBhcnRpdGlvbj8NCiAgKg0KQEAgLTIxMCw2IC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J1Y3Qgew0KKwkJdW5zaWduZWQgaW50 IGJsb2NrOw0KKwkJc2l6ZV90IGNvbnRlbnRfbGVuZ3RoOw0KKwkJY2hhciAq YmxvY2tfY29udGVudHM7DQorCX0gYmxrX2lvY3RsX3BhcmFtZXRlcjsNCisN CisgICAgICAgIGlmKCAhZGV2ICkgcmV0dXJuIC1FSU5WQUw7DQorDQorICAg ICAgICBpZihjb3B5X2Zyb21fdXNlcigmYmxrX2lvY3RsX3BhcmFtZXRlciwg cGFyYW0sIHNpemVvZihibGtfaW9jdGxfcGFyYW1ldGVyKSkpDQorCQlyZXR1 cm4gLUVGQVVMVDsNCisNCisgICAgICAgIGcgPSBnZXRfZ2VuZGlzayggZGV2 ICk7DQorDQorICAgICAgICBpZiggIWcgKSByZXR1cm4gLUVJTlZBTDsNCisN CisgICAgICAgIGxhc3RsYmEgPSBnLT5wYXJ0W01JTk9SKGRldildLm5yX3Nl Y3RzOw0KKw0KKyAgICAgICAgaWYoICFsYXN0bGJhICkgcmV0dXJuIC1FSU5W QUw7DQorDQorICAgICAgICBoYXJkYmxvY2tzaXplID0gZ2V0X2hhcmRibG9j a3NpemUoZGV2KTsNCisgICAgICAgIGlmKCAhIGhhcmRibG9ja3NpemUgKSBo YXJkYmxvY2tzaXplID0gNTEyOw0KKw0KKyAgICAgICAgIC8qIE5lZWQgdG8g Y2hhbmdlIHRoZSBibG9jayBzaXplIHRoYXQgdGhlIGJsb2NrIGxheWVyIHVz ZXMgKi8NCisgICAgICAgIGlmIChibGtzaXplX3NpemVbTUFKT1IoZGV2KV0p ew0KKyAgICAgICAgICAgICAgICBvcmlnX2Jsa3NpemUgPSBibGtzaXplX3Np emVbTUFKT1IoZGV2KV1bTUlOT1IoZGV2KV07DQorICAgICAgICB9DQorDQor ICAgICAgICAgLyogdmFsaWRhdGUgdXNlcnNwYWNlIGlucHV0ICovDQorICAg ICAgICBpZiggYmxrX2lvY3RsX3BhcmFtZXRlci5ibG9jayA9PSAwICkNCisJ CWdv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hbHVlcyBvZiANCisgICoJCSAgPD0g KCh0b3RhbF9zZWN0cyArIDEpICUgbG9naWNhbF9ibG9ja19zaXplKSAgfHwg IDANCisgICoJCSAgYXJlIGFsbG93ZWQuDQorICAqIAlibG9ja19jb250ZW50 czogYSBwb2ludGVyIHRvIHVzZXJzcGFjZSBjaGFyKiwgdGhpcyBpcyB3aGVy ZSB3ZSB3cml0ZSANCisgICoJIHJldHVybmVkIGJsb2NrcyB0by4NCisgICog CWNvbnRlbnRfbGVuZ3RoOiBIb3cgYmlnIHRoZSB1c2Vyc3BhY2UgYnVmZmVy IGlzLg0KKyAgKiByZXR1cm46IA0KKyAgKiAgICAwIG9uIHN1Y2Nlc3MNCisg ICogICAtRVJSVkFMIG9uIGVycm9yLg0KKyAgKioqKioqKioqKioqKioqKioq KioqLw0KK2ludCBzZXRfbGFzdF9zZWN0b3IoIGtkZXZfdCBkZXYsIGNvbnN0 IHZvaWQgKnBhcmFtICkgDQorew0KKyAgICAgICAgc3RydWN0IGJ1ZmZlcl9o ZWFkICpiaDsNCisgICAgICAgIHN0cnVjdCBnZW5kaXNrICpnOw0KKyAgICAg ICAgaW50IHJjID0gMDsNCisgICAgICAgIHVuc2lnbmVkIGludCBsYXN0bGJh LCB3cml0ZWxiYTsNCisgICAgICAgIGludCBvcmlnX2Jsa3NpemUgPSBCTE9D S19TSVpFOw0KKyAgICAgICAgaW50IGhhcmRibG9ja3NpemU7DQorDQorCXN0 cnVjdCB7DQorCQl1bnNpZ25lZCBpbnQgYmxvY2s7DQorCQlzaXplX3QgY29u dGVudF9sZW5ndGg7DQorCQljaGFyICpibG9ja19jb250ZW50czsNCisJfSBi bGtfaW9jdGxfcGFyYW1ldGVyOw0KKw0KKyAgICAgICAgaWYoICFkZXYgKSBy ZXR1cm4gLUVJTlZBTDsNCisNCisJaWYoY29weV9mcm9tX3VzZXIoJmJsa19p b2N0bF9wYXJhbWV0ZXIsIHBhcmFtLCBzaXplb2YoYmxrX2lvY3RsX3BhcmFt ZXRlcikpKQ0KKwkJcmV0dXJuIC1FRkFVTFQ7DQorDQorICAgICAgICBnID0g Z2V0X2dlbmRpc2soIGRldiApOw0KKw0KKyAgICAgICAgaWYoICFnICkgcmV0 dXJuIC1FSU5WQUw7DQorICAgIA0KKyAgICAgICAgbGFzdGxiYSA9IGctPnBh cnRbTUlOT1IoZGV2KV0ubnJfc2VjdHMgOw0KKyAgICANCisgICAgICAgIGlm KCAhbGFzdGxiYSApIHJldHVybiAtRUlOVkFMOw0KKyAgICANCisgICAgICAg IGhhcmRibG9ja3NpemUgPSBnZXRfaGFyZGJsb2Nrc2l6ZShkZXYpOw0KKyAg ICAgICAgaWYoICEgaGFyZGJsb2Nrc2l6ZSApIGhhcmRibG9ja3NpemUgPSA1 MTI7DQorICAgIA0KKyAgICAgICAgIC8qIE5lZWQgdG8gY2hhbmdlIHRoZSBi bG9jayBzaXplIHRoYXQgdGhlIGJsb2NrIGxheWVyIHVzZXMgKi8NCisgICAg ICAgIGlmIChibGtzaXplX3NpemVbTUFKT1IoZGV2KV0pew0KKyAgICAgICAg ICAgICAgICBvcmlnX2Jsa3NpemUgPSBibGtzaXplX3NpemVbTUFKT1IoZGV2 KV1bTUlOT1IoZGV2KV07DQorICAgICAgICB9DQorDQorICAgICAgICAgLyog dmFsaWRhdGUgdXNlcnNwYWNlIGlucHV0ICovDQorICAgICAgICBpZiggYmxr X2lvY3RsX3BhcmFtZXRlci5ibG9jayA9PSAwICkNCisJCWdvdG8gZ29vZF9w YXJhbXM7DQorDQorCS8qIHNvIHdlIGRvbid0IGRpdmlkZSBieSB6ZXJvIGJl bG93ICovICANCisJaWYob3JpZ19ibGtzaXplID09IDApIA0KKwkJcmV0dXJu IC1FSU5WQUw7IA0KKw0KKyAgICAgICAgaWYoIGJsa19pb2N0bF9wYXJhbWV0 ZXIuYmxvY2sgPD0gKGxhc3RsYmEgJSAob3JpZ19ibGtzaXplIC8gaGFyZGJs b2Nrc2l6ZSkpKQ0KKwkJZ290byBnb29k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opIGFyZyk7DQog DQorCQljYXNlIEJMS0dFVExBU1RTRUNUOg0KKwkJY2FzZSBCTEtTRVRMQVNU U0VDVDoNCiAJCWNhc2UgQkxLUk9TRVQ6DQogCQljYXNlIEJMS1JPR0VUOg0K IAkJY2FzZSBCTEtSQVNFVDoNCmRpZmYgLXJ1UCBsaW51eC9pbmNsdWRlL2xp bnV4L2ZzLmggbGludXgtaW9jdGwvaW5jbHVkZS9saW51eC9mcy5oDQotLS0g bGludXgvaW5jbHVkZS9saW51eC9mcy5oCVR1ZSBKYW4gMzAgMDE6MjQ6NTYg MjAwMQ0KKysrIGxpbnV4LWlvY3RsL2luY2x1ZGUvbGludXgvZnMuaAlUdWUg RmViIDEzIDExOjA4OjQzIDIwMDENCkBAIC0xODAsNiArMTgwLDggQEANCiAv KiBUaGlzIHdhcyBoZXJlIGp1c3QgdG8gc2hvdyB0aGF0IHRoZSBudW1iZXIg aXMgdGFrZW4gLQ0KICAgIHByb2JhYmx5IGFsbCB0aGVzZSBfSU8oMHgxMiwq KSBpb2N0bHMgc2hvdWxkIGJlIG1vdmVkIHRvIGJsa3BnLmguICovDQogI2Vu ZGlmDQorI2RlZmluZSBCTEtHRVRMQVNUU0VDVCAgX0lPKDB4MTIsMTA4KSAv KiBnZXQgbGFzdCBzZWN0b3Igb2YgYmxvY2sgZGV2aWNlICovDQorI2RlZmlu ZSBCTEtTRVRMQVNUU0VDVCAgX0lPKDB4MTIsMTA5KSAvKiBnZXQgbGFzdCBz ZWN0b3Igb2YgYmxvY2sgZGV2aWNlICovDQogDQogDQogI2RlZmluZSBCTUFQ X0lPQ1RMIDEJCS8qIG9ic29sZXRlIC0ga2VwdCBmb3IgY29tcGF0aWJpbGl0 eSAqLw0K ---1500554619-416417569-982015326=:26194-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/