Skip to content

Commit

Permalink
Initial commit for the Universal lagfix kernel.
Browse files Browse the repository at this point in the history
- fixes multiple issues with how samsung handles stuff
- backups (but does not restore) efs partition
- added graphsh command to display messages pre-init
- added truncate command to create large files fast (alternate to dd
  skip)
- added lagfixing and rooting options
- some other modifications
  • Loading branch information
sztupy committed Oct 20, 2010
1 parent 1805cfe commit 30bd9b6
Show file tree
Hide file tree
Showing 12 changed files with 898 additions and 40 deletions.
7 changes: 5 additions & 2 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ LOCAL_SRC_FILES := \
legacy.c \
commands.c \
recovery.c \
graphsh.c \
install.c \
truncate.c \
lagfixutils.c \
roots.c \
ui.c \
verifier.c
verifier.c

LOCAL_SRC_FILES += \
reboot.c \
Expand Down Expand Up @@ -44,7 +47,7 @@ LOCAL_MODULE := recovery

LOCAL_FORCE_STATIC_EXECUTABLE := true

RECOVERY_VERSION := ClockworkMod Recovery v2.5.1.0
RECOVERY_VERSION := ClockworkMod Recovery v2.5.1.0 lagfix edition
LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
RECOVERY_API_VERSION := 2
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
Expand Down
1 change: 1 addition & 0 deletions default_recovery_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ int device_handle_key(int key_code, int visible) {
case KEY_CAMERA:
case KEY_F21:
case KEY_SEND:
case KEY_M: // home button on SGS
return SELECT_ITEM;

case KEY_END:
Expand Down
60 changes: 40 additions & 20 deletions extendedcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void show_install_update_menu()
break;
case ITEM_APPLY_SDCARD:
{
if (confirm_selection("Confirm install?", "Yes - Install /sdcard/update.zip"))
if (confirm_selection("Confirm install?", "Yes - Install /mnt/sdcard/update.zip"))
install_zip(SDCARD_PACKAGE_FILE);
break;
}
Expand Down Expand Up @@ -308,7 +308,7 @@ char* choose_file_menu(const char* directory, const char* fileExtensionOrDirecto
void show_choose_zip_menu()
{
if (ensure_root_path_mounted("SDCARD:") != 0) {
LOGE ("Can't mount /sdcard\n");
LOGE ("Can't mount /mnt/sdcard\n");
return;
}

Expand All @@ -317,12 +317,12 @@ void show_choose_zip_menu()
NULL
};

char* file = choose_file_menu("/sdcard/", ".zip", headers);
char* file = choose_file_menu("/mnt/sdcard/", ".zip", headers);
if (file == NULL)
return;
char sdcard_package_file[1024];
strcpy(sdcard_package_file, "SDCARD:");
strcat(sdcard_package_file, file + strlen("/sdcard/"));
strcat(sdcard_package_file, file + strlen("/mnt/sdcard/"));
static char* confirm_install = "Confirm install?";
static char confirm[PATH_MAX];
sprintf(confirm, "Yes - Install %s", basename(file));
Expand Down Expand Up @@ -374,7 +374,7 @@ __system(const char *command)
void show_nandroid_restore_menu()
{
if (ensure_root_path_mounted("SDCARD:") != 0) {
LOGE ("Can't mount /sdcard\n");
LOGE ("Can't mount /mnt/sdcard\n");
return;
}

Expand All @@ -383,7 +383,7 @@ void show_nandroid_restore_menu()
NULL
};

char* file = choose_file_menu("/sdcard/clockworkmod/backup/", NULL, headers);
char* file = choose_file_menu("/mnt/sdcard/clockworkmod/backup/", NULL, headers);
if (file == NULL)
return;

Expand Down Expand Up @@ -419,7 +419,7 @@ void show_mount_usb_storage_menu()
int confirm_selection(const char* title, const char* confirm)
{
struct stat info;
if (0 == stat("/sdcard/clockworkmod/.no_confirm", &info))
if (0 == stat("/mnt/sdcard/clockworkmod/.no_confirm", &info))
return 1;

char* confirm_headers[] = { title, " THIS CAN NOT BE UNDONE.", "", NULL };
Expand Down Expand Up @@ -463,11 +463,11 @@ int format_non_mtd_device(const char* root)
}

static char tmp[PATH_MAX];
sprintf(tmp, "rm -rf %s/*", path);
sprintf(tmp, "rm -rf %s*", path);
__system(tmp);
sprintf(tmp, "rm -rf %s/.*", path);
sprintf(tmp, "rm -rf %s.*", path);
__system(tmp);

ensure_root_path_unmounted(root);
return 0;
}
Expand All @@ -488,7 +488,7 @@ void show_partition_menu()
{ "mount /system", "unmount /system", "SYSTEM:" },
{ "mount /data", "unmount /data", "DATA:" },
{ "mount /cache", "unmount /cache", "CACHE:" },
{ "mount /sdcard", "unmount /sdcard", "SDCARD:" },
{ "mount /mnt/sdcard", "unmount /mnt/sdcard", "SDCARD:" },
{ "mount /sd-ext", "unmount /sd-ext", "SDEXT:" }
};

