1

I want to make some changes in the system.img and flash it into my Nexus 5.

To modify the .img I first need to unpack it into filesystem, make the changes anf then repack into new system.img.

I'm following this guide for unpack/repack.

Steps I'm taking:

I. Clone ASOP scripts:

  1. git clone https://android.googlesource.com/platform/system/extras
  2. git clone https://android.googlesource.com/platform/external/libselinux/
  3. git clone https://android.googlesource.com/platform/system/core/

II. Checkout specific version:

  1. cd extras
  2. git checkout android-5.1.1_r9

III. Compiling c files to create make_ext4fs (which is used to repack the filesystem into img)

  1. cd ..
  2. gcc -o make_ext4fs -Icore/libsparse/include -Ilibselinux/include -Icore/include -lz extras/ext4_utils/canned_fs_config.c extras/ext4_utils/make_ext4fs_main.c extras/ext4_utils/make_ext4fs.c extras/ext4_utils/ext4fixup.c extras/ext4_utils/ext4_utils.c extras/ext4_utils/allocate.c extras/ext4_utils/contents.c extras/ext4_utils/extent.c extras/ext4_utils/indirect.c extras/ext4_utils/uuid.c extras/ext4_utils/sha1.c extras/ext4_utils/wipe.c core/libsparse/backed_block.c core/libsparse/output_file.c core/libsparse/sparse.c core/libsparse/sparse_crc32.c core/libsparse/sparse_err.c core/libsparse/sparse_read.c

But above command is giving me error:

extras/ext4_utils/make_ext4fs_main.c: In function ‘main’:
extras/ext4_utils/make_ext4fs_main.c:187:20: error: ‘fs_config’ undeclared (first use in this function)
   fs_config_func = fs_config;
                    ^
extras/ext4_utils/make_ext4fs_main.c:187:20: note: each undeclared identifier is reported only once for each function it appears in

It says fs_config in undeclared. But this is ASOP code, provided by Android only.

What am I missing..?

I think I've included all the header files, but now I'm not sure.

Please help. This is very frustrating.

P.S. - I'm a noob in C. So great help if anyone can explain in simple terms.

Thank You

adam black
  • 607
  • 5
  • 14
  • 1
    First thing that comes to mind: you're forgetting to include some file(s) in your `gcc` command. Are you sure this doesn't have a `Makefile`? – m0skit0 Aug 25 '15 at 08:07
  • 1
    @m0skit0 The folder where c file with main() resides is `extras/ext4_utils/make_ext4fs_main.c`. Intrestingly this folder does not have a make file, but all of its sibling folder does have. Now I'm not sure if this is something missed on git or am I missing some step? Also I'm not very fimiler with `make` operation. Please suggest. Will be great help. Thanks! – adam black Aug 25 '15 at 08:35
  • Then maybe running `make` in parent folder with also make this executable. Maybe this is not meant to be compiled by itself but rather as part of other tools. – m0skit0 Aug 25 '15 at 08:55
  • @m0skit0: I've built `make_ext4fs` successfully by itself. – Michael Aug 25 '15 at 09:00
  • 1
    @adamblack: Have you tried checking out the same branch (android-5.1.1_r9) for the `core` git as for the `extras` git? IIRC I had trouble building if the gits didn't match. – Michael Aug 25 '15 at 09:02
  • @m0skit0 can you please share steps how build it? I'm still stuck. – adam black Aug 26 '15 at 02:47

0 Answers0