summaryrefslogtreecommitdiff
path: root/flash_otp_lock.c
diff options
context:
space:
mode:
authorDongsheng Yang <yangds.fnst@cn.fujitsu.com>2015-10-31 11:12:01 +0800
committerBrian Norris <computersforpeace@gmail.com>2015-11-11 14:38:40 -0800
commit7d81790ced345585b1e647ca9d0f6678e7062fa4 (patch)
tree02f61270c7a0fff7bb6b2e28f247a3d2fd6ff490 /flash_otp_lock.c
parent344753f2aacb94d98ce238f81fc4a4b6ef6adea9 (diff)
mtd-utils: Restructure the mtd-utils source.
* There is no code modification in this commit, only moving * the files to proper place. The user tools looks a little messy as we place almost the all tools in the root directory of mtd-utils. To make it more clear, I propose to introduce the following structure for our source code. mtd-utils/ |-- lib |-- include |-- misc-utils |-- jffsX-utils |-- nand-utils |-- nor-utils |-- ubi-utils |-- ubifs-utils `-- tests Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'flash_otp_lock.c')
-rw-r--r--flash_otp_lock.c72
1 files changed, 0 insertions, 72 deletions
diff --git a/flash_otp_lock.c b/flash_otp_lock.c
deleted file mode 100644
index 3c39a2d..0000000
--- a/flash_otp_lock.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * flash_otp_lock.c -- lock area of One-Time-Program data
- */
-
-#define PROGRAM_NAME "flash_otp_lock"
-
-#include <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-
-#include <mtd/mtd-user.h>
-#include "common.h"
-
-int main(int argc,char *argv[])
-{
- int fd, val, ret, offset, size;
- char *p;
-
- if (argc != 5 || strcmp(argv[1], "-u")) {
- fprintf(stderr, "Usage: %s -u <device> <offset> <size>\n", PROGRAM_NAME);
- fprintf(stderr, "offset and size must match on OTP region boundaries\n");
- fprintf(stderr, "CAUTION! ONCE LOCKED, OTP REGIONS CAN'T BE UNLOCKED!\n");
- return EINVAL;
- }
-
- fd = open(argv[2], O_WRONLY);
- if (fd < 0) {
- perror(argv[2]);
- return errno;
- }
-
- val = MTD_OTP_USER;
- ret = ioctl(fd, OTPSELECT, &val);
- if (ret < 0) {
- perror("OTPSELECT");
- return errno;
- }
-
- offset = strtoul(argv[3], &p, 0);
- if (argv[3][0] == 0 || *p != 0) {
- fprintf(stderr, "%s: bad offset value\n", PROGRAM_NAME);
- return ERANGE;
- }
-
- size = strtoul(argv[4], &p, 0);
- if (argv[4][0] == 0 || *p != 0) {
- fprintf(stderr, "%s: bad size value\n", PROGRAM_NAME);
- return ERANGE;
- }
-
- printf("About to lock OTP user data on %s from 0x%x to 0x%x\n",
- argv[2], offset, offset + size);
- if (prompt("Are you sure?", false)) {
- struct otp_info info;
- info.start = offset;
- info.length = size;
- ret = ioctl(fd, OTPLOCK, &info);
- if (ret < 0) {
- perror("OTPLOCK");
- return errno;
- }
- printf("Done.\n");
- } else {
- printf("Aborted\n");
- }
-
- return 0;
-}