Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c88d802aa3 | ||
|
|
1f01a8330b | ||
|
|
b87411c02f | ||
|
|
7f38b4bd10 | ||
|
|
9e5646d30e | ||
|
|
33442482c6 | ||
|
|
e987dcd948 | ||
|
|
2fd11378c8 | ||
|
|
808ce724ee | ||
|
|
ca1db96690 | ||
|
|
a6c20b5ee4 | ||
|
|
e685787e67 | ||
|
|
10b495120e | ||
|
|
559fe2a3bd | ||
|
|
ccec7a182f | ||
|
|
31569c169a | ||
|
|
27a55c3367 | ||
|
|
cda5dc6116 | ||
|
|
5cbd5e92b8 | ||
|
|
1ec3777cb8 | ||
|
|
897919a70f | ||
|
|
76b18b9d39 | ||
|
|
ffcc10f689 | ||
|
|
16cdf3e776 | ||
|
|
dc81ebb855 | ||
|
|
66ecce9a3d | ||
|
|
87867a5904 | ||
|
|
f0b8ee117b | ||
|
|
4c8206b44f | ||
|
|
48c6be2d65 | ||
|
|
71e0eb87ea | ||
|
|
04f94d957a | ||
|
|
7d07f81ec6 | ||
|
|
55bed7e8cd | ||
|
|
e6ac56569c |
No files matched your search
+25
-19
@@ -1,26 +1,32 @@
|
||||
sudo: false
|
||||
|
||||
language: c
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq -y libusb-dev
|
||||
script: if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make ; fi
|
||||
|
||||
addons: &addons
|
||||
apt:
|
||||
packages:
|
||||
- libusb-dev
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- compiler: clang
|
||||
- env: COVERITY_SCAN_BRANCH=1
|
||||
include:
|
||||
- compiler: gcc
|
||||
if: (branch = master) AND (type != pull_request)
|
||||
env:
|
||||
- secure: "JdUp+xFykPZoYA4aRfmYk2CtilLapniQllWPKo2dDdJd1vzdawfTvVxIAKjy7ac9RKwZzg3Chq3RsMEXPv8BtaLbssw266C7RDLMgjacl1eFLcmGRj/Gkk9peDSZ6vVdGEcA2j+6KDSfpCa/XjFjvOufZOgKw6m+3+d0A4G45SI="
|
||||
addons:
|
||||
<<: *addons
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "pali/0xFFFF"
|
||||
description: "Build submitted via Travis CI"
|
||||
notification_email: pali.rohar@gmail.com
|
||||
build_command: make
|
||||
branch_pattern: master
|
||||
|
||||
env:
|
||||
global:
|
||||
- secure: "JdUp+xFykPZoYA4aRfmYk2CtilLapniQllWPKo2dDdJd1vzdawfTvVxIAKjy7ac9RKwZzg3Chq3RsMEXPv8BtaLbssw266C7RDLMgjacl1eFLcmGRj/Gkk9peDSZ6vVdGEcA2j+6KDSfpCa/XjFjvOufZOgKw6m+3+d0A4G45SI="
|
||||
|
||||
addons:
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "pali/0xFFFF"
|
||||
description: "Build submitted via Travis CI"
|
||||
notification_email: pali.rohar@gmail.com
|
||||
build_command: make
|
||||
branch_pattern: master
|
||||
script:
|
||||
- if [ -n "$COVERITY_SCAN_TOKEN" ]; then exit 0; fi
|
||||
- make
|
||||
@@ -23,7 +23,7 @@ R&D mode, changing HW revision strings, ...).
|
||||
by Nokia fiasco-gen.
|
||||
|
||||
Use it with CARE. This is an experimental tool and it can brick your device.
|
||||
It's not suposed to be stable, so nokia will probably release incompatible
|
||||
It's not supposed to be stable, so nokia will probably release incompatible
|
||||
bootloaders to break this tool. USE IT AT YOUR OWN RISK.
|
||||
|
||||
PLEASE. Read carefully all the documentation inside doc/* for more information
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
VERSION = 0.7
|
||||
VERSION = 0.8
|
||||
PREFIX = /usr/local
|
||||
|
||||
# NetBSD stuff
|
||||
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
0xffff (0.8-1) fremantle; urgency=low
|
||||
|
||||
* New upstream version
|
||||
|
||||
-- Pali Rohár <pali.rohar@gmail.com> Sun, 08 Jul 2018 12:43:42 +0200
|
||||
|
||||
0xffff (0.7-1) fremantle; urgency=low
|
||||
|
||||
* New upstream version
|
||||
|
||||
-- Pali Rohár <pali.rohar@gmail.com> Sun, 25 Dec 2016 11:47:44 +0100
|
||||
|
||||
0xffff (0.6.1-1) experimental; urgency=medium
|
||||
|
||||
* New upstream release
|
||||
- Contains a few security related fixes (memory corruptions & leaks)
|
||||
- Support for -t (filter by type) for -e (dump images)
|
||||
- reattach kernel driver
|
||||
- minor fixes
|
||||
|
||||
-- Sebastian Reichel <sre@debian.org> Thu, 11 Dec 2014 21:52:53 +0100
|
||||
|
||||
0xffff (0.6-1) unstable; urgency=low
|
||||
|
||||
* This is new rewritten version of original 0xFFFF 0.5 tool
|
||||
|
||||
-- Pali Rohár <pali.rohar@gmail.com> Sun, 07 Apr 2013 15:01:50 +0200
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
7
|
||||
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
Source: 0xffff
|
||||
Section: user/system
|
||||
Priority: extra
|
||||
Maintainer: Pali Rohár <pali.rohar@gmail.com>
|
||||
Standards-Version: 3.9.8
|
||||
Build-Depends: debhelper (>= 7),
|
||||
libusb-dev
|
||||
Homepage: https://github.com/pali/0xFFFF
|
||||
Vcs-Git: https://github.com/pali/0xFFFF.git
|
||||
Vcs-Browser: https://github.com/pali/0xFFFF/tree/maemo
|
||||
|
||||
Package: 0xffff
|
||||
Architecture: any
|
||||
Depends: ${misc:Depends}, ${shlibs:Depends}, mtd-utils
|
||||
Description: Open Free Fiasco Firmware Flasher
|
||||
The ‘Open Free Fiasco Firmware Flasher’ aka 0xFFFF utility implements
|
||||
a free userspace handler for the NOLO bootloader and extended features
|
||||
for flashing, dumping and getting information for the Nokia Internet
|
||||
Tablets. Thus it's a free alternative to Nokia's closed source flashing
|
||||
utility called flasher.
|
||||
.
|
||||
Supported operations currently include, but are not limited to:
|
||||
* generating and unpacking FIASCO images on local device
|
||||
* editing Maemo firmware packages
|
||||
* flashing any kind image type to Maemo devices via USB
|
||||
* "cold" flashing for devices with bricked bootloaders
|
||||
* direct kernel boot without flashing it to NAND
|
||||
* changing configuration of Maemo device (R&D flags, HW revision strings, ...)
|
||||
.
|
||||
Supported are the Nokia 770, N800, N810, N810w, N900, N950 and N9.
|
||||
XSBC-Maemo-Display-Name: 0xFFFF
|
||||
XB-Maemo-Icon-26:
|
||||
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAGXRFWHRTb2Z0
|
||||
d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACYtJREFUeNrUWkurZUcVXvXY
|
||||
59zbtyXpICEiaFrJQFDo6CDOHAi2UQdOFBw4CAqCDhU0DuIPEBtCRupIBxk4
|
||||
MBMHgpIMnChE1OAD2uADEkFpUM9z710vv7Wq6ty6u09f0+nb3Tcb6u7Hqb33
|
||||
96361qq1al/1vscfp+Ac3fjH6+S9v3owP/iYMfqyMaabz2ax62wwtnPDOPgY
|
||||
ok8pxpQoKKW9UhRC8IFI+UQ4ds7HFKLW1mujffDexRi9MXiGMQG34uborbEO
|
||||
515pckopZ7RxuN8RyflgtBrxfKeNGlNMY0ppxItGUnowSm3Rr7ezubfdnCwe
|
||||
SuMw2EsPPvi9x957+SlrNAXvCCTIWkMKvQP6JEYdorQoG6gkUIpo+SgkStyV
|
||||
SQb0RwOolACOQdBIlAaQ7XGtT4q2lGhDDCjRGsZYg8Qa71sR75WSPe5Z411o
|
||||
doPfN1rrDs/q8MaVVt5Z5T1dnM++8sEPXHnqXzduxOuv/iVutlsGKeCxJbyE
|
||||
jxN2uJc3FfkcJzHviBlG5sq/kUq8D4qvyzWKpQ/fzn94H/Mzub88L0hfJc/w
|
||||
OPc8Ijh3is8xUhqIMZr+woULscMwRmjCwoDdY+959xcXiwX9/KVfRAyV0gYD
|
||||
xTBVeY2mjJuvAR3+aMrgjPRQKtVzrRSDwE1Kl1uEuBADKCX34g5VzKLk/ihk
|
||||
lQBl8CKt3IQA5MMEICttPIY5XDw6gl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+02yKRnl
|
||||
/y1Ezm4EkqzZMAj2Xl0WWLcFaAt+57CTdJjJD/cDfK0HhryEsdvGMiInnHYP
|
||||
+Dq79jU1aMBHukebLbPkuoTRVB24AbwsSx7rPYVIXzPKJh1OdA83Wxx4nYNQ
|
||||
DqGs7zJhtaFyva+KmoCPdI83duKq91iW0nn9vs0qV00hcqsSMNxry7cFzaaA
|
||||
5HqA1/T71KyiVctPqig3qV/vC/hcD2QJLWsWWvKfOgKbAn5qeV+qqPhmqqiz
|
||||
deJs8WVd6yyzabU6E7jJ8qUQSfcbfIlCPOuqKiH+gtKu72wby0sJWAqRcwH+
|
||||
mECCD+yqMLVbpGoKEUmHzxv4UlIalEZhjVosmKT5i2OtA1rLn2kVdbYE+IOS
|
||||
0uyknEp7HfUYVeQlQ65fRTZ3oxA5w2xUeaNpw18tEf99UFHWf/iLSLH8uQVf
|
||||
RyBARltrDaaEEPhbbI408jURmh/TeQWf10ZtF9iRu86mAAImSi4WeLklr5ad
|
||||
X/BCoOsMf/cdZ11HKJ/4HwdiMHyg0/2cYW8nG+X1IDefzxUI8P9ySP2KITj3
|
||||
4PMnpqT4ozZrP3bWxq7rUlmle0tsVv6xgWkg/Bg7IxPr/2K8Nbb/CTAAF12f
|
||||
5l7y6xMAAAAASUVORK5CYII=
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Source: https://github.com/pali/0xFFFF
|
||||
|
||||
Files: *
|
||||
Copyright: 2007-2012 pancake <pancake@youterm.com>
|
||||
2011 Michael Buesch <mb@bu3sch.de>
|
||||
2011-2013 Pali Rohár <pali.rohar@gmail.com>
|
||||
License: GPL-3+
|
||||
This program is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
.
|
||||
On Debian systems, the complete text of the GPL-3 can be found in
|
||||
/usr/share/common-licenses/GPL-3.
|
||||
|
||||
Files: debian/*
|
||||
Copyright: Sebastian Reichel <sre@debian.org>
|
||||
License: ISC
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
doc/
|
||||
TODO
|
||||
README
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_auto_install -- PREFIX=/usr
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
3.0 (quilt)
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
version=3
|
||||
|
||||
opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/0xFFFF-$1\.tar\.gz/,pgpsigurlmangle=s/$/.asc/ \
|
||||
https://github.com/pali/0xFFFF/releases .*/0xffff_(\d\S+)\.orig\.tar\.gz
|
||||
+3
-3
@@ -5,9 +5,9 @@ INSTALL ?= install
|
||||
|
||||
BUILD_DATE ?= $(shell LC_ALL=C date '+%b %e %Y')
|
||||
|
||||
CC = gcc
|
||||
CROSS_CC = $(CROSS_COMPILE)$(CC)
|
||||
HOST_CC = $(HOST_COMPILE)$(CC)
|
||||
CC ?= cc
|
||||
CROSS_CC ?= $(CROSS_COMPILE)$(CC)
|
||||
HOST_CC ?= $(HOST_COMPILE)$(CC)
|
||||
|
||||
CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBUILD_DATE="\"$(BUILD_DATE)\"" -D_POSIX_C_SOURCE=200809L -D_FILE_OFFSET_BITS=64
|
||||
CFLAGS += -W -Wall -O2 -pedantic -std=c99
|
||||
|
||||
@@ -76,14 +76,14 @@ int cal_init_file(const char * file, struct cal ** cal_out) {
|
||||
off_t lsize = 0;
|
||||
#endif
|
||||
|
||||
if ( stat(file, &st) != 0 )
|
||||
return -1;
|
||||
|
||||
fd = open(file, O_RDONLY);
|
||||
|
||||
if ( fd < 0 )
|
||||
return -1;
|
||||
|
||||
if ( fstat(fd, &st) != 0 )
|
||||
goto err;
|
||||
|
||||
if ( S_ISREG(st.st_mode) )
|
||||
size = st.st_size;
|
||||
else if ( S_ISBLK(st.st_mode) ) {
|
||||
|
||||
+79
-32
@@ -51,6 +51,7 @@ int disk_open_dev(int maj, int min, int partition, int readonly) {
|
||||
DIR * dir;
|
||||
struct dirent * dirent;
|
||||
int found;
|
||||
int old_errno;
|
||||
size_t len;
|
||||
char blkdev[1024];
|
||||
|
||||
@@ -117,6 +118,18 @@ int disk_open_dev(int maj, int min, int partition, int readonly) {
|
||||
|
||||
blkdev[len] = 0;
|
||||
|
||||
fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL | O_NONBLOCK);
|
||||
if ( fd < 0 ) {
|
||||
ERROR_INFO("Cannot open block device %s", blkdev);
|
||||
return -1;
|
||||
} else {
|
||||
if ( fstat(fd, &st) != 0 || ! S_ISBLK(st.st_mode) || makedev(maj, min) != st.st_rdev ) {
|
||||
ERROR("Block device %s does not have id %d:%d\n", blkdev, maj, min);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
} else if ( partition > 0 ) {
|
||||
|
||||
/* Select partition */
|
||||
@@ -127,35 +140,48 @@ int disk_open_dev(int maj, int min, int partition, int readonly) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(blkdev+len, "p1", 3);
|
||||
if ( stat(blkdev, &st) != 0 || ! S_ISBLK(st.st_mode) ) {
|
||||
memcpy(blkdev+len, "1", 2);
|
||||
if ( stat(blkdev, &st) != 0 || ! S_ISBLK(st.st_mode) ) {
|
||||
blkdev[len] = 0;
|
||||
fd = open(blkdev, O_RDONLY);
|
||||
if ( fd < 0 ) {
|
||||
if ( errno != ENOMEDIUM ) {
|
||||
ERROR_INFO("Cannot open block device %s", blkdev);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
close(fd);
|
||||
ERROR("Block device does not have partitions");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if ( snprintf(blkdev+len, sizeof(blkdev)-len, "p%d", partition) >= (int)(sizeof(blkdev)-len) ) {
|
||||
ERROR("Block device name is too long");
|
||||
return -1;
|
||||
}
|
||||
fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL);
|
||||
if ( fd < 0 && errno == ENOENT ) {
|
||||
if ( snprintf(blkdev+len, sizeof(blkdev)-len, "%d", partition) >= (int)(sizeof(blkdev)-len) ) {
|
||||
ERROR("Block device name is too long");
|
||||
return -1;
|
||||
}
|
||||
fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL);
|
||||
}
|
||||
if ( fd < 0 && errno == ENOENT ) {
|
||||
blkdev[len] = 0;
|
||||
fd = open(blkdev, O_RDONLY | O_NONBLOCK);
|
||||
if ( fd < 0 ) {
|
||||
ERROR_INFO("Cannot open block device %s", blkdev);
|
||||
} else {
|
||||
close(fd);
|
||||
ERROR("Block device %s does not have partitions", blkdev);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if ( fd < 0 )
|
||||
old_errno = errno;
|
||||
|
||||
printf("Found block device %s for partition %d\n", blkdev, partition);
|
||||
|
||||
}
|
||||
|
||||
fd = open(blkdev, (readonly ? O_RDONLY : O_RDWR) | O_EXCL);
|
||||
|
||||
if ( fd < 0 ) {
|
||||
if ( errno != ENOMEDIUM )
|
||||
if ( fd < 0 ) {
|
||||
errno = old_errno;
|
||||
ERROR_INFO("Cannot open block device %s", blkdev);
|
||||
return -1;
|
||||
} else if ( fstat(fd, &st) != 0 || ! S_ISBLK(st.st_mode) ) {
|
||||
ERROR("Block device %s is not block device\n", blkdev);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
ERROR("Invalid partition %d for block device %s", partition, blkdev);
|
||||
fd = -1;
|
||||
|
||||
}
|
||||
|
||||
return fd;
|
||||
@@ -195,7 +221,7 @@ int disk_dump_dev(int fd, const char * file) {
|
||||
#else
|
||||
|
||||
blksize = lseek(fd, 0, SEEK_END);
|
||||
if ( blksize == (off_t)-1 ) {
|
||||
if ( (off_t)blksize == (off_t)-1 ) {
|
||||
ERROR_INFO("Cannot get size of block device");
|
||||
return -1;
|
||||
}
|
||||
@@ -207,11 +233,6 @@ int disk_dump_dev(int fd, const char * file) {
|
||||
|
||||
#endif
|
||||
|
||||
if ( blksize > ULLONG_MAX ) {
|
||||
ERROR("Block device is too big");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( blksize == 0 ) {
|
||||
ERROR("Block device has zero size");
|
||||
return -1;
|
||||
@@ -281,6 +302,7 @@ int disk_init(struct usb_device_info * dev) {
|
||||
int maj2;
|
||||
int min1;
|
||||
int min2;
|
||||
int tmp;
|
||||
|
||||
maj1 = -1;
|
||||
maj2 = -1;
|
||||
@@ -341,9 +363,17 @@ int disk_init(struct usb_device_info * dev) {
|
||||
|
||||
fclose(f);
|
||||
|
||||
if ( devnum != device->devnum || device->bus->location != busnum )
|
||||
if ( device->devnum != devnum )
|
||||
continue;
|
||||
|
||||
if ( device->bus->location ) {
|
||||
if ( device->bus->location != busnum )
|
||||
continue;
|
||||
} else if ( device->bus->dirname[0] ) {
|
||||
if ( atoi(device->bus->dirname) != (int)busnum )
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( sscanf(dirent->d_name, "%d:%d", &maj2, &min2) != 2 ) {
|
||||
maj2 = -1;
|
||||
min2 = -1;
|
||||
@@ -367,6 +397,16 @@ int disk_init(struct usb_device_info * dev) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Ensure that maj1:min1 is first device and maj2:min2 is second device */
|
||||
if ( min2 != -1 && min2 < min1 ) {
|
||||
tmp = min1;
|
||||
min1 = min2;
|
||||
min2 = tmp;
|
||||
tmp = maj1;
|
||||
maj1 = maj2;
|
||||
maj2 = tmp;
|
||||
}
|
||||
|
||||
/* TODO: change 1 to 0 when disk_flash_dev will be implemented */
|
||||
|
||||
/* RX-51 and RM-680 export MyDocs in first usb device and just first partion, so host system see whole device without MBR table */
|
||||
@@ -378,7 +418,7 @@ int disk_init(struct usb_device_info * dev) {
|
||||
else
|
||||
fd = disk_open_dev(maj1, min1, 1, 1);
|
||||
|
||||
if ( fd < 0 && errno != ENOMEDIUM )
|
||||
if ( fd < 0 )
|
||||
return -1;
|
||||
|
||||
dev->data = fd;
|
||||
@@ -394,6 +434,13 @@ int disk_init(struct usb_device_info * dev) {
|
||||
|
||||
}
|
||||
|
||||
void disk_exit(struct usb_device_info * dev) {
|
||||
|
||||
if ( dev->data >= 0 )
|
||||
close(dev->data);
|
||||
|
||||
}
|
||||
|
||||
enum device disk_get_device(struct usb_device_info * dev) {
|
||||
|
||||
return dev->device;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "usb-device.h"
|
||||
|
||||
int disk_init(struct usb_device_info * dev);
|
||||
void disk_exit(struct usb_device_info * dev);
|
||||
|
||||
enum device disk_get_device(struct usb_device_info * dev);
|
||||
|
||||
|
||||
+27
-14
@@ -162,8 +162,10 @@ static int image_append(struct image * image, const char * type, const char * de
|
||||
image->hash = image_hash_from_data(image);
|
||||
|
||||
image->devices = calloc(1, sizeof(struct device_list));
|
||||
if ( ! image->devices )
|
||||
return -1;
|
||||
if ( ! image->devices ) {
|
||||
image_free(image);
|
||||
ALLOC_ERROR_RETURN(-1);
|
||||
}
|
||||
|
||||
image->devices->device = DEVICE_ANY;
|
||||
|
||||
@@ -244,22 +246,33 @@ static struct image * image_alloc(void) {
|
||||
|
||||
struct image * image_alloc_from_file(const char * file, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout) {
|
||||
|
||||
off_t offset;
|
||||
struct image * image = image_alloc();
|
||||
if ( ! image )
|
||||
return NULL;
|
||||
int fd;
|
||||
|
||||
image->is_shared_fd = 0;
|
||||
image->fd = open(file, O_RDONLY);
|
||||
if ( image->fd < 0 ) {
|
||||
fd = open(file, O_RDONLY);
|
||||
if ( fd < 0 ) {
|
||||
ERROR_INFO("Cannot open image file %s", file);
|
||||
free(image);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return image_alloc_from_fd(fd, file, type, device, hwrevs, version, layout);
|
||||
|
||||
}
|
||||
|
||||
struct image * image_alloc_from_fd(int fd, const char * orig_filename, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout) {
|
||||
|
||||
off_t offset;
|
||||
struct image * image = image_alloc();
|
||||
if ( ! image ) {
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->is_shared_fd = 0;
|
||||
image->fd = fd;
|
||||
|
||||
offset = lseek(image->fd, 0, SEEK_END);
|
||||
if ( offset == (off_t)-1 ) {
|
||||
ERROR_INFO("Cannot seek to end of file %s", file);
|
||||
ERROR_INFO("Cannot seek to end of file %s", orig_filename);
|
||||
close(image->fd);
|
||||
free(image);
|
||||
return NULL;
|
||||
@@ -268,10 +281,10 @@ struct image * image_alloc_from_file(const char * file, const char * type, const
|
||||
image->size = offset;
|
||||
image->offset = 0;
|
||||
image->cur = 0;
|
||||
image->orig_filename = strdup(file);
|
||||
image->orig_filename = strdup(orig_filename);
|
||||
|
||||
if ( lseek(image->fd, 0, SEEK_SET) == (off_t)-1 ) {
|
||||
ERROR_INFO("Cannot seek to begin of file %s", file);
|
||||
ERROR_INFO("Cannot seek to begin of file %s", orig_filename);
|
||||
close(image->fd);
|
||||
free(image->orig_filename);
|
||||
free(image);
|
||||
@@ -282,7 +295,7 @@ struct image * image_alloc_from_file(const char * file, const char * type, const
|
||||
return NULL;
|
||||
|
||||
if ( ( ! type || ! type[0] ) && ( ! device || ! device[0] ) && ( ! hwrevs || ! hwrevs[0] ) && ( ! version || ! version[0] ) )
|
||||
image_missing_values_from_name(image, file);
|
||||
image_missing_values_from_name(image, orig_filename);
|
||||
|
||||
image_align(image);
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ struct image_list {
|
||||
};
|
||||
|
||||
struct image * image_alloc_from_file(const char * file, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout);
|
||||
struct image * image_alloc_from_fd(int fd, const char * orig_filename, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout);
|
||||
struct image * image_alloc_from_shared_fd(int fd, size_t size, size_t offset, uint16_t hash, const char * type, const char * device, const char * hwrevs, const char * version, const char * layout);
|
||||
void image_free(struct image * image);
|
||||
void image_seek(struct image * image, size_t whence);
|
||||
|
||||
+28
-12
@@ -155,16 +155,24 @@ static void parse_image_arg(char * arg, struct image_list ** image_first) {
|
||||
char * version;
|
||||
char * layout;
|
||||
char * layout_file;
|
||||
int fd;
|
||||
|
||||
/* First check if arg is file, then try to parse arg format */
|
||||
if ( stat(arg, &st) == 0 ) {
|
||||
image = image_alloc_from_file(arg, NULL, NULL, NULL, NULL, NULL);
|
||||
if ( ! image ) {
|
||||
ERROR("Cannot load image file %s", arg);
|
||||
exit(1);
|
||||
fd = open(arg, O_RDONLY);
|
||||
if ( fd >= 0 ) {
|
||||
if ( fstat(fd, &st) == 0 && !S_ISDIR(st.st_mode) ) {
|
||||
image = image_alloc_from_fd(fd, arg, NULL, NULL, NULL, NULL, NULL);
|
||||
if ( ! image ) {
|
||||
ERROR("Cannot load image file %s", arg);
|
||||
exit(1);
|
||||
}
|
||||
image_list_add(image_first, image);
|
||||
return;
|
||||
}
|
||||
image_list_add(image_first, image);
|
||||
return;
|
||||
close(fd);
|
||||
} else if ( errno != ENOENT ) {
|
||||
ERROR("Cannot load image file %s", arg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
layout_file = strchr(arg, '%');
|
||||
@@ -1239,6 +1247,8 @@ int main(int argc, char **argv) {
|
||||
if ( chdir(buf) < 0 )
|
||||
ERROR_INFO("Cannot chdir back to %s", buf);
|
||||
|
||||
printf("Done\n");
|
||||
|
||||
}
|
||||
|
||||
/* dump fiasco */
|
||||
@@ -1319,14 +1329,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
for ( i = 0; i < IMAGE_COUNT; ++i ) {
|
||||
|
||||
struct stat st;
|
||||
int rename_ret;
|
||||
int rename_errno;
|
||||
|
||||
if ( ! image_tmp_name(i) )
|
||||
continue;
|
||||
|
||||
if ( stat(image_tmp_name(i), &st) != 0 )
|
||||
continue;
|
||||
|
||||
switch ( i ) {
|
||||
case IMAGE_2ND:
|
||||
case IMAGE_XLOADER:
|
||||
@@ -1357,10 +1365,18 @@ int main(int argc, char **argv) {
|
||||
|
||||
buf[0] = 0;
|
||||
snprintf(buf, sizeof(buf), "%s-%s:%hd_%s", image_type_to_string(i), device_to_string(dev->detected_device), dev->detected_hwrev, ptr);
|
||||
|
||||
rename_ret = rename(image_tmp_name(i), buf);
|
||||
rename_errno = errno;
|
||||
|
||||
if ( rename_ret < 0 && rename_errno == ENOENT )
|
||||
continue;
|
||||
|
||||
printf("Renaming %s image file to %s...\n", image_type_to_string(i), buf);
|
||||
|
||||
if ( rename(image_tmp_name(i), buf) < 0 ) {
|
||||
if ( rename_ret < 0 ) {
|
||||
|
||||
errno = rename_errno;
|
||||
ERROR_INFO("Renaming failed");
|
||||
|
||||
buf[0] = 0;
|
||||
|
||||
+4
-1
@@ -91,8 +91,11 @@ clean:
|
||||
|
||||
void dev_free(struct device_info * dev) {
|
||||
|
||||
if ( dev->usb )
|
||||
if ( dev->usb ) {
|
||||
if ( dev->usb->flash_device->protocol == FLASH_DISK )
|
||||
disk_exit(dev->usb);
|
||||
usb_close_device(dev->usb);
|
||||
}
|
||||
free(dev);
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@
|
||||
|
||||
static struct usb_flash_device usb_devices[] = {
|
||||
{ 0x0421, 0x0096, -1, -1, -1, FLASH_DISK, { DEVICE_RX_44, 0 } },
|
||||
{ 0x0421, 0x0105, 2, 1, -1, FLASH_NOLO, { DEVICE_SU_18, DEVICE_RX_44, DEVICE_RX_48, DEVICE_RX_51, DEVICE_RM_680, DEVICE_RM_696, 0 } },
|
||||
{ 0x0421, 0x0105, 2, 1, -1, FLASH_NOLO, { DEVICE_SU_18, DEVICE_RX_34, DEVICE_RX_44, DEVICE_RX_48, DEVICE_RX_51, DEVICE_RM_680, DEVICE_RM_696, 0 } },
|
||||
{ 0x0421, 0x0106, 0, -1, -1, FLASH_COLD, { DEVICE_RX_51, DEVICE_RM_680, DEVICE_RM_696, 0 } },
|
||||
{ 0x0421, 0x0189, -1, -1, -1, FLASH_DISK, { DEVICE_RX_48, 0 } },
|
||||
{ 0x0421, 0x01c7, -1, -1, -1, FLASH_DISK, { DEVICE_RX_51, 0 } },
|
||||
|
||||
Reference in new issue
Block a user