Age | Commit message (Collapse) | Author |
|
A lock/unlock/islocked ioctl() should be prevented from anything past
the last byte, inclusive. But we were doing an exclusive check.
This isn't a big deal, as the kernel MTD APIs would be guarding this
anyway, but let's do this for completeness.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Use the simple_* helpers to improve error checking.
Also fixup brace style at the same time.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
With the -i / --islocked flags.
Sample output:
# flash_lock --islocked /dev/mtd0
Device: /dev/mtd0
Start: 0
Len: 0x400000
Lock status: unlocked
Return code: 0
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Add new --lock/--unlock flags, so we can do either with the same binary.
This will prepare for the addition of other features, so we don't have
to keep duplicating the same binary via #include "flash_unlock.c".
The defaults still work as expected: flash_unlock will default to
REQUEST_UNLOCK, and flash_lock will default to REQUEST_LOCK.
Eventually, we might deprecate one of the two (flash_unlock, probably),
so we only have to ship one flash_{un,}lock binary.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Previously, there were no options (besides stand-alone --help and
--version), so we just used fixed-position argv indexes. Let's change
that.
Also clean up the sanity checks a bit to make them more verbose and
specific.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Just use the common helper macro.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
We will be adding some more flags, so the getopt library can help.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
block count should be nested within the optional offset listing. That
is, we require offset before we accept a block count.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
This basically reverts commit 43feb39f35a9ee0ed3 which changed the full
length calculation to be one less than one sector. I don't understand
the logic in the commit message where it states that the length should
be one sector smaller as this results in misbehavior at runtime.
For example, with a mtd device with total size 0x400000 and erase block
size of 0x20000 (which gives us a total of 32 sectors), this new logic
results in:
mtdLockInfo.start = 0;
mtdLockInfo.length = 0x3e0000; /* (32 - 1) * 0x20000 */
Calling MEMLOCK/MEMUNLOCK on the device with this range leaves the last
sector unchanged which is certainly not what we want. So drop this -1
part of the calculation.
To look at it another way, if we only attempt to lock one sector, this
calculation would end up with the .length set to 0. Calling MEMLOCK
with a length of 0 does not lock the sector as this simple code shows:
int main(int argc, char *argv[]) {
erase_info_t e0 = { 0, 0 }, e1 = { 0, 0x20000 };
int fd = open(argv[1], O_RDONLY);
ioctl(fd, MEMUNLOCK, &e1);
printf("%i\n", ioctl(fd, MEMISLOCKED, &e1));
ioctl(fd, MEMLOCK, &e0);
printf("%i\n", ioctl(fd, MEMISLOCKED, &e1));
}
MEMISLOCKED returns 0 both times. If we change the argument to MEMLOCK
to e1, then MEMISLOCKED returns 1.
Signed-off-by: Steven Miao <realmz6@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Now that the utils have equivalent functionality, merge the two source
code bases so they can't diverge in the future.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
The flash_lock util has a bit of extra argument checking, and it supports
a magic value of "-1" to mean "all blocks".
The flash_unlock util supports automatic 2nd/3rd arguments to unlock the
whole flash. It also supports multiple bases (not just hex) for selecting
the range of the device to unlock.
So tweak both utilities so that they have equivalent functionality again
by adding the missing features to each.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Make sure all the utils define PROGRAM_NAME and do so at the start of
the file so that sub-headers may assume it exists.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
This patch enhances the flash_unlock utility to be able to do
unlocking for specified blocks range.
This patch also fixes calculation of 'length' as in previous patch.
Say there are 240 blocks present in the device. Then:
offset starts from: 0x0
and full size of device: 0x1E00000
doing: 240 * 0x20000 gives -> 0x1E00000
But last block address should be 0x1DE0000 (which spans for 0x20000
bytes, adding up to size of 0x1E00000)
Signed-off-by: Vimal Singh <vimalsingh@ti.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
|
|
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
|
|
|