Skip to content

Commit

Permalink
src:fix delete file issue
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoming <[email protected]>
  • Loading branch information
QQxiaoming committed Aug 7, 2023
1 parent 96790f4 commit 22699ed
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 32 deletions.
4 changes: 2 additions & 2 deletions build_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ QT_DIR=/opt/Qt6.2.0/6.2.0/gcc_64

# 定义版本号
QFSVIEWER_MAJARVERSION="0"
QFSVIEWER_SUBVERSION="0"
QFSVIEWER_REVISION="3"
QFSVIEWER_SUBVERSION="1"
QFSVIEWER_REVISION="0"
###############################################################################


Expand Down
4 changes: 2 additions & 2 deletions build_dmg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ QT_DIR=/opt/Qt6.2.0/6.2.0/gcc_64

# 定义版本号
QFSVIEWER_MAJARVERSION="0"
QFSVIEWER_SUBVERSION="0"
QFSVIEWER_REVISION="3"
QFSVIEWER_SUBVERSION="1"
QFSVIEWER_REVISION="0"
###############################################################################


Expand Down
2 changes: 1 addition & 1 deletion build_setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set "QT_TOOLS_DIR=C:/Qt/Qt6.2.0/Tools/mingw810_32/bin"
:: 定义Inno Setup目录
set "INNO_SETUP_DIR=C:/Program Files (x86)/Inno Setup 6"
:: 定义版本号
set "QFSVIEWER_VERSION=0.0.3"
set "QFSVIEWER_VERSION=0.1.0"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Expand Down
31 changes: 11 additions & 20 deletions lib/jffs2/jffs2extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,17 +767,7 @@ uint16_t jffs2_compress( unsigned char *data_in, unsigned char **cpage_out,
uint32_t *datalen, uint32_t *cdatalen)
{
int ret = JFFS2_COMPR_NONE;
int compr_ret;
unsigned char *output_buf = NULL, *tmp_buf;
uint32_t orig_slen, orig_dlen;
uint32_t best_slen=0, best_dlen=0;

//switch (jffs2_compression_mode) {
// case JFFS2_COMPR_MODE_NONE:
// break;
// default:
// break;
//}
unsigned char *output_buf = NULL;

if (ret == JFFS2_COMPR_NONE) {
*cpage_out = data_in;
Expand All @@ -789,21 +779,22 @@ uint16_t jffs2_compress( unsigned char *data_in, unsigned char **cpage_out,
return ret;
}

static uint64_t pre_pad_block(uint64_t offset, int req, int add_cleanmarkers, int erase_block_size)
static uint64_t pre_pad_block(uint64_t offset, uint32_t req, uint32_t add_cleanmarkers, uint32_t erase_block_size)
{
const static unsigned char ffbuf[16] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff
};
static struct jffs2_unknown_node cleanmarker = {0};
static int cleanmarker_size = sizeof(cleanmarker);
const struct jffs2_unknown_node cleanmarker = {
.magic = {0}, .nodetype = {0}, .totlen = {0}, .hdr_crc = {0}};
const int cleanmarker_size = sizeof(cleanmarker);

if(erase_block_size) {
if (add_cleanmarkers) {
if ((offset % erase_block_size) == 0) {
memcpy(ram_disk_data + offset, &cleanmarker, sizeof(cleanmarker));
offset += sizeof(cleanmarker);
int req = cleanmarker_size - sizeof(cleanmarker);
unsigned int req = cleanmarker_size - sizeof(cleanmarker);
while (req) {
if (req > sizeof(ffbuf)) {
memcpy(ram_disk_data + offset, ffbuf, sizeof(ffbuf));
Expand Down Expand Up @@ -832,7 +823,7 @@ static uint64_t pre_pad_block(uint64_t offset, int req, int add_cleanmarkers, in
if ((offset % erase_block_size) == 0) {
memcpy(ram_disk_data + offset, &cleanmarker, sizeof(cleanmarker));
offset += sizeof(cleanmarker);
int req = cleanmarker_size - sizeof(cleanmarker);
uint32_t req = cleanmarker_size - sizeof(cleanmarker);
while (req) {
if (req > sizeof(ffbuf)) {
memcpy(ram_disk_data + offset, ffbuf, sizeof(ffbuf));
Expand Down Expand Up @@ -887,7 +878,7 @@ void write_dir(const char *name, uint32_t pino, uint32_t ino, uint32_t timestamp
rd.pino = cpu_to_je32(pino);
rd.version = cpu_to_je32(1);
rd.ino = cpu_to_je32(ino);
rd.mctime = cpu_to_je32(0);//st_mtime
rd.mctime = cpu_to_je32(timestamp);//st_mtime
rd.nsize = strlen(name);
rd.type = 4;
//rd.unused[0] = 0;
Expand Down Expand Up @@ -982,7 +973,7 @@ void write_file(const char *name, const unsigned char *buff, size_t size,
} else {
unsigned char *tbuf = (unsigned char *)buff;
uint32_t ver = 0, woff = 0;
unsigned char *buf, *cbuf, *wbuf;
unsigned char *cbuf, *wbuf;
while (size) {
uint32_t dsize, space;
uint16_t compression;
Expand All @@ -1004,8 +995,8 @@ void write_file(const char *name, const unsigned char *buff, size_t size,
ri.totlen = cpu_to_je32(sizeof(ri) + space);
ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
&ri, sizeof(struct jffs2_unknown_node) - 4));

ri.version = cpu_to_je32(++ver);
++ver;
ri.version = cpu_to_je32(ver);
ri.offset = cpu_to_je32(woff);
ri.csize = cpu_to_je32(space);
ri.dsize = cpu_to_je32(dsize);
Expand Down
2 changes: 1 addition & 1 deletion partform_unix.pri
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###############################################################################
# 定义版本号路径
QFSVIEWER_VERSION=0.0.3
QFSVIEWER_VERSION=0.1.0
###############################################################################
2 changes: 1 addition & 1 deletion partform_win32.pri
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###############################################################################
# 定义版本号路径
QFSVIEWER_VERSION=0.0.3
QFSVIEWER_VERSION=0.1.0
###############################################################################
3 changes: 2 additions & 1 deletion src/fsviewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ int Ext4FSViewModel::fs_create_dir(QString path) {
}

int Ext4FSViewModel::fs_remove_dir(QString path) {
ext4_dir_rm(path.toStdString().c_str());
int ret = ext4_dir_rm(path.toStdString().c_str());
qDebug() << ret;
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions src/qfsviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class FSViewWindow : public QTreeView
QMessageBox::critical(this, tr("Error"), tr("Unsupported operation!"));
return;
}
if(size != 0) {
if(type == FSViewModel::FSView_DIR && size != 0) {
QMessageBox::critical(this, tr("Error"), tr("Now only support delete empty dir!"));
return;
}
Expand All @@ -411,9 +411,9 @@ class FSViewWindow : public QTreeView
QFileInfo info(this->windowTitle());
int ret = -1;
if(fsView) {
if(type != FSViewModel::FSView_DIR ) {
if(type == FSViewModel::FSView_DIR ) {
ret = fsView->removeDirFSImg(path);
} else if(type != FSViewModel::FSView_REG_FILE) {
} else if(type == FSViewModel::FSView_REG_FILE) {
ret = fsView->removeFileFSImg(path);
}
if(ret == 0) {
Expand All @@ -424,7 +424,7 @@ class FSViewWindow : public QTreeView
}
}
if(ret == 0) {
QMessageBox::information(this, tr("Information"), tr("Delete dir success!"));
QMessageBox::information(this, tr("Information"), tr("Delete success!"));
} else {
QMessageBox::critical(this, tr("Error"), tr("Unsupported operation!"));
}
Expand Down

0 comments on commit 22699ed

Please sign in to comment.