I have been working on building customized kernel image using Yocto build system.Now I wanted to change a file /etc/limits/ before I start my build but when I try to find this file "limits",could not find any file name limits and come to know this file is generated after build.
I was expecting to find this file(before build) somewhere in meta directory just like file named "profile" is there in poky directory.
Now my question is how yocto build system generates this file /etc/limits file ,where can I find this file before build
I have checke both the Danny branch (Yocto 1.3) and Dylan branch (Yocto 1.4) and in both of those versions, the file /etc/limits is generated by the shadow package. So I'm not sure why you say that the file is generated after the build. In general, when I need to find out where a file comes from, I search the generated binary packages. In your case, after building core-image-base, I performed this quick search:
$ cd tmp/deploy/rpm
$ find . -name '*.rpm' | while read A; do $RPM -qpl $A | grep etc/limits; \
if [ $? -eq 0 ]; then echo $A; fi; done
/etc/limits
./armv7a_vfp_neon/shadow-4.1.4.3-r13.armv7a_vfp_neon.rpm
This tells me that the limits file comes from the shadow package. When bitbake executes the do_install() task for that package, the package's own Makefile installs that file from a template contained in the shadow package.
There are two easy ways to change the contents of this file on your file root file system. The correct way is to add a layer with your custom changes: create a bbappend for the shadow package, add your own limits file using SRC_URI = "file://limits", and add a do_install_append() method to install your customized file after the package's own install method. There are plenty of examples of using this technique in poky.
The other method is to use a post process command.
ROOTFS_POSTPROCESS_COMMAND += "use_my_limits_file; "
where use_my_limits_file is simply a bash shell function that installs your custom limits file. See poky's insserv.bbclass for an example of the structure for using ROOTFS_POSTPROCESS_COMMAND.
Hope this helps. Happy hacking!