ubifs.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. /*
  2. * This file is part of UBIFS.
  3. *
  4. * Copyright (C) 2006-2008 Nokia Corporation.
  5. *
  6. * (C) Copyright 2008-2009
  7. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program; if not, write to the Free Software Foundation, Inc., 51
  20. * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Authors: Artem Bityutskiy (Битюцкий Артём)
  23. * Adrian Hunter
  24. */
  25. #include "ubifs.h"
  26. #include <u-boot/zlib.h>
  27. #if !defined(CONFIG_SYS_64BIT_VSPRINTF)
  28. #warning Please define CONFIG_SYS_64BIT_VSPRINTF for correct output!
  29. #endif
  30. DECLARE_GLOBAL_DATA_PTR;
  31. /* compress.c */
  32. /*
  33. * We need a wrapper for zunzip() because the parameters are
  34. * incompatible with the lzo decompressor.
  35. */
  36. static int gzip_decompress(const unsigned char *in, size_t in_len,
  37. unsigned char *out, size_t *out_len)
  38. {
  39. unsigned long len = in_len;
  40. return zunzip(out, *out_len, (unsigned char *)in, &len, 0, 0);
  41. }
  42. /* Fake description object for the "none" compressor */
  43. static struct ubifs_compressor none_compr = {
  44. .compr_type = UBIFS_COMPR_NONE,
  45. .name = "no compression",
  46. .capi_name = "",
  47. .decompress = NULL,
  48. };
  49. static struct ubifs_compressor lzo_compr = {
  50. .compr_type = UBIFS_COMPR_LZO,
  51. .name = "LZO",
  52. .capi_name = "lzo",
  53. .decompress = lzo1x_decompress_safe,
  54. };
  55. static struct ubifs_compressor zlib_compr = {
  56. .compr_type = UBIFS_COMPR_ZLIB,
  57. .name = "zlib",
  58. .capi_name = "deflate",
  59. .decompress = gzip_decompress,
  60. };
  61. /* All UBIFS compressors */
  62. struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
  63. /**
  64. * ubifs_decompress - decompress data.
  65. * @in_buf: data to decompress
  66. * @in_len: length of the data to decompress
  67. * @out_buf: output buffer where decompressed data should
  68. * @out_len: output length is returned here
  69. * @compr_type: type of compression
  70. *
  71. * This function decompresses data from buffer @in_buf into buffer @out_buf.
  72. * The length of the uncompressed data is returned in @out_len. This functions
  73. * returns %0 on success or a negative error code on failure.
  74. */
  75. int ubifs_decompress(const void *in_buf, int in_len, void *out_buf,
  76. int *out_len, int compr_type)
  77. {
  78. int err;
  79. struct ubifs_compressor *compr;
  80. if (unlikely(compr_type < 0 || compr_type >= UBIFS_COMPR_TYPES_CNT)) {
  81. ubifs_err("invalid compression type %d", compr_type);
  82. return -EINVAL;
  83. }
  84. compr = ubifs_compressors[compr_type];
  85. if (unlikely(!compr->capi_name)) {
  86. ubifs_err("%s compression is not compiled in", compr->name);
  87. return -EINVAL;
  88. }
  89. if (compr_type == UBIFS_COMPR_NONE) {
  90. memcpy(out_buf, in_buf, in_len);
  91. *out_len = in_len;
  92. return 0;
  93. }
  94. err = compr->decompress(in_buf, in_len, out_buf, (size_t *)out_len);
  95. if (err)
  96. ubifs_err("cannot decompress %d bytes, compressor %s, "
  97. "error %d", in_len, compr->name, err);
  98. return err;
  99. }
  100. /**
  101. * compr_init - initialize a compressor.
  102. * @compr: compressor description object
  103. *
  104. * This function initializes the requested compressor and returns zero in case
  105. * of success or a negative error code in case of failure.
  106. */
  107. static int __init compr_init(struct ubifs_compressor *compr)
  108. {
  109. ubifs_compressors[compr->compr_type] = compr;
  110. #ifndef CONFIG_RELOC_FIXUP_WORKS
  111. ubifs_compressors[compr->compr_type]->name += gd->reloc_off;
  112. ubifs_compressors[compr->compr_type]->capi_name += gd->reloc_off;
  113. ubifs_compressors[compr->compr_type]->decompress += gd->reloc_off;
  114. #endif
  115. return 0;
  116. }
  117. /**
  118. * ubifs_compressors_init - initialize UBIFS compressors.
  119. *
  120. * This function initializes the compressor which were compiled in. Returns
  121. * zero in case of success and a negative error code in case of failure.
  122. */
  123. int __init ubifs_compressors_init(void)
  124. {
  125. int err;
  126. err = compr_init(&lzo_compr);
  127. if (err)
  128. return err;
  129. err = compr_init(&zlib_compr);
  130. if (err)
  131. return err;
  132. err = compr_init(&none_compr);
  133. if (err)
  134. return err;
  135. return 0;
  136. }
  137. /*
  138. * ubifsls...
  139. */
  140. static int filldir(struct ubifs_info *c, const char *name, int namlen,
  141. u64 ino, unsigned int d_type)
  142. {
  143. struct inode *inode;
  144. char filetime[32];
  145. switch (d_type) {
  146. case UBIFS_ITYPE_REG:
  147. printf("\t");
  148. break;
  149. case UBIFS_ITYPE_DIR:
  150. printf("<DIR>\t");
  151. break;
  152. case UBIFS_ITYPE_LNK:
  153. printf("<LNK>\t");
  154. break;
  155. default:
  156. printf("other\t");
  157. break;
  158. }
  159. inode = ubifs_iget(c->vfs_sb, ino);
  160. if (IS_ERR(inode)) {
  161. printf("%s: Error in ubifs_iget(), ino=%lld ret=%p!\n",
  162. __func__, ino, inode);
  163. return -1;
  164. }
  165. ctime_r((time_t *)&inode->i_mtime, filetime);
  166. printf("%9lld %24.24s ", inode->i_size, filetime);
  167. ubifs_iput(inode);
  168. printf("%s\n", name);
  169. return 0;
  170. }
  171. static int ubifs_printdir(struct file *file, void *dirent)
  172. {
  173. int err, over = 0;
  174. struct qstr nm;
  175. union ubifs_key key;
  176. struct ubifs_dent_node *dent;
  177. struct inode *dir = file->f_path.dentry->d_inode;
  178. struct ubifs_info *c = dir->i_sb->s_fs_info;
  179. dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);
  180. if (file->f_pos > UBIFS_S_KEY_HASH_MASK || file->f_pos == 2)
  181. /*
  182. * The directory was seek'ed to a senseless position or there
  183. * are no more entries.
  184. */
  185. return 0;
  186. if (file->f_pos == 1) {
  187. /* Find the first entry in TNC and save it */
  188. lowest_dent_key(c, &key, dir->i_ino);
  189. nm.name = NULL;
  190. dent = ubifs_tnc_next_ent(c, &key, &nm);
  191. if (IS_ERR(dent)) {
  192. err = PTR_ERR(dent);
  193. goto out;
  194. }
  195. file->f_pos = key_hash_flash(c, &dent->key);
  196. file->private_data = dent;
  197. }
  198. dent = file->private_data;
  199. if (!dent) {
  200. /*
  201. * The directory was seek'ed to and is now readdir'ed.
  202. * Find the entry corresponding to @file->f_pos or the
  203. * closest one.
  204. */
  205. dent_key_init_hash(c, &key, dir->i_ino, file->f_pos);
  206. nm.name = NULL;
  207. dent = ubifs_tnc_next_ent(c, &key, &nm);
  208. if (IS_ERR(dent)) {
  209. err = PTR_ERR(dent);
  210. goto out;
  211. }
  212. file->f_pos = key_hash_flash(c, &dent->key);
  213. file->private_data = dent;
  214. }
  215. while (1) {
  216. dbg_gen("feed '%s', ino %llu, new f_pos %#x",
  217. dent->name, (unsigned long long)le64_to_cpu(dent->inum),
  218. key_hash_flash(c, &dent->key));
  219. ubifs_assert(le64_to_cpu(dent->ch.sqnum) > ubifs_inode(dir)->creat_sqnum);
  220. nm.len = le16_to_cpu(dent->nlen);
  221. over = filldir(c, (char *)dent->name, nm.len,
  222. le64_to_cpu(dent->inum), dent->type);
  223. if (over)
  224. return 0;
  225. /* Switch to the next entry */
  226. key_read(c, &dent->key, &key);
  227. nm.name = (char *)dent->name;
  228. dent = ubifs_tnc_next_ent(c, &key, &nm);
  229. if (IS_ERR(dent)) {
  230. err = PTR_ERR(dent);
  231. goto out;
  232. }
  233. kfree(file->private_data);
  234. file->f_pos = key_hash_flash(c, &dent->key);
  235. file->private_data = dent;
  236. cond_resched();
  237. }
  238. out:
  239. if (err != -ENOENT) {
  240. ubifs_err("cannot find next direntry, error %d", err);
  241. return err;
  242. }
  243. kfree(file->private_data);
  244. file->private_data = NULL;
  245. file->f_pos = 2;
  246. return 0;
  247. }
  248. static int ubifs_finddir(struct super_block *sb, char *dirname,
  249. unsigned long root_inum, unsigned long *inum)
  250. {
  251. int err;
  252. struct qstr nm;
  253. union ubifs_key key;
  254. struct ubifs_dent_node *dent;
  255. struct ubifs_info *c;
  256. struct file *file;
  257. struct dentry *dentry;
  258. struct inode *dir;
  259. file = kzalloc(sizeof(struct file), 0);
  260. dentry = kzalloc(sizeof(struct dentry), 0);
  261. dir = kzalloc(sizeof(struct inode), 0);
  262. if (!file || !dentry || !dir) {
  263. printf("%s: Error, no memory for malloc!\n", __func__);
  264. err = -ENOMEM;
  265. goto out;
  266. }
  267. dir->i_sb = sb;
  268. file->f_path.dentry = dentry;
  269. file->f_path.dentry->d_parent = dentry;
  270. file->f_path.dentry->d_inode = dir;
  271. file->f_path.dentry->d_inode->i_ino = root_inum;
  272. c = sb->s_fs_info;
  273. dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, file->f_pos);
  274. /* Find the first entry in TNC and save it */
  275. lowest_dent_key(c, &key, dir->i_ino);
  276. nm.name = NULL;
  277. dent = ubifs_tnc_next_ent(c, &key, &nm);
  278. if (IS_ERR(dent)) {
  279. err = PTR_ERR(dent);
  280. goto out;
  281. }
  282. file->f_pos = key_hash_flash(c, &dent->key);
  283. file->private_data = dent;
  284. while (1) {
  285. dbg_gen("feed '%s', ino %llu, new f_pos %#x",
  286. dent->name, (unsigned long long)le64_to_cpu(dent->inum),
  287. key_hash_flash(c, &dent->key));
  288. ubifs_assert(le64_to_cpu(dent->ch.sqnum) > ubifs_inode(dir)->creat_sqnum);
  289. nm.len = le16_to_cpu(dent->nlen);
  290. if ((strncmp(dirname, (char *)dent->name, nm.len) == 0) &&
  291. (strlen(dirname) == nm.len)) {
  292. *inum = le64_to_cpu(dent->inum);
  293. return 1;
  294. }
  295. /* Switch to the next entry */
  296. key_read(c, &dent->key, &key);
  297. nm.name = (char *)dent->name;
  298. dent = ubifs_tnc_next_ent(c, &key, &nm);
  299. if (IS_ERR(dent)) {
  300. err = PTR_ERR(dent);
  301. goto out;
  302. }
  303. kfree(file->private_data);
  304. file->f_pos = key_hash_flash(c, &dent->key);
  305. file->private_data = dent;
  306. cond_resched();
  307. }
  308. out:
  309. if (err != -ENOENT) {
  310. ubifs_err("cannot find next direntry, error %d", err);
  311. return err;
  312. }
  313. if (file)
  314. free(file);
  315. if (dentry)
  316. free(dentry);
  317. if (dir)
  318. free(dir);
  319. if (file->private_data)
  320. kfree(file->private_data);
  321. file->private_data = NULL;
  322. file->f_pos = 2;
  323. return 0;
  324. }
  325. static unsigned long ubifs_findfile(struct super_block *sb, char *filename)
  326. {
  327. int ret;
  328. char *next;
  329. char fpath[128];
  330. char symlinkpath[128];
  331. char *name = fpath;
  332. unsigned long root_inum = 1;
  333. unsigned long inum;
  334. int symlink_count = 0; /* Don't allow symlink recursion */
  335. strcpy(fpath, filename);
  336. /* Remove all leading slashes */
  337. while (*name == '/')
  338. name++;
  339. /*
  340. * Handle root-direcoty ('/')
  341. */
  342. inum = root_inum;
  343. if (!name || *name == '\0')
  344. return inum;
  345. for (;;) {
  346. struct inode *inode;
  347. struct ubifs_inode *ui;
  348. /* Extract the actual part from the pathname. */
  349. next = strchr(name, '/');
  350. if (next) {
  351. /* Remove all leading slashes. */
  352. while (*next == '/')
  353. *(next++) = '\0';
  354. }
  355. ret = ubifs_finddir(sb, name, root_inum, &inum);
  356. if (!ret)
  357. return 0;
  358. inode = ubifs_iget(sb, inum);
  359. if (!inode)
  360. return 0;
  361. ui = ubifs_inode(inode);
  362. if ((inode->i_mode & S_IFMT) == S_IFLNK) {
  363. char link_name[64];
  364. char buf[128];
  365. /* We have some sort of symlink recursion, bail out */
  366. if (symlink_count++ > 8) {
  367. printf("Symlink recursion, aborting\n");
  368. return 0;
  369. }
  370. memcpy(link_name, ui->data, ui->data_len);
  371. link_name[ui->data_len] = '\0';
  372. if (link_name[0] == '/') {
  373. /* Absolute path, redo everything without
  374. * the leading slash */
  375. next = name = link_name + 1;
  376. root_inum = 1;
  377. continue;
  378. }
  379. /* Relative to cur dir */
  380. sprintf(buf, "%s/%s",
  381. link_name, next == NULL ? "" : next);
  382. memcpy(symlinkpath, buf, sizeof(buf));
  383. next = name = symlinkpath;
  384. continue;
  385. }
  386. /*
  387. * Check if directory with this name exists
  388. */
  389. /* Found the node! */
  390. if (!next || *next == '\0')
  391. return inum;
  392. root_inum = inum;
  393. name = next;
  394. }
  395. return 0;
  396. }
  397. int ubifs_ls(char *filename)
  398. {
  399. struct ubifs_info *c = ubifs_sb->s_fs_info;
  400. struct file *file;
  401. struct dentry *dentry;
  402. struct inode *dir;
  403. void *dirent = NULL;
  404. unsigned long inum;
  405. int ret = 0;
  406. c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
  407. inum = ubifs_findfile(ubifs_sb, filename);
  408. if (!inum) {
  409. ret = -1;
  410. goto out;
  411. }
  412. file = kzalloc(sizeof(struct file), 0);
  413. dentry = kzalloc(sizeof(struct dentry), 0);
  414. dir = kzalloc(sizeof(struct inode), 0);
  415. if (!file || !dentry || !dir) {
  416. printf("%s: Error, no memory for malloc!\n", __func__);
  417. ret = -ENOMEM;
  418. goto out_mem;
  419. }
  420. dir->i_sb = ubifs_sb;
  421. file->f_path.dentry = dentry;
  422. file->f_path.dentry->d_parent = dentry;
  423. file->f_path.dentry->d_inode = dir;
  424. file->f_path.dentry->d_inode->i_ino = inum;
  425. file->f_pos = 1;
  426. file->private_data = NULL;
  427. ubifs_printdir(file, dirent);
  428. out_mem:
  429. if (file)
  430. free(file);
  431. if (dentry)
  432. free(dentry);
  433. if (dir)
  434. free(dir);
  435. out:
  436. ubi_close_volume(c->ubi);
  437. return ret;
  438. }
  439. /*
  440. * ubifsload...
  441. */
  442. /* file.c */
  443. static inline void *kmap(struct page *page)
  444. {
  445. return page->addr;
  446. }
  447. static int read_block(struct inode *inode, void *addr, unsigned int block,
  448. struct ubifs_data_node *dn)
  449. {
  450. struct ubifs_info *c = inode->i_sb->s_fs_info;
  451. int err, len, out_len;
  452. union ubifs_key key;
  453. unsigned int dlen;
  454. data_key_init(c, &key, inode->i_ino, block);
  455. err = ubifs_tnc_lookup(c, &key, dn);
  456. if (err) {
  457. if (err == -ENOENT)
  458. /* Not found, so it must be a hole */
  459. memset(addr, 0, UBIFS_BLOCK_SIZE);
  460. return err;
  461. }
  462. ubifs_assert(le64_to_cpu(dn->ch.sqnum) > ubifs_inode(inode)->creat_sqnum);
  463. len = le32_to_cpu(dn->size);
  464. if (len <= 0 || len > UBIFS_BLOCK_SIZE)
  465. goto dump;
  466. dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
  467. out_len = UBIFS_BLOCK_SIZE;
  468. err = ubifs_decompress(&dn->data, dlen, addr, &out_len,
  469. le16_to_cpu(dn->compr_type));
  470. if (err || len != out_len)
  471. goto dump;
  472. /*
  473. * Data length can be less than a full block, even for blocks that are
  474. * not the last in the file (e.g., as a result of making a hole and
  475. * appending data). Ensure that the remainder is zeroed out.
  476. */
  477. if (len < UBIFS_BLOCK_SIZE)
  478. memset(addr + len, 0, UBIFS_BLOCK_SIZE - len);
  479. return 0;
  480. dump:
  481. ubifs_err("bad data node (block %u, inode %lu)",
  482. block, inode->i_ino);
  483. dbg_dump_node(c, dn);
  484. return -EINVAL;
  485. }
  486. static int do_readpage(struct ubifs_info *c, struct inode *inode, struct page *page)
  487. {
  488. void *addr;
  489. int err = 0, i;
  490. unsigned int block, beyond;
  491. struct ubifs_data_node *dn;
  492. loff_t i_size = inode->i_size;
  493. dbg_gen("ino %lu, pg %lu, i_size %lld",
  494. inode->i_ino, page->index, i_size);
  495. addr = kmap(page);
  496. block = page->index << UBIFS_BLOCKS_PER_PAGE_SHIFT;
  497. beyond = (i_size + UBIFS_BLOCK_SIZE - 1) >> UBIFS_BLOCK_SHIFT;
  498. if (block >= beyond) {
  499. /* Reading beyond inode */
  500. memset(addr, 0, PAGE_CACHE_SIZE);
  501. goto out;
  502. }
  503. dn = kmalloc(UBIFS_MAX_DATA_NODE_SZ, GFP_NOFS);
  504. if (!dn)
  505. return -ENOMEM;
  506. i = 0;
  507. while (1) {
  508. int ret;
  509. if (block >= beyond) {
  510. /* Reading beyond inode */
  511. err = -ENOENT;
  512. memset(addr, 0, UBIFS_BLOCK_SIZE);
  513. } else {
  514. ret = read_block(inode, addr, block, dn);
  515. if (ret) {
  516. err = ret;
  517. if (err != -ENOENT)
  518. break;
  519. } else if (block + 1 == beyond) {
  520. int dlen = le32_to_cpu(dn->size);
  521. int ilen = i_size & (UBIFS_BLOCK_SIZE - 1);
  522. if (ilen && ilen < dlen)
  523. memset(addr + ilen, 0, dlen - ilen);
  524. }
  525. }
  526. if (++i >= UBIFS_BLOCKS_PER_PAGE)
  527. break;
  528. block += 1;
  529. addr += UBIFS_BLOCK_SIZE;
  530. }
  531. if (err) {
  532. if (err == -ENOENT) {
  533. /* Not found, so it must be a hole */
  534. dbg_gen("hole");
  535. goto out_free;
  536. }
  537. ubifs_err("cannot read page %lu of inode %lu, error %d",
  538. page->index, inode->i_ino, err);
  539. goto error;
  540. }
  541. out_free:
  542. kfree(dn);
  543. out:
  544. return 0;
  545. error:
  546. kfree(dn);
  547. return err;
  548. }
  549. int ubifs_load(char *filename, u32 addr, u32 size)
  550. {
  551. struct ubifs_info *c = ubifs_sb->s_fs_info;
  552. unsigned long inum;
  553. struct inode *inode;
  554. struct page page;
  555. int err = 0;
  556. int i;
  557. int count;
  558. c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
  559. /* ubifs_findfile will resolve symlinks, so we know that we get
  560. * the real file here */
  561. inum = ubifs_findfile(ubifs_sb, filename);
  562. if (!inum) {
  563. err = -1;
  564. goto out;
  565. }
  566. /*
  567. * Read file inode
  568. */
  569. inode = ubifs_iget(ubifs_sb, inum);
  570. if (IS_ERR(inode)) {
  571. printf("%s: Error reading inode %ld!\n", __func__, inum);
  572. err = PTR_ERR(inode);
  573. goto out;
  574. }
  575. /*
  576. * If no size was specified or if size bigger than filesize
  577. * set size to filesize
  578. */
  579. if ((size == 0) || (size > inode->i_size))
  580. size = inode->i_size;
  581. count = (size + UBIFS_BLOCK_SIZE - 1) >> UBIFS_BLOCK_SHIFT;
  582. printf("Loading file '%s' to addr 0x%08x with size %d (0x%08x)...\n",
  583. filename, addr, size, size);
  584. page.addr = (void *)addr;
  585. page.index = 0;
  586. page.inode = inode;
  587. for (i = 0; i < count; i++) {
  588. err = do_readpage(c, inode, &page);
  589. if (err)
  590. break;
  591. page.addr += PAGE_SIZE;
  592. page.index++;
  593. }
  594. if (err)
  595. printf("Error reading file '%s'\n", filename);
  596. else
  597. printf("Done\n");
  598. ubifs_iput(inode);
  599. out:
  600. ubi_close_volume(c->ubi);
  601. return err;
  602. }