Expand Down Expand Up @@ -652,7 +652,7 @@ int run_and_remove_extendedcommand()
}
sleep(1);
}
remove("/sdcard/clockworkmod/.recoverycheckpoint");
remove("/mnt/sdcard/clockworkmod/.recoverycheckpoint");
if (i == 0) {
ui_print("Timed out waiting for SD card... continuing anyways.");
}
Expand All @@ -679,7 +679,7 @@ int amend_main(int argc, char** argv)
void show_nandroid_advanced_restore_menu()
{
if (ensure_root_path_mounted("SDCARD:") != 0) {
LOGE ("Can't mount /sdcard\n");
LOGE ("Can't mount /mnt/sdcard\n");
return;
}

Expand All @@ -692,7 +692,7 @@ void show_nandroid_advanced_restore_menu()
NULL
};

char* file = choose_file_menu("/sdcard/clockworkmod/backup/", NULL, advancedheaders);
char* file = choose_file_menu("/mnt/sdcard/clockworkmod/backup/", NULL, advancedheaders);
if (file == NULL)
return;

Expand Down Expand Up @@ -763,11 +763,11 @@ void show_nandroid_menu()
{
struct timeval tp;
gettimeofday(&tp, NULL);
sprintf(backup_path, "/sdcard/clockworkmod/backup/%d", tp.tv_sec);
sprintf(backup_path, "/mnt/sdcard/clockworkmod/backup/%d", tp.tv_sec);
}
else
{
strftime(backup_path, sizeof(backup_path), "/sdcard/clockworkmod/backup/%F.%H.%M.%S", tmp);
strftime(backup_path, sizeof(backup_path), "/mnt/sdcard/clockworkmod/backup/%F.%H.%M.%S", tmp);
}
nandroid_backup(backup_path);
}
Expand Down Expand Up @@ -804,6 +804,9 @@ void show_advanced_menu()
"Partition SD Card",
"Fix Permissions",
#endif
"Install Superuser",
"Lagfix options",
"Reboot into Download",
NULL
};

Expand Down Expand Up @@ -906,6 +909,23 @@ void show_advanced_menu()
ui_print("Done!\n");
break;
}
case 7:
{
if (confirm_selection("Confirm root","Yes - apply root to device")) {
apply_root_to_device();
}
break;
}
case 8:
{
lagfix_menu();
break;
}
case 9:
{
__reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "download");
break;
}
}
}
}
Expand Down Expand Up @@ -956,7 +976,7 @@ void handle_failure(int ret)
return;
if (0 != ensure_root_path_mounted("SDCARD:"))
return;
mkdir("/sdcard/clockworkmod", S_IRWXU);
__system("cp /tmp/recovery.log /sdcard/clockworkmod/recovery.log");
ui_print("/tmp/recovery.log was copied to /sdcard/clockworkmod/recovery.log. Please open ROM Manager to report the issue.\n");
}
mkdir("/mnt/sdcard/clockworkmod", S_IRWXU);
__system("cp /tmp/recovery.log /mnt/sdcard/clockworkmod/recovery.log");
ui_print("/tmp/recovery.log was copied to /mnt/sdcard/clockworkmod/recovery.log. Please open ROM Manager to report the issue.\n");
}
76 changes: 76 additions & 0 deletions graphsh.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* Copyright (C) 2010 Zsolt Sz Sztupák
*
* 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.
*/

#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <linux/input.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/reboot.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>

#include "bootloader.h"
#include "common.h"
#include "cutils/properties.h"
#include "install.h"
#include "minui/minui.h"
#include "minzip/DirUtil.h"
#include "roots.h"
#include "recovery_ui.h"

#include "extendedcommands.h"
#include "commands.h"
#include "lagfixutils.h"

extern char **environ;
// runs the program and redirects it's output to the screen using ui_print
int graphsh_main(int argc, char** argv) {
if (argc>=2) {
ui_init();
ui_print(EXPAND(RECOVERY_VERSION)" - script runner\n");

ui_set_show_text(1);

FILE* f = popen(argv[1],"r");
char buff[255];
int l;
if (!f) {
ui_print("Could not open process\n");
sleep(1);
gr_exit();
ev_exit();
return -1;
}
while(fgets(buff,250,f))
{
ui_print("%s",buff);
}
pclose(f);
gr_exit();
ev_exit();
return 0;
} else {
printf("Usage: graphsh command\n command with it's optional parameter(s) must be in quotes.\n");
return -1;
}
}

Loading

0 comments on commit 30bd9b6

Please sign in to comment.