pmt: apply version 1.7.0 changes
This commit is contained in:
@@ -1,10 +1,3 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#include "include/common.h"
|
|
||||||
|
|
||||||
/* By YZBruh */
|
/* By YZBruh */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -23,41 +16,76 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern char *cust_cxt;
|
#ifdef __cplusplus
|
||||||
extern bool use_cust_cxt;
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
|
#include "include/pmt.h"
|
||||||
|
|
||||||
|
extern bool pmt_use_cust_cxt;
|
||||||
extern bool pmt_ab;
|
extern bool pmt_ab;
|
||||||
extern bool pmt_logical;
|
extern bool pmt_logical;
|
||||||
|
extern bool pmt_force_mode;
|
||||||
|
extern char *cust_cxt;
|
||||||
|
|
||||||
/* list existing partitions */
|
/* list existing partitions */
|
||||||
void listpart() {
|
void listpart() {
|
||||||
if (use_cust_cxt) {
|
DIR *dir;
|
||||||
printf("List of classic partitions (%s): \n", cust_cxt);
|
struct dirent *entry;
|
||||||
static char cust_cxt_path[150];
|
|
||||||
sprintf(cust_cxt_path, "ls %s", cust_cxt);
|
if (pmt_use_cust_cxt) {
|
||||||
if (system(cust_cxt_path) != 0) {
|
dir = opendir(cust_cxt);
|
||||||
error("An error occurred when the partition list appears!\n");
|
if (dir == NULL) {
|
||||||
|
if (!pmt_force_mode) {
|
||||||
|
fprintf(stderr, "Could not open: `%s`. Error reason: %s\n", cust_cxt, strerror(errno));
|
||||||
|
exit(62);
|
||||||
|
} else {
|
||||||
|
exit(62);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("List of classic partitions (/dev/block/by-name): \n");
|
dir = opendir("/dev/block/by-name");
|
||||||
if (system("ls /dev/block/by-name") != 0) {
|
if (dir == NULL) {
|
||||||
error("An error occurred when the classic partition list appears!\n");
|
if (!pmt_force_mode) {
|
||||||
|
fprintf(stderr, "Could not open: `/dev/block/by-name`. Error reason: %s\n", strerror(errno));
|
||||||
|
exit(63);
|
||||||
|
} else {
|
||||||
|
exit(63);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while ((entry = readdir(dir)) != NULL) {
|
||||||
|
printf("%s\n", entry->d_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
|
|
||||||
if (pmt_logical) {
|
if (pmt_logical) {
|
||||||
printf("List of logical partitions (/dev/block/mapper): \n");
|
printf("List of logical partitions (/dev/block/mapper): \n");
|
||||||
if (system("ls /dev/block/mapper") != 0) {
|
if (system("ls /dev/block/mapper") != 0 && !pmt_force_mode) {
|
||||||
error("An error occurred when the logical partition list appears!\n");
|
error("An error occurred when the logical partition list appears!\n", 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pmt_ab) {
|
if (pmt_ab && !pmt_force_mode) {
|
||||||
printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
|
printf("%sWarning: device using A/B partition style.%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pmt_logical) {
|
if (pmt_logical && !pmt_force_mode) {
|
||||||
printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
|
printf("%sWarning: device using logical partition type.%s\n", ANSI_YELLOW, ANSI_RESET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* end of code */
|
/* end of code */
|
||||||
Reference in New Issue
Block a user