Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Doug Zongker | fbf3c10 | 2009-06-24 09:36:20 -0700 | [diff] [blame] | 17 | #include <ctype.h> |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 18 | #include <errno.h> |
| 19 | #include <stdarg.h> |
Doug Zongker | fbf3c10 | 2009-06-24 09:36:20 -0700 | [diff] [blame] | 20 | #include <stdio.h> |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 21 | #include <stdlib.h> |
| 22 | #include <string.h> |
| 23 | #include <sys/mount.h> |
| 24 | #include <sys/stat.h> |
| 25 | #include <sys/types.h> |
| 26 | #include <unistd.h> |
| 27 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 28 | #include "cutils/misc.h" |
| 29 | #include "cutils/properties.h" |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 30 | #include "edify/expr.h" |
| 31 | #include "minzip/DirUtil.h" |
| 32 | #include "mtdutils/mounts.h" |
| 33 | #include "mtdutils/mtdutils.h" |
| 34 | #include "updater.h" |
| 35 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 36 | |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 37 | // mount(type, location, mount_point) |
| 38 | // |
| 39 | // what: type="MTD" location="<partition>" to mount a yaffs2 filesystem |
| 40 | // type="vfat" location="/dev/block/<whatever>" to mount a device |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 41 | char* MountFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 42 | char* result = NULL; |
| 43 | if (argc != 3) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 44 | return ErrorAbort(state, "%s() expects 3 args, got %d", name, argc); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 45 | } |
| 46 | char* type; |
| 47 | char* location; |
| 48 | char* mount_point; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 49 | if (ReadArgs(state, argv, 3, &type, &location, &mount_point) < 0) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 50 | return NULL; |
| 51 | } |
| 52 | |
| 53 | if (strlen(type) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 54 | ErrorAbort(state, "type argument to %s() can't be empty", name); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 55 | goto done; |
| 56 | } |
| 57 | if (strlen(location) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 58 | ErrorAbort(state, "location argument to %s() can't be empty", name); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 59 | goto done; |
| 60 | } |
| 61 | if (strlen(mount_point) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 62 | ErrorAbort(state, "mount_point argument to %s() can't be empty", name); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 63 | goto done; |
| 64 | } |
| 65 | |
| 66 | mkdir(mount_point, 0755); |
| 67 | |
| 68 | if (strcmp(type, "MTD") == 0) { |
| 69 | mtd_scan_partitions(); |
| 70 | const MtdPartition* mtd; |
| 71 | mtd = mtd_find_partition_by_name(location); |
| 72 | if (mtd == NULL) { |
| 73 | fprintf(stderr, "%s: no mtd partition named \"%s\"", |
| 74 | name, location); |
| 75 | result = strdup(""); |
| 76 | goto done; |
| 77 | } |
| 78 | if (mtd_mount_partition(mtd, mount_point, "yaffs2", 0 /* rw */) != 0) { |
| 79 | fprintf(stderr, "mtd mount of %s failed: %s\n", |
| 80 | location, strerror(errno)); |
| 81 | result = strdup(""); |
| 82 | goto done; |
| 83 | } |
| 84 | result = mount_point; |
| 85 | } else { |
| 86 | if (mount(location, mount_point, type, |
| 87 | MS_NOATIME | MS_NODEV | MS_NODIRATIME, "") < 0) { |
| 88 | result = strdup(""); |
| 89 | } else { |
| 90 | result = mount_point; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | done: |
| 95 | free(type); |
| 96 | free(location); |
| 97 | if (result != mount_point) free(mount_point); |
| 98 | return result; |
| 99 | } |
| 100 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 101 | |
| 102 | // is_mounted(mount_point) |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 103 | char* IsMountedFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 104 | char* result = NULL; |
| 105 | if (argc != 1) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 106 | return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 107 | } |
| 108 | char* mount_point; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 109 | if (ReadArgs(state, argv, 1, &mount_point) < 0) { |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 110 | return NULL; |
| 111 | } |
| 112 | if (strlen(mount_point) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 113 | ErrorAbort(state, "mount_point argument to unmount() can't be empty"); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 114 | goto done; |
| 115 | } |
| 116 | |
| 117 | scan_mounted_volumes(); |
| 118 | const MountedVolume* vol = find_mounted_volume_by_mount_point(mount_point); |
| 119 | if (vol == NULL) { |
| 120 | result = strdup(""); |
| 121 | } else { |
| 122 | result = mount_point; |
| 123 | } |
| 124 | |
| 125 | done: |
| 126 | if (result != mount_point) free(mount_point); |
| 127 | return result; |
| 128 | } |
| 129 | |
| 130 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 131 | char* UnmountFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 132 | char* result = NULL; |
| 133 | if (argc != 1) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 134 | return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 135 | } |
| 136 | char* mount_point; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 137 | if (ReadArgs(state, argv, 1, &mount_point) < 0) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 138 | return NULL; |
| 139 | } |
| 140 | if (strlen(mount_point) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 141 | ErrorAbort(state, "mount_point argument to unmount() can't be empty"); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 142 | goto done; |
| 143 | } |
| 144 | |
| 145 | scan_mounted_volumes(); |
| 146 | const MountedVolume* vol = find_mounted_volume_by_mount_point(mount_point); |
| 147 | if (vol == NULL) { |
| 148 | fprintf(stderr, "unmount of %s failed; no such volume\n", mount_point); |
| 149 | result = strdup(""); |
| 150 | } else { |
| 151 | unmount_mounted_volume(vol); |
| 152 | result = mount_point; |
| 153 | } |
| 154 | |
| 155 | done: |
| 156 | if (result != mount_point) free(mount_point); |
| 157 | return result; |
| 158 | } |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 159 | |
| 160 | |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 161 | // format(type, location) |
| 162 | // |
| 163 | // type="MTD" location=partition |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 164 | char* FormatFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 165 | char* result = NULL; |
| 166 | if (argc != 2) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 167 | return ErrorAbort(state, "%s() expects 2 args, got %d", name, argc); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 168 | } |
| 169 | char* type; |
| 170 | char* location; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 171 | if (ReadArgs(state, argv, 2, &type, &location) < 0) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 172 | return NULL; |
| 173 | } |
| 174 | |
| 175 | if (strlen(type) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 176 | ErrorAbort(state, "type argument to %s() can't be empty", name); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 177 | goto done; |
| 178 | } |
| 179 | if (strlen(location) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 180 | ErrorAbort(state, "location argument to %s() can't be empty", name); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 181 | goto done; |
| 182 | } |
| 183 | |
| 184 | if (strcmp(type, "MTD") == 0) { |
| 185 | mtd_scan_partitions(); |
| 186 | const MtdPartition* mtd = mtd_find_partition_by_name(location); |
| 187 | if (mtd == NULL) { |
| 188 | fprintf(stderr, "%s: no mtd partition named \"%s\"", |
| 189 | name, location); |
| 190 | result = strdup(""); |
| 191 | goto done; |
| 192 | } |
| 193 | MtdWriteContext* ctx = mtd_write_partition(mtd); |
| 194 | if (ctx == NULL) { |
| 195 | fprintf(stderr, "%s: can't write \"%s\"", name, location); |
| 196 | result = strdup(""); |
| 197 | goto done; |
| 198 | } |
| 199 | if (mtd_erase_blocks(ctx, -1) == -1) { |
| 200 | mtd_write_close(ctx); |
| 201 | fprintf(stderr, "%s: failed to erase \"%s\"", name, location); |
| 202 | result = strdup(""); |
| 203 | goto done; |
| 204 | } |
| 205 | if (mtd_write_close(ctx) != 0) { |
| 206 | fprintf(stderr, "%s: failed to close \"%s\"", name, location); |
| 207 | result = strdup(""); |
| 208 | goto done; |
| 209 | } |
| 210 | result = location; |
| 211 | } else { |
| 212 | fprintf(stderr, "%s: unsupported type \"%s\"", name, type); |
| 213 | } |
| 214 | |
| 215 | done: |
| 216 | free(type); |
| 217 | if (result != location) free(location); |
| 218 | return result; |
| 219 | } |
| 220 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 221 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 222 | char* DeleteFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 223 | char** paths = malloc(argc * sizeof(char*)); |
| 224 | int i; |
| 225 | for (i = 0; i < argc; ++i) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 226 | paths[i] = Evaluate(state, argv[i]); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 227 | if (paths[i] == NULL) { |
| 228 | int j; |
| 229 | for (j = 0; j < i; ++i) { |
| 230 | free(paths[j]); |
| 231 | } |
| 232 | free(paths); |
| 233 | return NULL; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | bool recursive = (strcmp(name, "delete_recursive") == 0); |
| 238 | |
| 239 | int success = 0; |
| 240 | for (i = 0; i < argc; ++i) { |
| 241 | if ((recursive ? dirUnlinkHierarchy(paths[i]) : unlink(paths[i])) == 0) |
| 242 | ++success; |
| 243 | free(paths[i]); |
| 244 | } |
| 245 | free(paths); |
| 246 | |
| 247 | char buffer[10]; |
| 248 | sprintf(buffer, "%d", success); |
| 249 | return strdup(buffer); |
| 250 | } |
| 251 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 252 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 253 | char* ShowProgressFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 254 | if (argc != 2) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 255 | return ErrorAbort(state, "%s() expects 2 args, got %d", name, argc); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 256 | } |
| 257 | char* frac_str; |
| 258 | char* sec_str; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 259 | if (ReadArgs(state, argv, 2, &frac_str, &sec_str) < 0) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 260 | return NULL; |
| 261 | } |
| 262 | |
| 263 | double frac = strtod(frac_str, NULL); |
| 264 | int sec = strtol(sec_str, NULL, 10); |
| 265 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 266 | UpdaterInfo* ui = (UpdaterInfo*)(state->cookie); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 267 | fprintf(ui->cmd_pipe, "progress %f %d\n", frac, sec); |
| 268 | |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 269 | free(sec_str); |
Doug Zongker | fbf3c10 | 2009-06-24 09:36:20 -0700 | [diff] [blame] | 270 | return frac_str; |
| 271 | } |
| 272 | |
| 273 | char* SetProgressFn(const char* name, State* state, int argc, Expr* argv[]) { |
| 274 | if (argc != 1) { |
| 275 | return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc); |
| 276 | } |
| 277 | char* frac_str; |
| 278 | if (ReadArgs(state, argv, 1, &frac_str) < 0) { |
| 279 | return NULL; |
| 280 | } |
| 281 | |
| 282 | double frac = strtod(frac_str, NULL); |
| 283 | |
| 284 | UpdaterInfo* ui = (UpdaterInfo*)(state->cookie); |
| 285 | fprintf(ui->cmd_pipe, "set_progress %f\n", frac); |
| 286 | |
| 287 | return frac_str; |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 290 | // package_extract_dir(package_path, destination_path) |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 291 | char* PackageExtractDirFn(const char* name, State* state, |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 292 | int argc, Expr* argv[]) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 293 | if (argc != 2) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 294 | return ErrorAbort(state, "%s() expects 2 args, got %d", name, argc); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 295 | } |
| 296 | char* zip_path; |
| 297 | char* dest_path; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 298 | if (ReadArgs(state, argv, 2, &zip_path, &dest_path) < 0) return NULL; |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 299 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 300 | ZipArchive* za = ((UpdaterInfo*)(state->cookie))->package_zip; |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 301 | |
| 302 | // To create a consistent system image, never use the clock for timestamps. |
| 303 | struct utimbuf timestamp = { 1217592000, 1217592000 }; // 8/1/2008 default |
| 304 | |
| 305 | bool success = mzExtractRecursive(za, zip_path, dest_path, |
| 306 | MZ_EXTRACT_FILES_ONLY, ×tamp, |
| 307 | NULL, NULL); |
| 308 | free(zip_path); |
| 309 | free(dest_path); |
| 310 | return strdup(success ? "t" : ""); |
| 311 | } |
| 312 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 313 | |
| 314 | // package_extract_file(package_path, destination_path) |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 315 | char* PackageExtractFileFn(const char* name, State* state, |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 316 | int argc, Expr* argv[]) { |
| 317 | if (argc != 2) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 318 | return ErrorAbort(state, "%s() expects 2 args, got %d", name, argc); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 319 | } |
| 320 | char* zip_path; |
| 321 | char* dest_path; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 322 | if (ReadArgs(state, argv, 2, &zip_path, &dest_path) < 0) return NULL; |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 323 | |
| 324 | bool success = false; |
| 325 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 326 | ZipArchive* za = ((UpdaterInfo*)(state->cookie))->package_zip; |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 327 | const ZipEntry* entry = mzFindZipEntry(za, zip_path); |
| 328 | if (entry == NULL) { |
| 329 | fprintf(stderr, "%s: no %s in package\n", name, zip_path); |
| 330 | goto done; |
| 331 | } |
| 332 | |
| 333 | FILE* f = fopen(dest_path, "wb"); |
| 334 | if (f == NULL) { |
| 335 | fprintf(stderr, "%s: can't open %s for write: %s\n", |
| 336 | name, dest_path, strerror(errno)); |
| 337 | goto done; |
| 338 | } |
| 339 | success = mzExtractZipEntryToFile(za, entry, fileno(f)); |
| 340 | fclose(f); |
| 341 | |
| 342 | done: |
| 343 | free(zip_path); |
| 344 | free(dest_path); |
| 345 | return strdup(success ? "t" : ""); |
| 346 | } |
| 347 | |
| 348 | |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 349 | // symlink target src1 src2 ... |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 350 | char* SymlinkFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 351 | if (argc == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 352 | return ErrorAbort(state, "%s() expects 1+ args, got %d", name, argc); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 353 | } |
| 354 | char* target; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 355 | target = Evaluate(state, argv[0]); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 356 | if (target == NULL) return NULL; |
| 357 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 358 | char** srcs = ReadVarArgs(state, argc-1, argv+1); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 359 | if (srcs == NULL) { |
| 360 | free(target); |
| 361 | return NULL; |
| 362 | } |
| 363 | |
| 364 | int i; |
| 365 | for (i = 0; i < argc-1; ++i) { |
| 366 | symlink(target, srcs[i]); |
| 367 | free(srcs[i]); |
| 368 | } |
| 369 | free(srcs); |
| 370 | return strdup(""); |
| 371 | } |
| 372 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 373 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 374 | char* SetPermFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 375 | char* result = NULL; |
| 376 | bool recursive = (strcmp(name, "set_perm_recursive") == 0); |
| 377 | |
| 378 | int min_args = 4 + (recursive ? 1 : 0); |
| 379 | if (argc < min_args) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 380 | return ErrorAbort(state, "%s() expects %d+ args, got %d", name, argc); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 383 | char** args = ReadVarArgs(state, argc, argv); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 384 | if (args == NULL) return NULL; |
| 385 | |
| 386 | char* end; |
| 387 | int i; |
| 388 | |
| 389 | int uid = strtoul(args[0], &end, 0); |
| 390 | if (*end != '\0' || args[0][0] == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 391 | ErrorAbort(state, "%s: \"%s\" not a valid uid", name, args[0]); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 392 | goto done; |
| 393 | } |
| 394 | |
| 395 | int gid = strtoul(args[1], &end, 0); |
| 396 | if (*end != '\0' || args[1][0] == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 397 | ErrorAbort(state, "%s: \"%s\" not a valid gid", name, args[1]); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 398 | goto done; |
| 399 | } |
| 400 | |
| 401 | if (recursive) { |
| 402 | int dir_mode = strtoul(args[2], &end, 0); |
| 403 | if (*end != '\0' || args[2][0] == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 404 | ErrorAbort(state, "%s: \"%s\" not a valid dirmode", name, args[2]); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 405 | goto done; |
| 406 | } |
| 407 | |
| 408 | int file_mode = strtoul(args[3], &end, 0); |
| 409 | if (*end != '\0' || args[3][0] == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 410 | ErrorAbort(state, "%s: \"%s\" not a valid filemode", |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 411 | name, args[3]); |
| 412 | goto done; |
| 413 | } |
| 414 | |
| 415 | for (i = 4; i < argc; ++i) { |
| 416 | dirSetHierarchyPermissions(args[i], uid, gid, dir_mode, file_mode); |
| 417 | } |
| 418 | } else { |
| 419 | int mode = strtoul(args[2], &end, 0); |
| 420 | if (*end != '\0' || args[2][0] == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 421 | ErrorAbort(state, "%s: \"%s\" not a valid mode", name, args[2]); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 422 | goto done; |
| 423 | } |
| 424 | |
Doug Zongker | 0bbfe3d | 2009-06-25 13:37:31 -0700 | [diff] [blame] | 425 | for (i = 3; i < argc; ++i) { |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 426 | chown(args[i], uid, gid); |
| 427 | chmod(args[i], mode); |
| 428 | } |
| 429 | } |
| 430 | result = strdup(""); |
| 431 | |
| 432 | done: |
| 433 | for (i = 0; i < argc; ++i) { |
| 434 | free(args[i]); |
| 435 | } |
| 436 | free(args); |
| 437 | |
| 438 | return result; |
| 439 | } |
| 440 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 441 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 442 | char* GetPropFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 443 | if (argc != 1) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 444 | return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 445 | } |
| 446 | char* key; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 447 | key = Evaluate(state, argv[0]); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 448 | if (key == NULL) return NULL; |
| 449 | |
| 450 | char value[PROPERTY_VALUE_MAX]; |
| 451 | property_get(key, value, ""); |
| 452 | free(key); |
| 453 | |
| 454 | return strdup(value); |
| 455 | } |
| 456 | |
| 457 | |
Doug Zongker | 47cace9 | 2009-06-18 10:11:50 -0700 | [diff] [blame] | 458 | // file_getprop(file, key) |
| 459 | // |
| 460 | // interprets 'file' as a getprop-style file (key=value pairs, one |
| 461 | // per line, # comment lines and blank lines okay), and returns the value |
| 462 | // for 'key' (or "" if it isn't defined). |
| 463 | char* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) { |
| 464 | char* result = NULL; |
| 465 | char* buffer = NULL; |
| 466 | char* filename; |
| 467 | char* key; |
| 468 | if (ReadArgs(state, argv, 2, &filename, &key) < 0) { |
| 469 | return NULL; |
| 470 | } |
| 471 | |
| 472 | struct stat st; |
| 473 | if (stat(filename, &st) < 0) { |
| 474 | ErrorAbort(state, "%s: failed to stat \"%s\": %s", |
| 475 | name, filename, strerror(errno)); |
| 476 | goto done; |
| 477 | } |
| 478 | |
| 479 | #define MAX_FILE_GETPROP_SIZE 65536 |
| 480 | |
| 481 | if (st.st_size > MAX_FILE_GETPROP_SIZE) { |
| 482 | ErrorAbort(state, "%s too large for %s (max %d)", |
| 483 | filename, name, MAX_FILE_GETPROP_SIZE); |
| 484 | goto done; |
| 485 | } |
| 486 | |
| 487 | buffer = malloc(st.st_size+1); |
| 488 | if (buffer == NULL) { |
| 489 | ErrorAbort(state, "%s: failed to alloc %d bytes", name, st.st_size+1); |
| 490 | goto done; |
| 491 | } |
| 492 | |
| 493 | FILE* f = fopen(filename, "rb"); |
| 494 | if (f == NULL) { |
| 495 | ErrorAbort(state, "%s: failed to open %s: %s", |
| 496 | name, filename, strerror(errno)); |
| 497 | goto done; |
| 498 | } |
| 499 | |
| 500 | if (fread(buffer, 1, st.st_size, f) != st.st_size) { |
| 501 | ErrorAbort(state, "%s: failed to read %d bytes from %s", |
| 502 | name, st.st_size+1, filename); |
| 503 | fclose(f); |
| 504 | goto done; |
| 505 | } |
| 506 | buffer[st.st_size] = '\0'; |
| 507 | |
| 508 | fclose(f); |
| 509 | |
| 510 | char* line = strtok(buffer, "\n"); |
| 511 | do { |
| 512 | // skip whitespace at start of line |
| 513 | while (*line && isspace(*line)) ++line; |
| 514 | |
| 515 | // comment or blank line: skip to next line |
| 516 | if (*line == '\0' || *line == '#') continue; |
| 517 | |
| 518 | char* equal = strchr(line, '='); |
| 519 | if (equal == NULL) { |
| 520 | ErrorAbort(state, "%s: malformed line \"%s\": %s not a prop file?", |
| 521 | name, line, filename); |
| 522 | goto done; |
| 523 | } |
| 524 | |
| 525 | // trim whitespace between key and '=' |
| 526 | char* key_end = equal-1; |
| 527 | while (key_end > line && isspace(*key_end)) --key_end; |
| 528 | key_end[1] = '\0'; |
| 529 | |
| 530 | // not the key we're looking for |
| 531 | if (strcmp(key, line) != 0) continue; |
| 532 | |
| 533 | // skip whitespace after the '=' to the start of the value |
| 534 | char* val_start = equal+1; |
| 535 | while(*val_start && isspace(*val_start)) ++val_start; |
| 536 | |
| 537 | // trim trailing whitespace |
| 538 | char* val_end = val_start + strlen(val_start)-1; |
| 539 | while (val_end > val_start && isspace(*val_end)) --val_end; |
| 540 | val_end[1] = '\0'; |
| 541 | |
| 542 | result = strdup(val_start); |
| 543 | break; |
| 544 | |
| 545 | } while ((line = strtok(NULL, "\n"))); |
| 546 | |
| 547 | if (result == NULL) result = strdup(""); |
| 548 | |
| 549 | done: |
| 550 | free(filename); |
| 551 | free(key); |
| 552 | free(buffer); |
| 553 | return result; |
| 554 | } |
| 555 | |
| 556 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 557 | static bool write_raw_image_cb(const unsigned char* data, |
| 558 | int data_len, void* ctx) { |
| 559 | int r = mtd_write_data((MtdWriteContext*)ctx, (const char *)data, data_len); |
| 560 | if (r == data_len) return true; |
| 561 | fprintf(stderr, "%s\n", strerror(errno)); |
| 562 | return false; |
| 563 | } |
| 564 | |
| 565 | // write_raw_image(file, partition) |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 566 | char* WriteRawImageFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 567 | char* result = NULL; |
| 568 | |
| 569 | char* partition; |
| 570 | char* filename; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 571 | if (ReadArgs(state, argv, 2, &filename, &partition) < 0) { |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 572 | return NULL; |
| 573 | } |
| 574 | |
| 575 | if (strlen(partition) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 576 | ErrorAbort(state, "partition argument to %s can't be empty", name); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 577 | goto done; |
| 578 | } |
| 579 | if (strlen(filename) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 580 | ErrorAbort(state, "file argument to %s can't be empty", name); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 581 | goto done; |
| 582 | } |
| 583 | |
| 584 | mtd_scan_partitions(); |
| 585 | const MtdPartition* mtd = mtd_find_partition_by_name(partition); |
| 586 | if (mtd == NULL) { |
| 587 | fprintf(stderr, "%s: no mtd partition named \"%s\"\n", name, partition); |
| 588 | result = strdup(""); |
| 589 | goto done; |
| 590 | } |
| 591 | |
| 592 | MtdWriteContext* ctx = mtd_write_partition(mtd); |
| 593 | if (ctx == NULL) { |
| 594 | fprintf(stderr, "%s: can't write mtd partition \"%s\"\n", |
| 595 | name, partition); |
| 596 | result = strdup(""); |
| 597 | goto done; |
| 598 | } |
| 599 | |
| 600 | bool success; |
| 601 | |
| 602 | FILE* f = fopen(filename, "rb"); |
| 603 | if (f == NULL) { |
| 604 | fprintf(stderr, "%s: can't open %s: %s\n", |
| 605 | name, filename, strerror(errno)); |
| 606 | result = strdup(""); |
| 607 | goto done; |
| 608 | } |
| 609 | |
| 610 | success = true; |
| 611 | char* buffer = malloc(BUFSIZ); |
| 612 | int read; |
| 613 | while (success && (read = fread(buffer, 1, BUFSIZ, f)) > 0) { |
| 614 | int wrote = mtd_write_data(ctx, buffer, read); |
| 615 | success = success && (wrote == read); |
| 616 | if (!success) { |
| 617 | fprintf(stderr, "mtd_write_data to %s failed: %s\n", |
| 618 | partition, strerror(errno)); |
| 619 | } |
| 620 | } |
| 621 | free(buffer); |
| 622 | fclose(f); |
| 623 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 624 | if (mtd_erase_blocks(ctx, -1) == -1) { |
| 625 | fprintf(stderr, "%s: error erasing blocks of %s\n", name, partition); |
| 626 | } |
| 627 | if (mtd_write_close(ctx) != 0) { |
| 628 | fprintf(stderr, "%s: error closing write of %s\n", name, partition); |
| 629 | } |
| 630 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 631 | printf("%s %s partition from %s\n", |
| 632 | success ? "wrote" : "failed to write", partition, filename); |
| 633 | |
| 634 | result = success ? partition : strdup(""); |
| 635 | |
| 636 | done: |
| 637 | if (result != partition) free(partition); |
| 638 | free(filename); |
| 639 | return result; |
| 640 | } |
| 641 | |
| 642 | // write_firmware_image(file, partition) |
| 643 | // |
| 644 | // partition is "radio" or "hboot" |
| 645 | // file is not used until after updater exits |
| 646 | // |
| 647 | // TODO: this should live in some HTC-specific library |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 648 | char* WriteFirmwareImageFn(const char* name, State* state, |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 649 | int argc, Expr* argv[]) { |
| 650 | char* result = NULL; |
| 651 | |
| 652 | char* partition; |
| 653 | char* filename; |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 654 | if (ReadArgs(state, argv, 2, &filename, &partition) < 0) { |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 655 | return NULL; |
| 656 | } |
| 657 | |
| 658 | if (strlen(partition) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 659 | ErrorAbort(state, "partition argument to %s can't be empty", name); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 660 | goto done; |
| 661 | } |
| 662 | if (strlen(filename) == 0) { |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 663 | ErrorAbort(state, "file argument to %s can't be empty", name); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 664 | goto done; |
| 665 | } |
| 666 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 667 | FILE* cmd = ((UpdaterInfo*)(state->cookie))->cmd_pipe; |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 668 | fprintf(cmd, "firmware %s %s\n", partition, filename); |
| 669 | |
| 670 | printf("will write %s firmware from %s\n", partition, filename); |
| 671 | result = partition; |
| 672 | |
| 673 | done: |
| 674 | if (result != partition) free(partition); |
| 675 | free(filename); |
| 676 | return result; |
| 677 | } |
| 678 | |
| 679 | |
| 680 | extern int applypatch(int argc, char** argv); |
| 681 | |
| 682 | // apply_patch(srcfile, tgtfile, tgtsha1, tgtsize, sha1:patch, ...) |
| 683 | // apply_patch_check(file, sha1, ...) |
| 684 | // apply_patch_space(bytes) |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 685 | char* ApplyPatchFn(const char* name, State* state, int argc, Expr* argv[]) { |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 686 | printf("in applypatchfn (%s)\n", name); |
| 687 | |
| 688 | char* prepend = NULL; |
| 689 | if (strstr(name, "check") != NULL) { |
| 690 | prepend = "-c"; |
| 691 | } else if (strstr(name, "space") != NULL) { |
| 692 | prepend = "-s"; |
| 693 | } |
| 694 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 695 | char** args = ReadVarArgs(state, argc, argv); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 696 | if (args == NULL) return NULL; |
| 697 | |
| 698 | // insert the "program name" argv[0] and a copy of the "prepend" |
| 699 | // string (if any) at the start of the args. |
| 700 | |
| 701 | int extra = 1 + (prepend != NULL ? 1 : 0); |
| 702 | char** temp = malloc((argc+extra) * sizeof(char*)); |
| 703 | memcpy(temp+extra, args, argc * sizeof(char*)); |
| 704 | temp[0] = strdup("updater"); |
| 705 | if (prepend) { |
| 706 | temp[1] = strdup(prepend); |
| 707 | } |
| 708 | free(args); |
| 709 | args = temp; |
| 710 | argc += extra; |
| 711 | |
| 712 | printf("calling applypatch\n"); |
| 713 | fflush(stdout); |
| 714 | int result = applypatch(argc, args); |
| 715 | printf("applypatch returned %d\n", result); |
| 716 | |
| 717 | int i; |
| 718 | for (i = 0; i < argc; ++i) { |
| 719 | free(args[i]); |
| 720 | } |
| 721 | free(args); |
| 722 | |
| 723 | switch (result) { |
| 724 | case 0: return strdup("t"); |
| 725 | case 1: return strdup(""); |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 726 | default: return ErrorAbort(state, "applypatch couldn't parse args"); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 727 | } |
| 728 | } |
| 729 | |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 730 | char* UIPrintFn(const char* name, State* state, int argc, Expr* argv[]) { |
| 731 | char** args = ReadVarArgs(state, argc, argv); |
| 732 | if (args == NULL) { |
| 733 | return NULL; |
| 734 | } |
| 735 | |
| 736 | int size = 0; |
| 737 | int i; |
| 738 | for (i = 0; i < argc; ++i) { |
| 739 | size += strlen(args[i]); |
| 740 | } |
| 741 | char* buffer = malloc(size+1); |
| 742 | size = 0; |
| 743 | for (i = 0; i < argc; ++i) { |
| 744 | strcpy(buffer+size, args[i]); |
| 745 | size += strlen(args[i]); |
| 746 | free(args[i]); |
| 747 | } |
| 748 | free(args); |
| 749 | buffer[size] = '\0'; |
| 750 | |
| 751 | char* line = strtok(buffer, "\n"); |
| 752 | while (line) { |
| 753 | fprintf(((UpdaterInfo*)(state->cookie))->cmd_pipe, |
| 754 | "ui_print %s\n", line); |
| 755 | line = strtok(NULL, "\n"); |
| 756 | } |
| 757 | fprintf(((UpdaterInfo*)(state->cookie))->cmd_pipe, "ui_print\n"); |
| 758 | |
| 759 | return buffer; |
| 760 | } |
| 761 | |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 762 | |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 763 | void RegisterInstallFunctions() { |
| 764 | RegisterFunction("mount", MountFn); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 765 | RegisterFunction("is_mounted", IsMountedFn); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 766 | RegisterFunction("unmount", UnmountFn); |
| 767 | RegisterFunction("format", FormatFn); |
| 768 | RegisterFunction("show_progress", ShowProgressFn); |
Doug Zongker | fbf3c10 | 2009-06-24 09:36:20 -0700 | [diff] [blame] | 769 | RegisterFunction("set_progress", SetProgressFn); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 770 | RegisterFunction("delete", DeleteFn); |
| 771 | RegisterFunction("delete_recursive", DeleteFn); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 772 | RegisterFunction("package_extract_dir", PackageExtractDirFn); |
| 773 | RegisterFunction("package_extract_file", PackageExtractFileFn); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 774 | RegisterFunction("symlink", SymlinkFn); |
| 775 | RegisterFunction("set_perm", SetPermFn); |
| 776 | RegisterFunction("set_perm_recursive", SetPermFn); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 777 | |
| 778 | RegisterFunction("getprop", GetPropFn); |
Doug Zongker | 47cace9 | 2009-06-18 10:11:50 -0700 | [diff] [blame] | 779 | RegisterFunction("file_getprop", FileGetPropFn); |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 780 | RegisterFunction("write_raw_image", WriteRawImageFn); |
| 781 | RegisterFunction("write_firmware_image", WriteFirmwareImageFn); |
| 782 | |
| 783 | RegisterFunction("apply_patch", ApplyPatchFn); |
| 784 | RegisterFunction("apply_patch_check", ApplyPatchFn); |
| 785 | RegisterFunction("apply_patch_space", ApplyPatchFn); |
Doug Zongker | d9c9d10 | 2009-06-12 12:24:39 -0700 | [diff] [blame] | 786 | |
| 787 | RegisterFunction("ui_print", UIPrintFn); |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 788 | } |