The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 | |
| 17 | #include <errno.h> |
| 18 | #include <stdlib.h> |
| 19 | #include <sys/mount.h> |
| 20 | #include <sys/stat.h> |
| 21 | #include <sys/types.h> |
JP Abgrall | 37aedb3 | 2014-06-16 19:07:39 -0700 | [diff] [blame] | 22 | #include <sys/wait.h> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 23 | #include <unistd.h> |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 24 | #include <ctype.h> |
Doug Zongker | f39989a | 2013-12-11 15:40:28 -0800 | [diff] [blame] | 25 | #include <fcntl.h> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 26 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 27 | extern "C" { |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 28 | #include <fs_mgr.h> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 29 | #include "mtdutils/mtdutils.h" |
| 30 | #include "mtdutils/mounts.h" |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 31 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 32 | #include "roots.h" |
| 33 | #include "common.h" |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 34 | #include "make_ext4fs.h" |
Doug Zongker | f39989a | 2013-12-11 15:40:28 -0800 | [diff] [blame] | 35 | extern "C" { |
| 36 | #include "wipe.h" |
| 37 | #include "cryptfs.h" |
| 38 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 39 | |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 40 | static struct fstab *fstab = NULL; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 41 | |
Kenny Root | 41dda82 | 2012-03-30 20:48:34 -0700 | [diff] [blame] | 42 | extern struct selabel_handle *sehandle; |
Stephen Smalley | 779701d | 2012-02-09 14:13:23 -0500 | [diff] [blame] | 43 | |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 44 | void load_volume_table() |
| 45 | { |
| 46 | int i; |
| 47 | int ret; |
Doug Zongker | 2810ced | 2011-02-17 15:55:21 -0800 | [diff] [blame] | 48 | |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 49 | fstab = fs_mgr_read_fstab("/etc/recovery.fstab"); |
| 50 | if (!fstab) { |
| 51 | LOGE("failed to read /etc/recovery.fstab\n"); |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 52 | return; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 53 | } |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 54 | |
Sasha Levitskiy | 85ef47d | 2014-04-10 17:11:34 -0700 | [diff] [blame] | 55 | ret = fs_mgr_add_entry(fstab, "/tmp", "ramdisk", "ramdisk"); |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 56 | if (ret < 0 ) { |
| 57 | LOGE("failed to add /tmp entry to fstab\n"); |
| 58 | fs_mgr_free_fstab(fstab); |
| 59 | fstab = NULL; |
| 60 | return; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 61 | } |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 62 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 63 | printf("recovery filesystem table\n"); |
| 64 | printf("=========================\n"); |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 65 | for (i = 0; i < fstab->num_entries; ++i) { |
| 66 | Volume* v = &fstab->recs[i]; |
| 67 | printf(" %d %s %s %s %lld\n", i, v->mount_point, v->fs_type, |
| 68 | v->blk_device, v->length); |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 69 | } |
| 70 | printf("\n"); |
| 71 | } |
| 72 | |
| 73 | Volume* volume_for_path(const char* path) { |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 74 | return fs_mgr_get_entry_for_mount_point(fstab, path); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 77 | int ensure_path_mounted(const char* path) { |
Dees_Troy | c51f1f9 | 2012-09-20 15:32:13 -0400 | [diff] [blame] | 78 | if (PartitionManager.Mount_By_Path(path, true)) |
| 79 | return 0; |
| 80 | else |
| 81 | return -1; |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 82 | Volume* v = volume_for_path(path); |
| 83 | if (v == NULL) { |
| 84 | LOGE("unknown volume for path [%s]\n", path); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 85 | return -1; |
| 86 | } |
Doug Zongker | c18eeb8 | 2010-09-21 16:49:26 -0700 | [diff] [blame] | 87 | if (strcmp(v->fs_type, "ramdisk") == 0) { |
| 88 | // the ramdisk is always mounted. |
| 89 | return 0; |
| 90 | } |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 91 | |
| 92 | int result; |
| 93 | result = scan_mounted_volumes(); |
| 94 | if (result < 0) { |
| 95 | LOGE("failed to scan mounted volumes\n"); |
| 96 | return -1; |
Doug Zongker | 23ceeea | 2010-07-08 17:27:55 -0700 | [diff] [blame] | 97 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 98 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 99 | const MountedVolume* mv = |
| 100 | find_mounted_volume_by_mount_point(v->mount_point); |
| 101 | if (mv) { |
| 102 | // volume is already mounted |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 103 | return 0; |
| 104 | } |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 105 | |
| 106 | mkdir(v->mount_point, 0755); // in case it doesn't already exist |
| 107 | |
| 108 | if (strcmp(v->fs_type, "yaffs2") == 0) { |
| 109 | // mount an MTD partition as a YAFFS2 filesystem. |
| 110 | mtd_scan_partitions(); |
| 111 | const MtdPartition* partition; |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 112 | partition = mtd_find_partition_by_name(v->blk_device); |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 113 | if (partition == NULL) { |
| 114 | LOGE("failed to find \"%s\" partition to mount at \"%s\"\n", |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 115 | v->blk_device, v->mount_point); |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 116 | return -1; |
| 117 | } |
| 118 | return mtd_mount_partition(partition, v->mount_point, v->fs_type, 0); |
| 119 | } else if (strcmp(v->fs_type, "ext4") == 0 || |
Mohamad Ayyash | 0ddfa32 | 2015-06-29 18:57:14 -0700 | [diff] [blame] | 120 | strcmp(v->fs_type, "squashfs") == 0 || |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 121 | strcmp(v->fs_type, "vfat") == 0) { |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 122 | result = mount(v->blk_device, v->mount_point, v->fs_type, |
Gaelle Nassiet | e853e96 | 2015-03-23 17:51:53 +0100 | [diff] [blame] | 123 | v->flags, v->fs_options); |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 124 | if (result == 0) return 0; |
| 125 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 126 | LOGE("failed to mount %s (%s)\n", v->mount_point, strerror(errno)); |
| 127 | return -1; |
| 128 | } |
| 129 | |
| 130 | LOGE("unknown fs_type \"%s\" for %s\n", v->fs_type, v->mount_point); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 131 | return -1; |
| 132 | } |
| 133 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 134 | int ensure_path_unmounted(const char* path) { |
Dees_Troy | c51f1f9 | 2012-09-20 15:32:13 -0400 | [diff] [blame] | 135 | if (PartitionManager.UnMount_By_Path(path, true)) |
| 136 | return 0; |
| 137 | else |
| 138 | return -1; |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 139 | Volume* v = volume_for_path(path); |
| 140 | if (v == NULL) { |
| 141 | LOGE("unknown volume for path [%s]\n", path); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 142 | return -1; |
| 143 | } |
Doug Zongker | c18eeb8 | 2010-09-21 16:49:26 -0700 | [diff] [blame] | 144 | if (strcmp(v->fs_type, "ramdisk") == 0) { |
| 145 | // the ramdisk is always mounted; you can't unmount it. |
| 146 | return -1; |
| 147 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 148 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 149 | int result; |
| 150 | result = scan_mounted_volumes(); |
| 151 | if (result < 0) { |
| 152 | LOGE("failed to scan mounted volumes\n"); |
| 153 | return -1; |
| 154 | } |
| 155 | |
| 156 | const MountedVolume* mv = |
| 157 | find_mounted_volume_by_mount_point(v->mount_point); |
| 158 | if (mv == NULL) { |
| 159 | // volume is already unmounted |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 160 | return 0; |
| 161 | } |
| 162 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 163 | return unmount_mounted_volume(mv); |
| 164 | } |
| 165 | |
JP Abgrall | 37aedb3 | 2014-06-16 19:07:39 -0700 | [diff] [blame] | 166 | static int exec_cmd(const char* path, char* const argv[]) { |
| 167 | int status; |
| 168 | pid_t child; |
| 169 | if ((child = vfork()) == 0) { |
| 170 | execv(path, argv); |
| 171 | _exit(-1); |
| 172 | } |
| 173 | waitpid(child, &status, 0); |
| 174 | if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { |
| 175 | LOGE("%s failed with status %d\n", path, WEXITSTATUS(status)); |
| 176 | } |
| 177 | return WEXITSTATUS(status); |
| 178 | } |
| 179 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 180 | int format_volume(const char* volume) { |
Dees_Troy | c51f1f9 | 2012-09-20 15:32:13 -0400 | [diff] [blame] | 181 | if (PartitionManager.Wipe_By_Path(volume)) |
| 182 | return 0; |
| 183 | else |
| 184 | return -1; |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 185 | Volume* v = volume_for_path(volume); |
| 186 | if (v == NULL) { |
| 187 | LOGE("unknown volume \"%s\"\n", volume); |
| 188 | return -1; |
| 189 | } |
Doug Zongker | c18eeb8 | 2010-09-21 16:49:26 -0700 | [diff] [blame] | 190 | if (strcmp(v->fs_type, "ramdisk") == 0) { |
| 191 | // you can't format the ramdisk. |
| 192 | LOGE("can't format_volume \"%s\"", volume); |
| 193 | return -1; |
| 194 | } |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 195 | if (strcmp(v->mount_point, volume) != 0) { |
| 196 | LOGE("can't give path \"%s\" to format_volume\n", volume); |
| 197 | return -1; |
| 198 | } |
| 199 | |
| 200 | if (ensure_path_unmounted(volume) != 0) { |
| 201 | LOGE("format_volume failed to unmount \"%s\"\n", v->mount_point); |
| 202 | return -1; |
| 203 | } |
| 204 | |
| 205 | if (strcmp(v->fs_type, "yaffs2") == 0 || strcmp(v->fs_type, "mtd") == 0) { |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 206 | mtd_scan_partitions(); |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 207 | const MtdPartition* partition = mtd_find_partition_by_name(v->blk_device); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 208 | if (partition == NULL) { |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 209 | LOGE("format_volume: no MTD partition \"%s\"\n", v->blk_device); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 210 | return -1; |
| 211 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 212 | |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 213 | MtdWriteContext *write = mtd_write_partition(partition); |
| 214 | if (write == NULL) { |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 215 | LOGW("format_volume: can't open MTD \"%s\"\n", v->blk_device); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 216 | return -1; |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 217 | } else if (mtd_erase_blocks(write, -1) == (off_t) -1) { |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 218 | LOGW("format_volume: can't erase MTD \"%s\"\n", v->blk_device); |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 219 | mtd_write_close(write); |
| 220 | return -1; |
| 221 | } else if (mtd_write_close(write)) { |
Ken Sumrall | f35d1ce | 2013-02-13 12:59:35 -0800 | [diff] [blame] | 222 | LOGW("format_volume: can't close MTD \"%s\"\n", v->blk_device); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 223 | return -1; |
| 224 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 225 | return 0; |
| 226 | } |
| 227 | |
JP Abgrall | 37aedb3 | 2014-06-16 19:07:39 -0700 | [diff] [blame] | 228 | if (strcmp(v->fs_type, "ext4") == 0 || strcmp(v->fs_type, "f2fs") == 0) { |
Doug Zongker | f39989a | 2013-12-11 15:40:28 -0800 | [diff] [blame] | 229 | // if there's a key_loc that looks like a path, it should be a |
| 230 | // block device for storing encryption metadata. wipe it too. |
| 231 | if (v->key_loc != NULL && v->key_loc[0] == '/') { |
| 232 | LOGI("wiping %s\n", v->key_loc); |
| 233 | int fd = open(v->key_loc, O_WRONLY | O_CREAT, 0644); |
| 234 | if (fd < 0) { |
| 235 | LOGE("format_volume: failed to open %s\n", v->key_loc); |
| 236 | return -1; |
| 237 | } |
| 238 | wipe_block_device(fd, get_file_size(fd)); |
| 239 | close(fd); |
| 240 | } |
| 241 | |
JP Abgrall | 37aedb3 | 2014-06-16 19:07:39 -0700 | [diff] [blame] | 242 | ssize_t length = 0; |
| 243 | if (v->length != 0) { |
| 244 | length = v->length; |
| 245 | } else if (v->key_loc != NULL && strcmp(v->key_loc, "footer") == 0) { |
| 246 | length = -CRYPT_FOOTER_OFFSET; |
| 247 | } |
| 248 | int result; |
| 249 | if (strcmp(v->fs_type, "ext4") == 0) { |
| 250 | result = make_ext4fs(v->blk_device, length, volume, sehandle); |
| 251 | } else { /* Has to be f2fs because we checked earlier. */ |
| 252 | if (v->key_loc != NULL && strcmp(v->key_loc, "footer") == 0 && length < 0) { |
JP Abgrall | 78d458c | 2014-08-04 16:44:33 -0700 | [diff] [blame] | 253 | LOGE("format_volume: crypt footer + negative length (%zd) not supported on %s\n", length, v->fs_type); |
JP Abgrall | 37aedb3 | 2014-06-16 19:07:39 -0700 | [diff] [blame] | 254 | return -1; |
| 255 | } |
| 256 | if (length < 0) { |
JP Abgrall | 78d458c | 2014-08-04 16:44:33 -0700 | [diff] [blame] | 257 | LOGE("format_volume: negative length (%zd) not supported on %s\n", length, v->fs_type); |
JP Abgrall | 37aedb3 | 2014-06-16 19:07:39 -0700 | [diff] [blame] | 258 | return -1; |
| 259 | } |
| 260 | char *num_sectors; |
JP Abgrall | 78d458c | 2014-08-04 16:44:33 -0700 | [diff] [blame] | 261 | if (asprintf(&num_sectors, "%zd", length / 512) <= 0) { |
JP Abgrall | 37aedb3 | 2014-06-16 19:07:39 -0700 | [diff] [blame] | 262 | LOGE("format_volume: failed to create %s command for %s\n", v->fs_type, v->blk_device); |
| 263 | return -1; |
| 264 | } |
| 265 | const char *f2fs_path = "/sbin/mkfs.f2fs"; |
| 266 | const char* const f2fs_argv[] = {"mkfs.f2fs", "-t", "-d1", v->blk_device, num_sectors, NULL}; |
| 267 | |
| 268 | result = exec_cmd(f2fs_path, (char* const*)f2fs_argv); |
| 269 | free(num_sectors); |
| 270 | } |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 271 | if (result != 0) { |
JP Abgrall | 37aedb3 | 2014-06-16 19:07:39 -0700 | [diff] [blame] | 272 | LOGE("format_volume: make %s failed on %s with %d(%s)\n", v->fs_type, v->blk_device, result, strerror(errno)); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 273 | return -1; |
| 274 | } |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 275 | return 0; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 276 | } |
Doug Zongker | d4208f9 | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 277 | |
| 278 | LOGE("format_volume: fs_type \"%s\" unsupported\n", v->fs_type); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 279 | return -1; |
| 280 | } |
Doug Zongker | 239ac6a | 2013-08-20 16:03:25 -0700 | [diff] [blame] | 281 | |
| 282 | int setup_install_mounts() { |
| 283 | if (fstab == NULL) { |
| 284 | LOGE("can't set up install mounts: no fstab loaded\n"); |
| 285 | return -1; |
| 286 | } |
| 287 | for (int i = 0; i < fstab->num_entries; ++i) { |
| 288 | Volume* v = fstab->recs + i; |
| 289 | |
| 290 | if (strcmp(v->mount_point, "/tmp") == 0 || |
| 291 | strcmp(v->mount_point, "/cache") == 0) { |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 292 | if (ensure_path_mounted(v->mount_point) != 0) { |
| 293 | LOGE("failed to mount %s\n", v->mount_point); |
| 294 | return -1; |
| 295 | } |
Doug Zongker | 239ac6a | 2013-08-20 16:03:25 -0700 | [diff] [blame] | 296 | |
| 297 | } else { |
Doug Zongker | 99916f0 | 2014-01-13 14:16:58 -0800 | [diff] [blame] | 298 | if (ensure_path_unmounted(v->mount_point) != 0) { |
| 299 | LOGE("failed to unmount %s\n", v->mount_point); |
| 300 | return -1; |
| 301 | } |
Doug Zongker | 239ac6a | 2013-08-20 16:03:25 -0700 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | return 0; |
| 305 | } |