Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 03776ed710 |
24
.github/build.config
vendored
24
.github/build.config
vendored
@@ -1,24 +0,0 @@
|
||||
#
|
||||
# Build config for pmt workflows
|
||||
#
|
||||
# 2.4.0 config
|
||||
#
|
||||
|
||||
# Version
|
||||
export BUILD_VERSION="2.4.0"
|
||||
|
||||
# Relese tag
|
||||
export BUILD_RELTAG="240"
|
||||
|
||||
# Target architures
|
||||
export BUILD_ARCH="arm64-v8a, armeabi-v7a"
|
||||
|
||||
# NDK environ for getting clang version
|
||||
export NDK="/home/workdir/android-ndk"
|
||||
export TC="${NDK}/toolchains/llvm/prebuilt/linux-x86_64"
|
||||
export TARGET_TEMPLATE="aarch64-linux-android"
|
||||
export API_TEMPLATE="21"
|
||||
export NDK_CLANG="${TC}/bin/${TARGET_TEMPLATE}${API}-clang"
|
||||
|
||||
# get version
|
||||
export CLANG_VERSION=$(${NDK_CLANG} --version | head -n 1)
|
||||
136
ADD-LANGUAGES.md
136
ADD-LANGUAGES.md
@@ -1,136 +0,0 @@
|
||||
### Add a new language to pmt (guide)
|
||||
|
||||
On this page, I will tell you how to add languages to pmt. This is not a difficult thing :)
|
||||
|
||||
##### Send ready stuff
|
||||
- Send ready translations via pull requests. After making the necessary checks, if there is no problem, I will accept it.
|
||||
- Proper commit messages are required.
|
||||
- If there is an error, I will mention it in the pull request comments.
|
||||
- Once you accept it, I (YZBruh) will implement the rest of the necessary things.
|
||||
- It may take 5 days for me to notice :P
|
||||
|
||||
##### Little important notes
|
||||
- You don't have to be a professional to do this thing.
|
||||
- There will be only one place you need to pay attention to, I will explain it.
|
||||
- There is no need to know C.
|
||||
- You can edit existing translations.
|
||||
- You may need ready pmt to understand some things.
|
||||
- If you are on an x86 PC, you can compile and use it, but the functions will never work.
|
||||
|
||||
##### Understanding general logic
|
||||
All the texts (strings) in pmt are like variables in bash. I mean:
|
||||
|
||||
```
|
||||
Bash
|
||||
export missing_operand="missing operand."
|
||||
|
||||
APPLYING:
|
||||
~ $ echo -n "$missing_operand\n" # for more detail I used the -n argument
|
||||
missing operand
|
||||
~ $
|
||||
|
||||
|
||||
C / C++
|
||||
const char* _Nonnull missing_operand = "missing operand.";
|
||||
const std::string missing_operand = "missing operand.";
|
||||
|
||||
APPLYING (C / C++):
|
||||
printf("%s\n", missing_operand); // Move to new line with '\n' character
|
||||
std::cout << missing_operand << std::endl; // Move to new line with std::endl
|
||||
```
|
||||
|
||||
For example, let's take the output directly in pmt without any arguments and process the variables and structures behind the work.
|
||||
|
||||
```
|
||||
Shell
|
||||
~ $ pmt
|
||||
pmt: missing operand
|
||||
Try `pmt --help' for more information.
|
||||
~ $
|
||||
|
||||
Code pieces (C)
|
||||
struct pmt_langdb_general en = {
|
||||
// other translations
|
||||
.missing_operand = "missing operand";
|
||||
.try_h = "Try";
|
||||
.for_more = "for more information";
|
||||
// other translations
|
||||
}
|
||||
|
||||
// pmt code functions [ logging ]
|
||||
LOGE("%s\n%s `%s --help' %s.\n, missing_operand, try_h, argv[0], for_more); // LOGE is error logger (pmt). argv[0] = execution name
|
||||
```
|
||||
|
||||
In short, there are variables for texts. And I made these dynamic by using [struct](https://chatgpt.com/share/a798b57c-7e29-4b17-8887-f230414e57bd) method in C. You just need to add translation :)
|
||||
|
||||
##### Translating main program texts (relevant part)
|
||||
|
||||
- Let's open our jni/languages.c source file.
|
||||
- Now, let's create the translation with the ready-made struct structure (see jni/include/pmt-stringkeys.h for the structure).
|
||||
```
|
||||
// main
|
||||
struct pmt_langdb_general <LANGUAGE_PREFIX> = { // LANGUAGE_PREFIX must be the corresponding abbreviation of the language in English. For example, it's like en in English.
|
||||
// translations
|
||||
}
|
||||
|
||||
// example
|
||||
struct pmt_langdb_general en = {
|
||||
// translation
|
||||
}
|
||||
```
|
||||
- We need to add some information about the language.
|
||||
```
|
||||
struct pmt_langdb_general <LANGUAGE_PREFIX> = {
|
||||
.lang_by_s = // Names of those who made the translation. It's up to you. Do you use & between more than one person?
|
||||
.language = // Language name. For example English
|
||||
.lang_prefix = // Language prefix. For example en
|
||||
// other translations
|
||||
}
|
||||
|
||||
// example
|
||||
struct pmt_langdb_general en = {
|
||||
.lang_by_s = "YZBruh";
|
||||
.language = "English";
|
||||
.lang_prefix = "en";
|
||||
// other translations
|
||||
}
|
||||
|
||||
// CRITIC WARNING: Do not add ';' to the end of the last translation text. But others always
|
||||
```
|
||||
- Now do the others :)
|
||||
- Now let me explain the documentation...
|
||||
|
||||
##### Document texts translation (relevant part)
|
||||
|
||||
- Let's open our jni/languages.c source file.
|
||||
- Now, let's create the translation with the ready-made struct structure (see jni/include/pmt-stringkeys.h for the structure).
|
||||
```
|
||||
struct pmt_langdb_docs <LANGUAGE_PREFIX>_docs = {
|
||||
// translations
|
||||
}
|
||||
|
||||
// example
|
||||
struct pmt_langdb_docs en_docs = {
|
||||
// translations
|
||||
}
|
||||
```
|
||||
- Make translations by taking examples from existing ones. And definitely do it regularly by getting help message from pmt :D
|
||||
|
||||
##### General things to do in translation
|
||||
|
||||
- Open jni/languages.c
|
||||
- Go down a bit...
|
||||
```
|
||||
char* pmt_langdb_langs[] = {
|
||||
"en",
|
||||
"tr"
|
||||
};
|
||||
// Add the language you are translating into these existing language prefixes. I will fix the errors here (if there is an error)
|
||||
|
||||
int pmt_langdb_total = <NUM>; // add one to the existing one and write (replacing with existing)
|
||||
int pmt_langdb_ctrl = <NUM>; // add one to the existing one and write (replacing with existing)
|
||||
```
|
||||
|
||||
##### Notes
|
||||
- Apologies for the crappy current language control structure :(
|
||||
- You can ask your questions: <t.me/YZBruh>
|
||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,7 +1,7 @@
|
||||
### Version 2.4.0 (code 240) changelog
|
||||
- Logging type has been changed.
|
||||
- More understandable syntax.
|
||||
- And one or two more things but I don't remember :P
|
||||
### Version 2.3.0 (code 230) changelog
|
||||
- Fixed some minor bugs in 2.1.0
|
||||
- Added language switching feature (Turkish and English for now).
|
||||
|
||||
| END OF VERSION 2.4.0 CHANGELOG |
|
||||
|
||||
| END OF VERSION 2.3.0 CHANGELOG |
|
||||
|------------------------------------|
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
### Supported languages
|
||||
|
||||
- Türkçe (Turkish) (TR)
|
||||
- English (EN)
|
||||
10
README.md
10
README.md
@@ -27,25 +27,23 @@ Examples:
|
||||
pmt format ext4 system_a --logical
|
||||
pmt -c /dev/block/platform/bootdevice/by-name --list
|
||||
|
||||
Report bugs to <t.me / ShawkTeam | Community / Topics -- pmt>
|
||||
Report bugs to <t.me/YZBruh>
|
||||
```
|
||||
|
||||
#### Some notes
|
||||
|
||||
- pmt supports multiple languages. [See languages.](https://github.com/ShawkTeam/pmt/blob/2.4.0/LANGUAGES.md)
|
||||
- [Add language.](https://github.com/ShawkTeam/pmt/blob/2.4.0/ADD-LANGUAGES.md)
|
||||
- Feel free to ask any questions you want.
|
||||
- Packages are available in publications.
|
||||
- If the logical partition flag is not used, a classic partition is tried to be processing by default.
|
||||
- [Click to see special version changes.](https://github.com/ShawkTeam/pmt/blob/2.4.0/CHANGELOG.md)
|
||||
- We are always open to your suggestions and support (developing)!
|
||||
- [Click to see special version changes](https://github.com/YZBruh/pbt/blob/2.3.0/CHANGELOG.md)
|
||||
- Let me know your suggestions!
|
||||
|
||||
### How is it built?
|
||||
Android NDK is required to build.
|
||||
- [Download](https://developer.android.com/ndk/downloads) and extract the NDK package.
|
||||
- Clone this repository. And get access to it.
|
||||
```
|
||||
git clone https://github.com/ShawkTeam/pmt -b 2.4.0
|
||||
git clone https://github.com/YZBruh/pbt -b 2.3.0 ./pmt
|
||||
cd pmt
|
||||
```
|
||||
- Set the NDK working directory variable.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Source: pmt
|
||||
Package: pmt
|
||||
Version: 2.4.0
|
||||
Version: 2.3.0
|
||||
Architecture: arm
|
||||
Description: pmt is for reading, writing and formatting partitions of android devices
|
||||
Section: misc
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Source: pmt
|
||||
Package: pmt
|
||||
Version: 2.4.0
|
||||
Version: 2.3.0
|
||||
Architecture: aarch64
|
||||
Description: pmt is for reading, writing and formatting partitions of android devices
|
||||
Section: misc
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
# By YZBruh | ShawkTeam
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
@@ -18,12 +18,13 @@ LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(LOCAL_PATH)/config/env.mk
|
||||
|
||||
PMT_CFLAGS = -O3 -std=c11 -Wall $(EXTRA_COMPILER_FLAGS)
|
||||
|
||||
ifeq ($(ENABLE_DEBUGGING), true)
|
||||
PMT_CFLAGS += -g -Wextra
|
||||
PMT_CFLAGS := -O3 -g -Wall -Wextra $(EXTRA_COMPILER_FLAGS)
|
||||
else ifeq ($(ENABLE_DEBUGGING), false)
|
||||
PMT_CFLAGS := -O3 -Wall $(EXTRA_COMPILER_FLAGS)
|
||||
else
|
||||
$(warning Unknown debugging flag: $(ENABLE_DEBUGGING). Please see: src/config/env.mk. Using non-debugging flags)
|
||||
$(warning Unknown debugging flag: $(ENABLE_DEBUGGING). Please see: $(PREDIR)/config/env.mk. Using non-debugging flags)
|
||||
PMT_CFLAGS := -O3 -Wall $(EXTRA_COMPILER_FLAGS)
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
@@ -37,8 +38,8 @@ include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpmt_debugging
|
||||
LOCAL_SRC_FILES := debugging.c
|
||||
LOCAL_MODULE := libpmt_error
|
||||
LOCAL_SRC_FILES := error.c
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
@@ -68,7 +69,6 @@ LOCAL_MODULE := pmt
|
||||
LOCAL_SRC_FILES := \
|
||||
pmt.c \
|
||||
versioner.c \
|
||||
get_stat.c \
|
||||
tools.c \
|
||||
lang_tools.c \
|
||||
languages.c \
|
||||
@@ -76,7 +76,7 @@ LOCAL_SRC_FILES := \
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
LOCAL_STATIC_LIBRARIES := \
|
||||
libpmt_root \
|
||||
libpmt_debugging \
|
||||
libpmt_error \
|
||||
libpmt_partitiontool \
|
||||
libpmt_list
|
||||
LOCAL_CFLAGS := $(PMT_CFLAGS)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# By YZBruh | ShawkTeam
|
||||
# By YZBruh
|
||||
|
||||
# Copyright 2024 Partition Manager
|
||||
#
|
||||
@@ -23,4 +23,4 @@ APP_PLATFORM := android-21
|
||||
|
||||
APP_OPTIM := release
|
||||
|
||||
# end
|
||||
# end
|
||||
@@ -1,79 +0,0 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
|
||||
#include <pmt.h>
|
||||
|
||||
extern char* bin_name;
|
||||
extern bool pmt_silent;
|
||||
|
||||
extern struct pmt_langdb_general* current;
|
||||
extern struct pmt_langdb_general en;
|
||||
extern struct pmt_langdb_general tr;
|
||||
|
||||
void debug(LogLevel status, const char* _Nullable fmt, ...)
|
||||
{
|
||||
if (fmt == NULL) exit(1);
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case LOG_LEVEL_ERR:
|
||||
if (!pmt_silent)
|
||||
{
|
||||
fprintf(stderr, "%s: ", bin_name);
|
||||
vfprintf(stderr, fmt, args);
|
||||
}
|
||||
exit(1);
|
||||
break;
|
||||
case LOG_LEVEL_WARN:
|
||||
if (!pmt_silent)
|
||||
{
|
||||
fprintf(stderr, "%s: ", current->warn);
|
||||
vfprintf(stderr, fmt, args);
|
||||
}
|
||||
break;
|
||||
case LOG_LEVEL_FATAL:
|
||||
if (!pmt_silent)
|
||||
{
|
||||
fprintf(stderr, "%s: ", current->fatal);
|
||||
vfprintf(stderr, fmt, args);
|
||||
}
|
||||
abort();
|
||||
break;
|
||||
case LOG_LEVEL_DEBUG:
|
||||
if (!pmt_silent)
|
||||
vfprintf(stdout, fmt, args);
|
||||
break;
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
10
jni/docs.c
10
jni/docs.c
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/*
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -38,10 +38,8 @@ prepare_langconf_docs(void)
|
||||
static char* langctrl_str;
|
||||
langctrl_str = loadlang();
|
||||
|
||||
if (strcmp(langctrl_str, "en") == 0)
|
||||
curr_docs = &en_docs;
|
||||
else if (strcmp(langctrl_str, "tr") == 0)
|
||||
curr_docs = &tr_docs;
|
||||
if (strcmp(langctrl_str, "en") == 0) curr_docs = &en_docs;
|
||||
else if (strcmp(langctrl_str, "tr") == 0) curr_docs = &tr_docs;
|
||||
}
|
||||
|
||||
void licenses(void)
|
||||
@@ -78,7 +76,7 @@ void help(void)
|
||||
printf(" %s flash /sdcard/twrp/boot.img boot_a -c /dev/block/platform/bootdevice/by-name\n", bin_name);
|
||||
printf(" %s format ext4 system_a --logical\n", bin_name);
|
||||
printf(" %s -c /dev/block/platform/bootdevice/by-name --list\n\n", bin_name);
|
||||
printf("%s <t.me / ShawkTeam | Community / Topics -- pmt>\n", curr_docs->docs_strs_l15);
|
||||
printf("%s <t.me/YZBruh>\n", curr_docs->docs_strs_l15);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
42
jni/error.c
Executable file
42
jni/error.c
Executable file
@@ -0,0 +1,42 @@
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
|
||||
#include <pmt.h>
|
||||
|
||||
__noreturn void error(int __status, const char* _Nullable __fmt, ...)
|
||||
{
|
||||
if (__fmt == NULL) exit(__status);
|
||||
|
||||
va_list err_args;
|
||||
va_start(err_args, __fmt);
|
||||
fprintf(stderr, "%s: ", bin_name);
|
||||
vfprintf(stderr, __fmt, err_args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(err_args);
|
||||
exit(__status);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
@@ -1,78 +0,0 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INC_MAIN_LIBS
|
||||
#define INC_STAT
|
||||
|
||||
#include <pmt.h>
|
||||
|
||||
/**
|
||||
* The target file is controlled by the stat function.
|
||||
* Files, directories, links and blocks (disks) are for.
|
||||
* If it is never found, it returns 1 value.
|
||||
* If he finds 0 value is returned.
|
||||
* If the desired type is not in -1 value is returned.
|
||||
*/
|
||||
int get_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
||||
{
|
||||
static struct stat get_stat;
|
||||
|
||||
if (stat(filepath, &get_stat) != 0)
|
||||
return 1;
|
||||
|
||||
if (strcmp(stype, "dir") == 0)
|
||||
{
|
||||
if (S_ISDIR(get_stat.st_mode))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else if (strcmp(stype, "file") == 0)
|
||||
{
|
||||
if (S_ISREG(get_stat.st_mode))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else if (strcmp(stype, "blk") == 0)
|
||||
{
|
||||
if (S_ISBLK(get_stat.st_mode))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else if (strcmp(stype, "link") == 0)
|
||||
{
|
||||
if (S_ISLNK(get_stat.st_mode))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
@@ -62,8 +62,6 @@ struct pmt_langdb_general {
|
||||
const char* _Nonnull see_license;
|
||||
const char* _Nonnull success_backup;
|
||||
const char* _Nonnull success_flash;
|
||||
const char* _Nonnull warn;
|
||||
const char* _Nonnull fatal;
|
||||
const char* _Nonnull switching_lang;
|
||||
const char* _Nonnull welcome;
|
||||
const char* _Nullable welcome_;
|
||||
|
||||
@@ -34,7 +34,7 @@ __BEGIN_DECLS
|
||||
|
||||
/* versioning */
|
||||
#define PMT_MAJOR 2
|
||||
#define PMT_MINOR 4
|
||||
#define PMT_MINOR 3
|
||||
#define PMT_PATCHLEVEL 0
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -49,6 +49,11 @@ __BEGIN_DECLS
|
||||
|
||||
#if defined(INC_DEBUGERS)
|
||||
#include <errno.h>
|
||||
|
||||
/* from <err.h>. Modified. */
|
||||
__noreturn void error(int __status, const char* _Nullable __fmt, ...);
|
||||
void warning(const char* _Nullable __fmt, ...) __printflike(1, 2);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(INC_PMT_LANGS)
|
||||
@@ -95,14 +100,6 @@ extern struct pmt_langdb_general tr;
|
||||
extern struct pmt_langdb_docs en_docs;
|
||||
extern struct pmt_langdb_docs tr_docs;
|
||||
|
||||
/* logging levels */
|
||||
typedef enum {
|
||||
LOG_LEVEL_FATAL,
|
||||
LOG_LEVEL_ERR,
|
||||
LOG_LEVEL_WARN,
|
||||
LOG_LEVEL_DEBUG
|
||||
} LogLevel;
|
||||
|
||||
/* function definations */
|
||||
int listpart(void);
|
||||
void check_dev_point(void);
|
||||
@@ -112,13 +109,6 @@ void version(void);
|
||||
void setlang(const char* _Nonnull lang);
|
||||
int search_sls(void);
|
||||
char* _Nonnull loadlang(void);
|
||||
void debug(LogLevel status, const char* _Nullable fmt, ...);
|
||||
|
||||
/* logging macros */
|
||||
#define LOGF(fmt, ...) debug(LOG_LEVEL_FATAL, fmt, ##__VA_ARGS__)
|
||||
#define LOGE(fmt, ...) debug(LOG_LEVEL_ERR, fmt, ##__VA_ARGS__)
|
||||
#define LOGW(fmt, ...) debug(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
|
||||
#define LOGD(fmt, ...) debug(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -53,11 +53,48 @@ extern int pmt_langdb_ctrl;
|
||||
|
||||
FILE *langconf;
|
||||
|
||||
/**
|
||||
* The target file is controlled by the stat function.
|
||||
* Files, directories, links and blocks (disks) are for.
|
||||
* If it is never found, it returns 1 value.
|
||||
* If he finds 0 value is returned.
|
||||
* If the desired type is not in -1 value is returned.
|
||||
*/
|
||||
static int
|
||||
search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
||||
{
|
||||
struct stat search_stat;
|
||||
|
||||
if (stat(filepath, &search_stat) != 0) return 1;
|
||||
|
||||
if (strcmp(stype, "dir") == 0)
|
||||
{
|
||||
if (S_ISDIR(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "file") == 0)
|
||||
{
|
||||
if (S_ISREG(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "blk") == 0)
|
||||
{
|
||||
if (S_ISBLK(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "link") == 0)
|
||||
{
|
||||
if (S_ISLNK(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
langctrl(const char* _Nonnull lang_)
|
||||
{
|
||||
if (strcmp(lang_, "en") == 0 || strcmp(lang_, "tr") == 0)
|
||||
return 0;
|
||||
if (strcmp(lang_, "en") == 0 || strcmp(lang_, "tr") == 0) return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -67,12 +104,11 @@ char* loadlang(void)
|
||||
static char lang_fpr[10] = "en";
|
||||
langconf = NULL;
|
||||
|
||||
if (get_stat(TERMUX_PMT_MANDOC, "file") == 0)
|
||||
pmt_inst_on_termux = true;
|
||||
if (search_stat(TERMUX_PMT_MANDOC, "file") == 0) pmt_inst_on_termux = true;
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
{
|
||||
if (get_stat(TERMUX_PMTLANG_CONF, "file") == 0)
|
||||
if (search_stat(TERMUX_PMTLANG_CONF, "file") == 0)
|
||||
{
|
||||
langconf = fopen(TERMUX_PMTLANG_CONF, "r+");
|
||||
|
||||
@@ -108,7 +144,7 @@ char* loadlang(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (get_stat(INTRNL_PMTLANG_CONF, "file") == 0)
|
||||
if (search_stat(INTRNL_PMTLANG_CONF, "file") == 0)
|
||||
{
|
||||
langconf = fopen(INTRNL_PMTLANG_CONF, "r");
|
||||
|
||||
@@ -151,47 +187,35 @@ void setlang(const char* _Nonnull lang)
|
||||
{
|
||||
static char* lcf_path;
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
lcf_path = TERMUX_PMTLANG_CONF;
|
||||
else
|
||||
lcf_path = INTRNL_PMTLANG_CONF;
|
||||
if (pmt_inst_on_termux) lcf_path = TERMUX_PMTLANG_CONF;
|
||||
else lcf_path = INTRNL_PMTLANG_CONF;
|
||||
|
||||
if (get_stat(lcf_path, "file") == 0)
|
||||
remove(lcf_path);
|
||||
if (search_stat(lcf_path, "file") == 0) remove(lcf_path);
|
||||
|
||||
langconf = NULL;
|
||||
if (pmt_inst_on_termux) langconf = fopen(TERMUX_PMTLANG_CONF, "w");
|
||||
else langconf = fopen(INTRNL_PMTLANG_CONF, "w");
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
langconf = fopen(TERMUX_PMTLANG_CONF, "w");
|
||||
else
|
||||
langconf = fopen(INTRNL_PMTLANG_CONF, "w");
|
||||
|
||||
if (langconf == NULL)
|
||||
LOGE("Failed!!! Cannot open/write config file.\n");
|
||||
if (langconf == NULL) error(1, "%s: Failed!!! Cannot open/write config file.\n", bin_name);
|
||||
|
||||
if (langctrl(lang) == 0)
|
||||
{
|
||||
if (fprintf(langconf, "%s", lang) < 2)
|
||||
LOGE("Failed!!! Couldn't write config!\n");
|
||||
else
|
||||
fclose(langconf);
|
||||
if (fprintf(langconf, "%s", lang) < 2) error(1, "Failed!!! Couldn't write config!\n");
|
||||
else fclose(langconf);
|
||||
}
|
||||
else
|
||||
LOGE("Unknown language: %s.\n", lang);
|
||||
else error(1, "Unknown language: %s.", bin_name, lang);
|
||||
|
||||
static int status;
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
{
|
||||
status = open(TERMUX_PMT_SW_POINT, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (status == 0)
|
||||
close(status);
|
||||
if (status == 0) close(status);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = open(INTRNL_PMT_SW_POINT, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (status == 0)
|
||||
close(status);
|
||||
if (status == 0) close(status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,22 +223,19 @@ int search_sls(void)
|
||||
{
|
||||
static char* sw_point_path;
|
||||
|
||||
if (pmt_inst_on_termux)
|
||||
sw_point_path = TERMUX_PMT_SW_POINT;
|
||||
else
|
||||
sw_point_path = INTRNL_PMT_SW_POINT;
|
||||
if (pmt_inst_on_termux) sw_point_path = TERMUX_PMT_SW_POINT;
|
||||
else sw_point_path = INTRNL_PMT_SW_POINT;
|
||||
|
||||
if (get(sw_point_path, "file") == 0)
|
||||
if (search_stat(sw_point_path, "file") == 0)
|
||||
{
|
||||
remove(sw_point_path);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
/* end of code */
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -25,51 +25,49 @@ extern "C" {
|
||||
#include <pmt.h>
|
||||
|
||||
struct pmt_langdb_general en = {
|
||||
.lang_by_s = "YZBruh & r0manas",
|
||||
.lang_by_s = "YZBruh",
|
||||
.language = "English",
|
||||
.lang_prefix = "en",
|
||||
.not_logical = "This device does not have logical partitions!",
|
||||
.not_file = "is not a file.",
|
||||
.not_dir = "is not a directory.",
|
||||
.not_in_dev = "Nothing found in /dev. Use force mode to avoid this error.",
|
||||
.not_open = "Couldn't open",
|
||||
.not_block = "The specified partition is not recognized as a block device.",
|
||||
.not_file = "is a not file.",
|
||||
.not_dir = "is a not directory.",
|
||||
.not_in_dev = "You're going through my wave? There's nothing about this /dev. Use force mode if you don't want this error.",
|
||||
.not_open = "Could not open",
|
||||
.not_block = "The specified partition is not the block. I mean, it's not actually an episode (disc). I'm sure it needs to applaud those mistakes.",
|
||||
.not_read = "Couldn't read",
|
||||
.not_write = "Couldn't write",
|
||||
.not_gen = "Couldn't generate",
|
||||
.no_root = "Root access could not be detected! Please run this with root permissions.",
|
||||
.no_target = "No target specified (backup, flash, or format).",
|
||||
.no_root = "Root access could not be detected! Please run this binary with root.",
|
||||
.no_target = "No target (backup, flash or format).",
|
||||
.expected_backup_arg = "Expected backup argument 2 (1 of them are not mandatory), retrieved",
|
||||
.expected_flash_arg = "Expected flash argument 2, retrieved",
|
||||
.expected_format_arg = "Expected format argument 2, retrieved",
|
||||
.missing_operand = "Missing operand",
|
||||
.multiple_wiewers = "Multiple viewers can't be used on the same line.",
|
||||
.common_symbol_rule = "When specifying arguments for an option, ensure they do not begin with '-'. Each argument must correspond correctly to its respective option.",
|
||||
.req_part_name = "Partition name required.",
|
||||
.missing_operand = "missing operand",
|
||||
.multiple_wiewers = "Multiple viewers cannot be used at the same line.",
|
||||
.common_symbol_rule = "When entering the attached argument of an option, an argument of another option type cannot be used. In short, the rule is: there can be no '-' at the beginning of the attached argument.",
|
||||
.req_part_name = "Required partition name.",
|
||||
.part_not_found = "Partition not found!",
|
||||
.unsupported_fs = "Formatter: unsupported filesystem",
|
||||
.cannot_stat = "Can't retrieve file status",
|
||||
.ffile_more_part = "Flash file size exceeds partition capacity.",
|
||||
.cannot_get_bsz = "Failed to retrieve partition block size.",
|
||||
.format_fail = "Formatting failed! There is a possibility of data damage.",
|
||||
.logical_warn = "This device uses logical partitions.",
|
||||
.ab_warn = "This device uses A/B partition style.",
|
||||
.out_not_spec = "Output file name not specified. Using default name:",
|
||||
.please_rerun = "Please rerun the command.",
|
||||
.part_disk_sz = "Partition disk size",
|
||||
.flash_file_sz = "Flash file size",
|
||||
.part_disk_sz_fail = "Failed to retrieve partition disk size.",
|
||||
.flash_file_sz_fail = "Failed to retrieve flash file size.",
|
||||
.list_of_dir = "Directory listing",
|
||||
.see_license = "View licenses using the -L argument.",
|
||||
.success_backup = "Backup successful. Output:",
|
||||
.success_flash = "Flash successful.",
|
||||
.warn = "WARNING",
|
||||
.fatal = "FATAL ERROR",
|
||||
.cannot_stat = "Cannot stat",
|
||||
.ffile_more_part = "Size of the file to flash more than the partition size.",
|
||||
.cannot_get_bsz = "The partition block size could not be obtained!",
|
||||
.format_fail = "Formatting failed! There may be a chance that something has been damaged!",
|
||||
.logical_warn = "Warning: device using logical partition type.",
|
||||
.ab_warn = "Warning: device using A/B partition style.",
|
||||
.out_not_spec = "Warning: The output file name was not specified. The output file name will be",
|
||||
.please_rerun = "Please re run",
|
||||
.part_disk_sz = "Disk size of the partition",
|
||||
.flash_file_sz = "Size of flash file",
|
||||
.part_disk_sz_fail = "Warning: failed to get target partition disk size",
|
||||
.flash_file_sz_fail = "Warning: failed to get flash file size.",
|
||||
.list_of_dir = "List of dir",
|
||||
.see_license = "See licenses with -L argument.",
|
||||
.success_backup = "Success. Output",
|
||||
.success_flash = "Success.",
|
||||
.switching_lang = "Switching language...",
|
||||
.welcome = "language!",
|
||||
.welcome_ = "Welcome to ",
|
||||
.for_more = "for more information",
|
||||
.for_more = "for more information.",
|
||||
.try_h = "Try",
|
||||
.usage_head = "Usage",
|
||||
.compiler_str = "Compiler",
|
||||
@@ -119,8 +117,6 @@ struct pmt_langdb_general tr = {
|
||||
.see_license = "Lisansı -L seçeneği ile görüntüleyebilirsiniz.",
|
||||
.success_backup = "Başarılı. Çıktı",
|
||||
.success_flash = "Başarılı.",
|
||||
.warn = "UYARI",
|
||||
.fatal = "KRİTİK HATA",
|
||||
.switching_lang = "Dil değiştiriliyor...",
|
||||
.welcome = "diline hoş geldiniz!",
|
||||
.welcome_ = NULL,
|
||||
@@ -135,9 +131,9 @@ struct pmt_langdb_general tr = {
|
||||
};
|
||||
|
||||
struct pmt_langdb_docs en_docs = {
|
||||
.docs_strs_l1 = "backup PARTITION [OUTPUT] [OPTIONS]...",
|
||||
.docs_strs_l2 = "flash FILE PARTITION [OPTIONS]...",
|
||||
.docs_strs_l3 = "format FILE_SYSTEM[ext/2/3/4] PARTITION [OPTIONS]...",
|
||||
.docs_strs_l1 = "[OPTIONS] backup PARTITION [OUTPUT] [OPTIONS]...",
|
||||
.docs_strs_l2 = "[OPTIONS] flash FILE PARTITION [OPTIONS]...",
|
||||
.docs_strs_l3 = "[OPTIONS] format FILE_SYSTEM[ext/2/3/4] PARTITION [OPTIONS]...",
|
||||
.docs_strs_l4 = "Options",
|
||||
.docs_strs_l5 = "It is meant to determine whether the target partition is logical.",
|
||||
.docs_strs_l6 = "It is meant to specify a custom /dev context. Only classic partitions (default: /dev/block/by-name).",
|
||||
@@ -155,9 +151,9 @@ struct pmt_langdb_docs en_docs = {
|
||||
};
|
||||
|
||||
struct pmt_langdb_docs tr_docs = {
|
||||
.docs_strs_l1 = "backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
|
||||
.docs_strs_l2 = "flash DOSYA BÖLÜM [SEÇENEKLER]...",
|
||||
.docs_strs_l3 = "format DOSYA_SİSTEMİ[ext/2/3/4] BÖLÜM [SEÇENEKLER]...",
|
||||
.docs_strs_l1 = "[SEÇENEKLER] backup BÖLÜM [ÇIKTI] [SEÇENEKLER]...",
|
||||
.docs_strs_l2 = "[SEÇENEKLER] flash DOSYA BÖLÜM [SEÇENEKLER]...",
|
||||
.docs_strs_l3 = "[SEÇENEKLER] format DOSYA_SİSTEMİ[ext/2/3/4] BÖLÜM [SEÇENEKLER]...",
|
||||
.docs_strs_l4 = "Seçenekler",
|
||||
.docs_strs_l5 = "Bu seçeneği kullanarak mantıksal (logical) bir bölümle işlem yapılacağını belirtebilirsiniz.",
|
||||
.docs_strs_l6 = "Bu seçeneği kullanarak özel /dev bağlamı belirtebilirsiniz. Sadece normal (mantıksal olmayan) bölümler içindir (Varsayılan: /dev/block/by-name).",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -53,15 +53,11 @@ list(const char* operation, const char* target_dir)
|
||||
struct dirent *entry;
|
||||
dir = NULL;
|
||||
|
||||
if (strcmp(operation, "access") == 0)
|
||||
list = false;
|
||||
else if (strcmp(operation, "print") == 0)
|
||||
list = true;
|
||||
else
|
||||
return -1;
|
||||
if (strcmp(operation, "access") == 0) list = false;
|
||||
else if (strcmp(operation, "print") == 0) list = true;
|
||||
else return -1;
|
||||
|
||||
dir = opendir(target_dir);
|
||||
|
||||
if (dir != NULL)
|
||||
{
|
||||
if (!list)
|
||||
@@ -71,62 +67,51 @@ list(const char* operation, const char* target_dir)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGD("%s: `%s'\n", current->list_of_dir, target_dir);
|
||||
while ((entry = readdir(dir)) != NULL)
|
||||
{
|
||||
LOGD("%s\n", entry->d_name);
|
||||
}
|
||||
printf("%s: `%s'\n", current->list_of_dir, target_dir);
|
||||
while ((entry = readdir(dir)) != NULL) printf("%s\n", entry->d_name);
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
else return -1;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* list existing partitions */
|
||||
int listpart(void)
|
||||
{
|
||||
int listpart(void) {
|
||||
if (pmt_use_cust_cxt)
|
||||
{
|
||||
if (list("access", cust_cxt) != 0)
|
||||
{
|
||||
if (!pmt_force_mode)
|
||||
LOGE("%s: `%s': %s\n", current->not_open, cust_cxt, strerror(errno));
|
||||
else
|
||||
return 1;
|
||||
if (!pmt_force_mode) error(1, "%s: `%s': %s", current->not_open, cust_cxt, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
else
|
||||
list("print", cust_cxt);
|
||||
else list("print", cust_cxt);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list("access", CUR_DEV_CNTX) != 0)
|
||||
{
|
||||
if (!pmt_force_mode)
|
||||
LOGE("%s: `%s': %s\n", current->not_open, CUR_DEV_CNTX, strerror(errno));
|
||||
else
|
||||
return 1;
|
||||
if (!pmt_force_mode) error(1, "%s: `%s': %s", current->not_open, CUR_DEV_CNTX, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
else
|
||||
list("print", CUR_DEV_CNTX);
|
||||
else list("print", CUR_DEV_CNTX);
|
||||
}
|
||||
|
||||
if (pmt_logical)
|
||||
{
|
||||
if (list("access", LGC_DEV_CNTX) != 0)
|
||||
LOGE("%s: `%s': %s\n", current->not_open, LGC_DEV_CNTX, strerror(errno));
|
||||
else
|
||||
list("print", LGC_DEV_CNTX);
|
||||
{
|
||||
if (!pmt_silent) error(1, "%s: `%s': %s", current->not_open, LGC_DEV_CNTX, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
else list("print", LGC_DEV_CNTX);
|
||||
}
|
||||
|
||||
if (pmt_ab)
|
||||
LOGD("%s: %s\n", bin_name, current->ab_warn);
|
||||
if (pmt_ab && !pmt_silent) printf("%s: %s\n", bin_name, current->ab_warn);
|
||||
|
||||
if (pmt_logical)
|
||||
LOGD("%s: %s\n", bin_name, current->logical_warn);
|
||||
if (pmt_logical && !pmt_silent) printf("%s: %s\n", bin_name, current->logical_warn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -135,4 +120,4 @@ int listpart(void)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* end of code */
|
||||
/* end of code */
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -30,7 +30,7 @@ extern bool pmt_logical;
|
||||
extern char* cust_cxt;
|
||||
|
||||
static int
|
||||
accf(const char* _Nonnull target) { return access(target, F_OK); }
|
||||
search(const char* _Nonnull target) { return access(target, F_OK); }
|
||||
|
||||
/* check parts */
|
||||
void check_dev_point()
|
||||
@@ -40,18 +40,13 @@ void check_dev_point()
|
||||
{
|
||||
static char cust_cxt_ck_path[150];
|
||||
sprintf(cust_cxt_ck_path, "%s/boot_a", cust_cxt);
|
||||
|
||||
if (accf(cust_cxt_ck_path) != 0)
|
||||
pmt_ab = false;
|
||||
else
|
||||
pmt_ab = true;
|
||||
if (search(cust_cxt_ck_path) != 0) pmt_ab = false;
|
||||
else pmt_ab = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accf("/dev/block/by-name/boot_a") != 0)
|
||||
pmt_ab = false;
|
||||
else
|
||||
pmt_ab = true;
|
||||
if (search("/dev/block/by-name/boot_a") != 0) pmt_ab = false;
|
||||
else pmt_ab = true;
|
||||
}
|
||||
|
||||
/* true = logical | false = classic */
|
||||
@@ -59,18 +54,13 @@ void check_dev_point()
|
||||
{
|
||||
static char cust_cxt_ckl_path[150];
|
||||
sprintf(cust_cxt_ckl_path, "%s/super", cust_cxt);
|
||||
|
||||
if (accf(cust_cxt_ckl_path) != 0)
|
||||
pmt_logical = false;
|
||||
else
|
||||
pmt_logical = true;
|
||||
if (search(cust_cxt_ckl_path) != 0) pmt_logical = false;
|
||||
else pmt_logical = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (accf("/dev/block/by-name/super") != 0)
|
||||
pmt_logical = false;
|
||||
else
|
||||
pmt_logical = true;
|
||||
if (search("/dev/block/by-name/super") != 0) pmt_logical = false;
|
||||
else pmt_logical = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,4 +68,4 @@ void check_dev_point()
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* end */
|
||||
/* end */
|
||||
169
jni/pmt.c
169
jni/pmt.c
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -68,13 +68,49 @@ check_optsym(const char* _Nonnull mystring)
|
||||
{
|
||||
if (strncmp(mystring, opt_symbol, 1) == 0)
|
||||
{
|
||||
if (!pmt_force_mode)
|
||||
LOGE("%s\n", common_symbol_rule);
|
||||
else
|
||||
exit(1);
|
||||
if (!pmt_force_mode) error(1, "%s", common_symbol_rule);
|
||||
else exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The target file is controlled by the stat function.
|
||||
* Files, directories, links and blocks (disks) are for.
|
||||
* If it is never found, it returns 1 value.
|
||||
* If he finds 0 value is returned.
|
||||
* If the desired type is not in -1 value is returned.
|
||||
*/
|
||||
static int
|
||||
search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
||||
{
|
||||
struct stat search_stat;
|
||||
|
||||
if (stat(filepath, &search_stat) != 0) return 0;
|
||||
|
||||
if (strcmp(stype, "dir") == 0)
|
||||
{
|
||||
if (S_ISDIR(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "file") == 0)
|
||||
{
|
||||
if (S_ISREG(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "blk") == 0)
|
||||
{
|
||||
if (S_ISBLK(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "link") == 0)
|
||||
{
|
||||
if (S_ISLNK(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* classic main function (C binary here xd) */
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
@@ -84,24 +120,19 @@ int main(int argc, char* argv[])
|
||||
static char* langctrl_str;
|
||||
langctrl_str = loadlang();
|
||||
|
||||
if (strcmp(langctrl_str, "en") == 0)
|
||||
current = &en;
|
||||
else if (strcmp(langctrl_str, "tr") == 0)
|
||||
current = &tr;
|
||||
if (strcmp(langctrl_str, "en") == 0) current = &en;
|
||||
else if (strcmp(langctrl_str, "tr") == 0) current = &tr;
|
||||
|
||||
sprintf(common_symbol_rule, "%s\n", current->common_symbol_rule);
|
||||
|
||||
if (search_sls() == 0)
|
||||
{
|
||||
if (current->welcome_ != NULL)
|
||||
LOGD("%s", current->welcome_);
|
||||
|
||||
LOGD("%s %s %s %s.\n", current->language, current->welcome, current->by_str, current->lang_by_s);
|
||||
if (current->welcome_ != NULL) printf("%s", current->welcome_);
|
||||
printf("%s %s %s %s.\n", current->language, current->welcome, current->by_str, current->lang_by_s);
|
||||
}
|
||||
|
||||
/* check argument total */
|
||||
if (argc < 2)
|
||||
LOGE("%s\n%s `%s --help' %s.\n", current->missing_operand, current->try_h, argv[0], current->for_more);
|
||||
if (argc < 2) error(1, "%s\n%s `%s --help' %s.", current->missing_operand, current->try_h, argv[0], current->for_more);
|
||||
|
||||
/* a structure for long arguments */
|
||||
struct option long_options[] = {
|
||||
@@ -140,16 +171,22 @@ int main(int argc, char* argv[])
|
||||
case 'l':
|
||||
check_root();
|
||||
check_dev_point();
|
||||
if (pmt_logical)
|
||||
pmt_use_logical = true;
|
||||
if (pmt_logical) pmt_use_logical = true;
|
||||
else
|
||||
LOGE("%s\n", current->not_logical);
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s", current->not_logical);
|
||||
else return 1;
|
||||
}
|
||||
break;
|
||||
/* context selector option */
|
||||
case 'c':
|
||||
pmt_use_cust_cxt = true;
|
||||
cust_cxt = strdup(optarg);
|
||||
check_optsym(cust_cxt);
|
||||
if (strncmp(cust_cxt, opt_symbol, 1) == 0)
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s", common_symbol_rule);
|
||||
else return 1;
|
||||
}
|
||||
break;
|
||||
/* partition lister function */
|
||||
case 'p':
|
||||
@@ -190,18 +227,17 @@ int main(int argc, char* argv[])
|
||||
break;
|
||||
/* for invalid options */
|
||||
case '?':
|
||||
LOGD("%s `%s --help' %s\n", current->try_h, argv[0], current->for_more);
|
||||
printf("%s `%s --help' %s\n", current->try_h, argv[0], current->for_more);
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
LOGD("%s: %s [backup] [flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", current->usage_head, argv[0]);
|
||||
printf("%s: %s [backup] [flash] [format] [-l | --logical] [-c | --context] [-D | --list] [-v | --version] [--help] [-L | --license]\n", current->usage_head, argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* stop the program if multiple viewer is used */
|
||||
if (combo_wiewers)
|
||||
LOGE("%s", current->multiple_wiewers);
|
||||
if (combo_wiewers) error(1, "%s", current->multiple_wiewers);
|
||||
|
||||
/* controller to handle viewer */
|
||||
if (wiew_help)
|
||||
@@ -227,10 +263,10 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (pmt_setlang)
|
||||
{
|
||||
LOGD("%s: %s\n", argv[0], current->switching_lang);
|
||||
printf("%s: %s\n", argv[0], current->switching_lang);
|
||||
setlang(langpr);
|
||||
sleep(2);
|
||||
LOGD("%s: %s.\n", argv[0], current->please_rerun);
|
||||
printf("%s: %s.\n", argv[0], current->please_rerun);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -249,7 +285,10 @@ int main(int argc, char* argv[])
|
||||
check_getvar_temp++;
|
||||
|
||||
if (argc < check_getvar_temp)
|
||||
LOGE("%s 0.\n", current->expected_backup_arg);
|
||||
{
|
||||
if (!pmt_silent) error(1, "%s 0.", current->expected_backup_arg);
|
||||
else return 1;
|
||||
}
|
||||
|
||||
target_partition = argv[getvar_temp];
|
||||
|
||||
@@ -264,7 +303,6 @@ int main(int argc, char* argv[])
|
||||
check_optsym(out);
|
||||
|
||||
pmt_backup = true;
|
||||
|
||||
break;
|
||||
}
|
||||
else if (strcmp(argv[argtest], "flash") == 0)
|
||||
@@ -272,10 +310,16 @@ int main(int argc, char* argv[])
|
||||
check_getvar_temp++;
|
||||
|
||||
if (argc < check_getvar_temp)
|
||||
LOGE("%s 0.\n", current->expected_flash_arg);
|
||||
{
|
||||
if (!pmt_force_mode || !pmt_silent) error(1, "%s 0.", current->expected_flash_arg);
|
||||
else return 1;
|
||||
}
|
||||
|
||||
if (argc == check_getvar_temp)
|
||||
LOGE("%s 1.\n", current->expected_flash_arg);
|
||||
{
|
||||
if (!pmt_force_mode || !pmt_silent) error(1, "%s 1.", current->expected_flash_arg);
|
||||
else return 1;
|
||||
}
|
||||
|
||||
target_flash_file = argv[getvar_temp];
|
||||
|
||||
@@ -286,7 +330,6 @@ int main(int argc, char* argv[])
|
||||
check_optsym(target_partition);
|
||||
|
||||
pmt_flash = true;
|
||||
|
||||
break;
|
||||
}
|
||||
else if (strcmp(argv[argtest], "format") == 0)
|
||||
@@ -294,10 +337,16 @@ int main(int argc, char* argv[])
|
||||
check_getvar_temp++;
|
||||
|
||||
if (argc < check_getvar_temp)
|
||||
LOGE("%s 0.\n", current->expected_format_arg);
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s 0.", current->expected_format_arg);
|
||||
else return 1;
|
||||
}
|
||||
|
||||
if (argc == check_getvar_temp)
|
||||
LOGE("%s 1.\n", current->expected_format_arg);
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s 1.", current->expected_format_arg);
|
||||
else return 1;
|
||||
}
|
||||
|
||||
format_fs = argv[getvar_temp];
|
||||
|
||||
@@ -308,14 +357,13 @@ int main(int argc, char* argv[])
|
||||
check_optsym(target_partition);
|
||||
|
||||
pmt_format = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* target control is done */
|
||||
if (!pmt_backup && !pmt_flash && !pmt_format)
|
||||
LOGE("%s `%s --help` %s\n", current->missing_operand, current->try_h, current->for_more);
|
||||
if (!pmt_backup && !pmt_flash && !pmt_format && !pmt_silent) error(1, "%s\n%s `%s --help` %s", argv[0], current->missing_operand, current->try_h, current->for_more);
|
||||
else return 1;
|
||||
|
||||
/* checks */
|
||||
check_root();
|
||||
@@ -324,37 +372,54 @@ int main(int argc, char* argv[])
|
||||
if (pmt_format)
|
||||
{
|
||||
if (strcmp(format_fs, "ext4") != 0 || strcmp(format_fs, "ext3") != 0 || strcmp(format_fs, "ext2") != 0)
|
||||
LOGE("%s: %s\n", current->unsupported_fs, format_fs);
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s: %s", current->unsupported_fs, format_fs);
|
||||
else return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (pmt_flash)
|
||||
{
|
||||
search_result = get_stat(target_flash_file, "file");
|
||||
search_result = search_stat(target_flash_file, "file");
|
||||
|
||||
if (search_result == 1)
|
||||
LOGE("%s `%s': %s\n", current->cannot_stat, target_flash_file, strerror(errno));
|
||||
{
|
||||
if (!pmt_silent) error(1, "%s `%s': %s", current->cannot_stat, target_flash_file, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
else if (search_result == -1)
|
||||
LOGE("`%s': %s\n", target_flash_file, current->not_file);
|
||||
{
|
||||
if (!pmt_silent) error(1, "`%s': %s", target_flash_file, current->not_file);
|
||||
else return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* custom context checker */
|
||||
if (pmt_use_cust_cxt)
|
||||
{
|
||||
search_result = get_stat(cust_cxt, "dir");
|
||||
search_result = search_stat(cust_cxt, "dir");
|
||||
|
||||
if (search_result == 1)
|
||||
LOGE("%s `%s': %s\n", current->cannot_stat, cust_cxt, strerror(errno));
|
||||
{
|
||||
if (!pmt_silent) error(1, "%s `%s': %s", current->cannot_stat, cust_cxt, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
else if (search_result == -1)
|
||||
LOGE("`%s': %s\n", cust_cxt, current->not_dir);
|
||||
{
|
||||
if (!pmt_silent) error(1, "`%s': %s", cust_cxt, current->not_dir);
|
||||
else return 1;
|
||||
}
|
||||
|
||||
if (strstr(cust_cxt, "/dev") == NULL && !pmt_force_mode)
|
||||
LOGE("%s\n", current->not_in_dev);
|
||||
if (strstr(cust_cxt, "/dev") == NULL && !pmt_force_mode) error(1, "%s", current->not_in_dev);
|
||||
}
|
||||
|
||||
if (target_partition == NULL)
|
||||
{
|
||||
if (!pmt_force_mode)
|
||||
LOGE("%s\n%s `%s --help' %s\n", current->req_part_name, current->try_h, argv[0], current->for_more);
|
||||
{
|
||||
if (!pmt_silent) error(1, "%s\n%s `%s --help' %s", current->req_part_name, current->try_h, argv[0], current->for_more);
|
||||
}
|
||||
else return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -365,14 +430,10 @@ int main(int argc, char* argv[])
|
||||
*
|
||||
* 3 = format
|
||||
*/
|
||||
if (pmt_backup)
|
||||
return pmt(1);
|
||||
else if (pmt_flash)
|
||||
return pmt(2);
|
||||
else if (pmt_format)
|
||||
return pmt(3);
|
||||
else
|
||||
LOGE("%s\n%s `%s --help' %s\n", current->no_target, current->try_h, argv[0], current->for_more);
|
||||
if (pmt_backup) return pmt(1);
|
||||
else if (pmt_flash) return pmt(2);
|
||||
else if (pmt_format) return pmt(3);
|
||||
else if (!pmt_silent) error(1, "%s\n%s `%s --help' %s", current->no_target, current->try_h, argv[0], current->for_more);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,4 +441,4 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
/* end of code */
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -34,7 +34,10 @@ void check_root(void)
|
||||
{
|
||||
/* a quick, easy method for verifying root */
|
||||
if (getuid() != 0)
|
||||
LOGE("%s\n", current->no_root);
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s", current->no_root);
|
||||
else exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
166
jni/tools.c
166
jni/tools.c
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -34,7 +34,6 @@ extern char* cust_cxt;
|
||||
extern char* target_partition;
|
||||
extern char* target_flash_file;
|
||||
extern char* partition_type;
|
||||
extern char* bin_name;
|
||||
extern bool pmt_use_logical;
|
||||
extern bool pmt_use_cust_cxt;
|
||||
extern bool pmt_logical;
|
||||
@@ -56,16 +55,13 @@ calc_flsz(const char* _Nonnull filepath)
|
||||
{
|
||||
static int calc_flsz_file;
|
||||
calc_flsz_file = open(filepath, O_RDONLY);
|
||||
|
||||
if (calc_flsz_file == -1)
|
||||
return calc_flsz_file;
|
||||
if (calc_flsz_file == -1) return calc_flsz_file;
|
||||
|
||||
static off_t flsz;
|
||||
flsz = lseek(calc_flsz_file, 0, SEEK_END);
|
||||
close(calc_flsz_file);
|
||||
|
||||
if (flsz == (off_t)-1)
|
||||
return -1;
|
||||
if (flsz == (off_t)-1) return -1;
|
||||
|
||||
return (double)flsz / (1024 * 1024);
|
||||
}
|
||||
@@ -74,25 +70,64 @@ calc_flsz(const char* _Nonnull filepath)
|
||||
* error that the partition is not found.
|
||||
* It's for quick action.
|
||||
*/
|
||||
static void
|
||||
partition_not_found(void) { LOGE("%s\n", current->part_not_found); }
|
||||
static int
|
||||
partition_not_found(void)
|
||||
{
|
||||
if (!pmt_silent) error(1, "%s", current->part_not_found);
|
||||
else return 1;
|
||||
}
|
||||
|
||||
/* to stop use of function type */
|
||||
#define partition_not_found partition_not_found()
|
||||
|
||||
/**
|
||||
* The target file is controlled by the stat function.
|
||||
* Files, directories, links and blocks (disks) are for.
|
||||
* If it is never found, it returns 1 value.
|
||||
* If he finds 0 value is returned.
|
||||
* If the desired type is not in -1 value is returned.
|
||||
*/
|
||||
static int
|
||||
search_stat(const char* _Nonnull filepath, const char* _Nonnull stype)
|
||||
{
|
||||
struct stat search_stat;
|
||||
|
||||
if (stat(filepath, &search_stat) != 0) return 1;
|
||||
|
||||
if (strcmp(stype, "dir") == 0)
|
||||
{
|
||||
if (S_ISDIR(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "file") == 0)
|
||||
{
|
||||
if (S_ISREG(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "blk") == 0)
|
||||
{
|
||||
if (S_ISBLK(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
else if (strcmp(stype, "link") == 0)
|
||||
{
|
||||
if (S_ISLNK(search_stat.st_mode)) return 0;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* the partitions are meant to quickly find. */
|
||||
static void
|
||||
search_partition(const char* _Nonnull partition)
|
||||
{
|
||||
static int partition_results = 0;
|
||||
partition_results = get_stat(partition, "blk");
|
||||
partition_results = search_stat(partition, "blk");
|
||||
|
||||
if (partition_results == 1)
|
||||
partition_not_found;
|
||||
else if (partition_results == -1)
|
||||
LOGE("%s\n", current->not_block);
|
||||
if (partition_results == 1) partition_not_found;
|
||||
else if (partition_results == -1 && !pmt_silent) error(1, "%s", current->not_block);
|
||||
else exit(1);
|
||||
}
|
||||
|
||||
int pmt(unsigned short progress_code)
|
||||
@@ -113,37 +148,37 @@ int pmt(unsigned short progress_code)
|
||||
{
|
||||
if (!pmt_use_logical)
|
||||
{
|
||||
if (pmt_use_cust_cxt)
|
||||
sprintf(backupper_path, "%s/%s", cust_cxt, target_partition);
|
||||
else
|
||||
sprintf(backupper_path, "/dev/block/by-name/%s", target_partition);
|
||||
if (pmt_use_cust_cxt) sprintf(backupper_path, "%s/%s", cust_cxt, target_partition);
|
||||
else sprintf(backupper_path, "/dev/block/by-name/%s", target_partition);
|
||||
}
|
||||
else
|
||||
sprintf(backupper_path, "/dev/block/mapper/%s", target_partition);
|
||||
else if (pmt_use_logical) sprintf(backupper_path, "/dev/block/mapper/%s", target_partition);
|
||||
|
||||
search_partition(backupper_path);
|
||||
|
||||
if (calc_flsz(backupper_path) != -1)
|
||||
LOGD("%s: %.2f\n", current->part_disk_sz, calc_flsz(backupper_path));
|
||||
else
|
||||
LOGW("%s\n", current->part_disk_sz_fail);
|
||||
if (calc_flsz(backupper_path) != -1 && !pmt_silent) printf("%s: %.2f\n", current->part_disk_sz, calc_flsz(backupper_path));
|
||||
else if (!pmt_silent) warning("%s", current->part_disk_sz_fail);
|
||||
|
||||
srcf = open(backupper_path, O_RDONLY);
|
||||
if (srcf == -1)
|
||||
LOGE("%s: %s: %s\n", current->not_read, backupper_path, strerror(errno));
|
||||
{
|
||||
if (!pmt_silent) error(1, "%s: %s: %s", current->not_read, backupper_path, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
|
||||
/* determine output */
|
||||
if (strcmp(out, target_partition) == 0)
|
||||
{
|
||||
sprintf(outf, "%s.img", target_partition);
|
||||
LOGW("%s: %s\n", current->out_not_spec, outf);
|
||||
if (!pmt_silent) warning("%s: %s", current->out_not_spec, outf);
|
||||
}
|
||||
else
|
||||
sprintf(outf, "%s", target_partition);
|
||||
else sprintf(outf, "%s", target_partition);
|
||||
|
||||
targetf = open(outf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (targetf == -1)
|
||||
LOGE("%s: %s: %s\n", current->not_gen, outf, strerror(errno));
|
||||
{
|
||||
if (!pmt_silent) error(1, "%s: %s: %s", current->not_gen, outf, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
|
||||
/* start writing */
|
||||
while ((readed_data = read(srcf, buffer, BFSIZE)) > 0 && copied_data < count)
|
||||
@@ -151,9 +186,11 @@ int pmt(unsigned short progress_code)
|
||||
ssize_t writed_data = write(targetf, buffer, readed_data);
|
||||
if (writed_data != readed_data)
|
||||
{
|
||||
if (get_stat(outf, "file") == 0)
|
||||
remove(outf);
|
||||
LOGF("%s: %s: %s\n", current->not_write, backupper_path, strerror(errno));
|
||||
if (!pmt_silent) warning("%s: %s: %s", current->not_write, backupper_path, strerror(errno));
|
||||
close(srcf);
|
||||
close(targetf);
|
||||
if (search_stat(outf, "file") == 0) remove(outf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
copied_data += writed_data;
|
||||
@@ -163,7 +200,7 @@ int pmt(unsigned short progress_code)
|
||||
close(srcf);
|
||||
close(targetf);
|
||||
|
||||
LOGD("%s: %s\n", current->success_backup, outf);
|
||||
if (!pmt_silent) printf("%s: %s\n", current->success_backup, outf);
|
||||
}
|
||||
else if (progress_code == 2)
|
||||
{
|
||||
@@ -171,45 +208,49 @@ int pmt(unsigned short progress_code)
|
||||
/* for classic */
|
||||
if (!pmt_use_logical)
|
||||
{
|
||||
if (pmt_use_cust_cxt)
|
||||
sprintf(flasher_path, "%s/%s", cust_cxt, target_partition);
|
||||
else
|
||||
sprintf(flasher_path, "/dev/block/by-name/%s", target_partition);
|
||||
if (pmt_use_cust_cxt) sprintf(flasher_path, "%s/%s", cust_cxt, target_partition);
|
||||
else sprintf(flasher_path, "/dev/block/by-name/%s", target_partition);
|
||||
/* for logical */
|
||||
}
|
||||
else
|
||||
sprintf(flasher_path, "/dev/block/mapper/%s", target_partition);
|
||||
else if (pmt_use_logical) sprintf(flasher_path, "/dev/block/mapper/%s", target_partition);
|
||||
|
||||
/* check partition */
|
||||
search_partition(flasher_path);
|
||||
|
||||
if (calc_flsz(target_flash_file) != -1)
|
||||
LOGD("%s: %.2f\n", current->flash_file_sz, calc_flsz(target_flash_file));
|
||||
else
|
||||
LOGW("%s\n", current->flash_file_sz_fail);
|
||||
if (calc_flsz(target_flash_file) != -1 && !pmt_force_mode) printf("%s: %.2f\n", current->flash_file_sz, calc_flsz(target_flash_file));
|
||||
else warning("%s", current->flash_file_sz_fail);
|
||||
|
||||
if (calc_flsz(target_partition) != -1)
|
||||
LOGD("%s: %.2f\n", current->part_disk_sz, calc_flsz(target_partition));
|
||||
else
|
||||
LOGW("%s\n", current->part_disk_sz_fail);
|
||||
if (calc_flsz(target_partition) != -1 && !pmt_force_mode) printf("%s: %.2f\n", current->part_disk_sz, calc_flsz(target_partition));
|
||||
else warning("%s", current->part_disk_sz_fail);
|
||||
|
||||
if (calc_flsz(target_flash_file) > calc_flsz(target_partition))
|
||||
LOGE("%s\n", current->ffile_more_part);
|
||||
if (calc_flsz(target_flash_file) > calc_flsz(target_partition) && !pmt_silent) error(1, "%s", current->ffile_more_part);
|
||||
else return 1;
|
||||
|
||||
srcf = open(target_flash_file, O_RDONLY);
|
||||
if (srcf == -1)
|
||||
LOGF("%s: %s: %s\n", current->not_read, target_flash_file, strerror(errno));
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s: %s: %s", current->not_read, target_flash_file, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
|
||||
targetf = open(target_partition, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (targetf == -1)
|
||||
LOGF("%s: %s: %s\n", current->not_read, target_partition, strerror(errno));
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s: %s: %s", current->not_read, target_partition, strerror(errno));
|
||||
else return 1;
|
||||
}
|
||||
|
||||
/* start writing */
|
||||
while ((readed_data = read(srcf, buffer, BFSIZE)) > 0 && copied_data < count)
|
||||
{
|
||||
ssize_t writed_data = write(targetf, buffer, readed_data);
|
||||
if (writed_data != readed_data)
|
||||
LOGF("%s: %s: %s\n", current->not_write, backupper_path, strerror(errno));
|
||||
{
|
||||
warning("%s: %s: %s", current->not_write, backupper_path, strerror(errno));
|
||||
close(srcf);
|
||||
close(targetf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
copied_data += writed_data;
|
||||
}
|
||||
@@ -217,21 +258,18 @@ int pmt(unsigned short progress_code)
|
||||
close(srcf);
|
||||
close(targetf);
|
||||
|
||||
LOGD("%s.\n", current->success_flash);
|
||||
if (!pmt_force_mode) printf("%s.\n", current->success_flash);
|
||||
}
|
||||
else if (progress_code == 3)
|
||||
{
|
||||
/* generate partition extn */
|
||||
if (!pmt_use_logical)
|
||||
{
|
||||
if (pmt_use_cust_cxt)
|
||||
sprintf(ppath, "%s/%s", cust_cxt, target_partition);
|
||||
else
|
||||
sprintf(ppath, "/dev/block/by-name/%s", target_partition);
|
||||
if (pmt_use_cust_cxt) sprintf(ppath, "%s/%s", cust_cxt, target_partition);
|
||||
else sprintf(ppath, "/dev/block/by-name/%s", target_partition);
|
||||
/* for logical */
|
||||
}
|
||||
else
|
||||
sprintf(ppath, "/dev/block/mapper/%s", target_partition);
|
||||
else if (pmt_use_logical) sprintf(ppath, "/dev/block/mapper/%s", target_partition);
|
||||
|
||||
/* check partition */
|
||||
search_partition(ppath);
|
||||
@@ -239,14 +277,20 @@ int pmt(unsigned short progress_code)
|
||||
/* get target partition block size */
|
||||
struct statvfs file_sys_inf;
|
||||
if (statvfs(ppath, &file_sys_inf) != 0)
|
||||
LOGE("%s\n", current->cannot_get_bsz);
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s", current->cannot_get_bsz);
|
||||
else return 1;
|
||||
}
|
||||
|
||||
/* generate mke2fs command */
|
||||
sprintf(formatter_cmd, "mke2fs -Fq -t %s -b %lu %s", format_fs, file_sys_inf.f_bsize, ppath);
|
||||
|
||||
/* run command */
|
||||
if (system(formatter_cmd) != 0)
|
||||
LOGF("%s\n", current->format_fail);
|
||||
{
|
||||
if (!pmt_force_mode) error(1, "%s", current->format_fail);
|
||||
else return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* By YZBruh | ShawkTeam */
|
||||
/* By YZBruh */
|
||||
|
||||
/**
|
||||
* Copyright 2024 Partition Manager
|
||||
@@ -33,25 +33,25 @@ extern struct pmt_langdb_general tr;
|
||||
|
||||
void version(void)
|
||||
{
|
||||
LOGD("%s %s %d.%d.%d (%d%d%d) ", bin_name, current->version_str, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL);
|
||||
printf("%s %s %d.%d.%d (%d%d%d) ", bin_name, current->version_str, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL, PMT_MAJOR, PMT_MINOR, PMT_PATCHLEVEL);
|
||||
|
||||
#if __SIZEOF_POINTER__ == 4
|
||||
LOGD("32-bit %s\n", current->bin_str);
|
||||
printf("32-bit %s\n", current->bin_str);
|
||||
#elif __SIZEOF_POINTER__ == 8
|
||||
LOGD("64-bit %s\n", current->bin_str);
|
||||
printf("64-bit %s\n", current->bin_str);
|
||||
#else
|
||||
LOGD("<%s> %s\n", current->unknw_str, current->bin_str);
|
||||
printf("<%s> %s\n", current->unknw_str, current->bin_str);
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
LOGD("%s: clang %d.%d.%d (NDK r%d%s %s)\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__, __NDK_MAJOR__, __NDK_MINOR_STATUS__, __NDK_BETA_STATUS__);
|
||||
printf("%s: clang %d.%d.%d (NDK r%d%s %s)\n", current->compiler_str, __clang_major__, __clang_minor__, __clang_patchlevel__, __NDK_MAJOR__, __NDK_MINOR_STATUS__, __NDK_BETA_STATUS__);
|
||||
#endif
|
||||
|
||||
LOGD("%s\n", current->see_license);
|
||||
printf("%s\n", current->see_license);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of code */
|
||||
/* end of code */
|
||||
Reference in New Issue
Block a user