How is the /proc/pid/fd/0, 1, 2 is linked to tty device? - stdio

Linux process link stdin/output/err to /dev/tty, for example:
ls -all /proc/5310/fd show
lrwx------ 1 ubuntu ubuntu 64 Mar 31 09:58 0 -> /dev/pts/1
lrwx------ 1 ubuntu ubuntu 64 Mar 31 09:58 1 -> /dev/pts/1
lrwx------ 1 ubuntu ubuntu 64 Mar 31 09:58 2 -> /dev/pts/1
Which component in system is in charge of the link? How it link the fd 0/1/2 to /dev/pts/1? How can I change it to be /dev/pts/2

Related

cannot compile raspberry kernel on NTFS disk

Sorry for my bad english.
I am trying to compile kernel source code of raspberry and jetson tx2 on a NTFS disk.
compile kernel source code of jetson ok, no error.
compile kernel source code of raspberry fail with bellow error message:
*** Error during update of the configuration.
make[3]: *** [/media/u2004/LINUX_SHARED/rasp/linux/scripts/kconfig/Makefile:39: silentoldconfig] Error 1
make[2]: *** [/media/u2004/LINUX_SHARED/rasp/linux/Makefile:541: silentoldconfig] Error 2
make[1]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/kernel.release'. Stop.
make[1]: Leaving directory '/media/u2004/LINUX_SHARED/rasp/build_output'
make: *** [Makefile:150: sub-make] Error 2
no error when compile raspberry kernel source code in Ext4 disk.
edit: add compile environment and script
cross compile in Ubuntu 20.04 64bit. compile aarch32 with bellow script (compile ok in Ext4 partition).
ROOT_DIR=/home/u2004/Desktop/dm
KERNEL_BUILD_DIR=${ROOT_DIR}/linux/
CROSS_COMPILE=${ROOT_DIR}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
BUILD_OUTPUT=${ROOT_DIR}/build_output
INSTALL_MOD_PATH_EXT4=${ROOT_DIR}/copy_to_sdcard/ext4
INSTALL_MOD_PATH_FAT32=${ROOT_DIR}/copy_to_sdcard/fat32
ARCH=arm
DEF_CONFIG=bcm2709_defconfig
TARGET=kernel7
git clone --depth=1 -b rpi-4.9.y https://github.com/raspberrypi/linux
git clone https://github.com/raspberrypi/tools
export CROSS_COMPILE=${CROSS_COMPILE}
cd ${KERNEL_BUILD_DIR}
make mrproper
make ARCH=${ARCH} O=${BUILD_OUTPUT} ${DEF_CONFIG}
make ARCH=${ARCH} O=${BUILD_OUTPUT} -j4 zImage modules dtbs
make ARCH=${ARCH} INSTALL_MOD_PATH=${INSTALL_MOD_PATH_EXT4} modules_install
please help.
thank you
Ultimately, I would advise not to clone/build the linux kernel directly on an NTFS partition, since, from my own past experiences, this is probably a recipe for trouble.
The safest approach, if you want to clone/build it on a Windows 10 computer, would therefore be, IMHO, to either:
install/use WSL2 on your Windows system (free,fastest),
install VirtualBox (free) on your Windows 10 system and use a virtual drive formatted in EXT4 (You could import a ready-to-use (free) Linux development virtual Machine retrieved from Turnkey Linux in a breeze).
The following procedure worked flawlessly using WSL2:
start bash.ex, and, in the WSL2 bash session, enter the following commands:
user#kleronomas:/tmp$ mkdir so
user#kleronomas:/tmp$ cd so
user#kleronomas:/tmp/so$ ROOT_DIR=$(pwd)
user#kleronomas:/tmp/so$ KERNEL_BUILD_DIR=${ROOT_DIR}/linux/
user#kleronomas:/tmp/so$ CROSS_COMPILE=${ROOT_DIR}/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-
user#kleronomas:/tmp/so$ BUILD_OUTPUT=${ROOT_DIR}/build_output
user#kleronomas:/tmp/so$ INSTALL_MOD_PATH_EXT4=${ROOT_DIR}/copy_to_sdcard/ext4
user#kleronomas:/tmp/so$ INSTALL_MOD_PATH_FAT32=${ROOT_DIR}/copy_to_sdcard/fat32
user#kleronomas:/tmp/so$ ARCH=arm
user#kleronomas:/tmp/so$ DEF_CONFIG=bcm2709_defconfig
user#kleronomas:/tmp/so$ TARGET=kernel7
user#kleronomas:/tmp/so$ export CROSS_COMPILE=${CROSS_COMPILE}
user#kleronomas:/tmp/so$ cd ${KERNEL_BUILD_DIR}
user#kleronomas:/tmp/so$ git clone --depth=1 -b rpi-4.9.y https://github.com/raspberrypi/linux
user#kleronomas:/tmp/so$ git clone https://github.com/raspberrypi/tools
user#kleronomas:/tmp/so$ make O=${BUILD_OUTPUT} mrproper
user#kleronomas:/tmp/so$ make ARCH=${ARCH} O=${BUILD_OUTPUT} ${DEF_CONFIG}
user#kleronomas:/tmp/so$ make ARCH=${ARCH} O=${BUILD_OUTPUT} -j4 zImage modules dtbs
user#kleronomas:/tmp/so$ make ARCH=${ARCH} O=${BUILD_OUTPUT} INSTALL_MOD_PATH=${INSTALL_MOD_PATH_EXT4} modules_install
user#kleronomas:/tmp/so$ ls -l ${BUILD_OUTPUT}
total 45445
-rw-r--r-- 1 user user 586 Mar 2 10:43 Makefile
-rw-r--r-- 1 user user 730037 Mar 2 11:05 Module.symvers
-rw-r--r-- 1 user user 2244428 Mar 2 11:04 System.map
drwxr-xr-x 1 user user 512 Mar 2 10:43 arch
drwxr-xr-x 1 user user 512 Mar 2 10:46 block
drwxr-xr-x 1 user user 512 Mar 2 10:44 certs
drwxr-xr-x 1 user user 512 Mar 2 11:07 crypto
drwxr-xr-x 1 user user 512 Mar 2 11:04 drivers
drwxr-xr-x 1 user user 512 Mar 2 11:07 firmware
drwxr-xr-x 1 user user 512 Mar 2 11:07 fs
drwxr-xr-x 1 user user 512 Mar 2 10:43 include
drwxr-xr-x 1 user user 512 Mar 2 11:04 init
drwxr-xr-x 1 user user 512 Mar 2 10:45 ipc
drwxr-xr-x 1 user user 512 Mar 2 11:07 kernel
drwxr-xr-x 1 user user 512 Mar 2 11:07 lib
drwxr-xr-x 1 user user 512 Mar 2 11:07 mm
-rw-r--r-- 1 user user 4840 Mar 2 10:44 modules.builtin
-rw-r--r-- 1 user user 61793 Mar 2 11:04 modules.order
drwxr-xr-x 1 user user 512 Mar 2 11:04 net
drwxr-xr-x 1 user user 512 Mar 2 10:44 scripts
drwxr-xr-x 1 user user 512 Mar 2 10:45 security
drwxr-xr-x 1 user user 512 Mar 2 11:07 sound
lrwxrwxrwx 1 user user 13 Mar 2 10:43 source -> /tmp/so/linux
drwxr-xr-x 1 user user 512 Mar 2 10:44 usr
drwxr-xr-x 1 user user 512 Mar 2 10:50 virt
-rwxr-xr-x 1 user user 14295892 Mar 2 11:04 vmlinux
-rw-r--r-- 1 user user 17819862 Mar 2 11:04 vmlinux.o
user#kleronomas:/tmp/so$ ls -ail ${INSTALL_MOD_PATH_EXT4}/lib/modules
total 0
844424931148038 drwxr-xr-x 1 user user 512 Mar 2 11:19 .
844424931148037 drwxr-xr-x 1 user user 512 Mar 2 12:12 ..
17732923533530216 drwxr-xr-x 1 user user 512 Mar 2 12:12 4.9.80-v7+
844424931148041 lrwxrwxrwx 1 user user 13 Mar 2 11:14 build -> /tmp/so/linux
1125899907858695 drwxr-xr-x 1 user user 512 Mar 2 11:17 kernel
1125899907858696 lrwxrwxrwx 1 user user 13 Mar 2 11:17 source -> /tmp/so/linux
You would then have to copy the build artifacts into your NTFS partition, which will be accessible from WSL2 in /mnt/c for C:, /mnt/d for D:, ...

why terminal output can't be saved to file when there's core dumped

I'm running an executable and trying to save terminal output to a file:
# ll
total 132
-rw-r--r--. 1 root root 496 Jun 14 11:41 mpx-debug.h
-rw-r--r--. 1 root root 12775 Jun 14 11:41 mpx-dig.c
-rw-r--r--. 1 root root 3526 Jun 14 11:41 mpx-hw.h
-rwxr-xr-x. 1 root root 65176 Jun 14 14:28 mpx-mini-test
-rw-r--r--. 1 root root 40480 Jun 14 11:41 mpx-mini-test.c
-rw-r--r--. 1 root root 205 Jun 14 11:41 mpx-mm.h
# ./mpx-mini-test
XSAVE is supported by HW & OS
XSAVE processor supported state mask: 0x1f
XSAVE OS supported state mask: 0x1f
BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0
no MPX support
Aborted (core dumped)
#
# ./mpx-mini-test | tee -a mpx-mini-test.log
#
# cat mpx-mini-test.log
#
As you can see, there're some prints in terminal without "| tee -a **.log".
But with "| tee -a **.log", nothing is saved to file.
I suspect it has something to do with the "Abort (core dumped)", did some googling but can't figure out exactly why. Is there anyone knows why? And how could I save all terminal outputs(including the "Abort (core dumped)") to file? Thanks in advance.

Has anyone tried using the bitbake-env utility lately?

Has anyone tried using the bitbake-env utility lately?
I do not see it installed:
[user#localhost build]$ which bitbake
~/YOCTO/oe_core_embedded/poky/bitbake/bin/bitbake
[user#localhost build]$ which bitbake-env
/usr/bin/which: no bitbake-env in (/home/user/YOCTO/oe_core_embedded/poky/scripts:/home/user/YOCTO/oe_core_embedded/poky/bitbake/bin:/usr/libexec/python2-sphinx:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/user/.local/bin:/home/user/bin)
[user#localhost build]$
As well I do not see it in the bitbake command listing:
[user#localhost poky]$ cd bitbake/bin
[user#localhost bin]$ ls -al
total 100
drwxrwxr-x. 2 user user 4096 Oct 18 12:49 .
drwxrwxr-x. 6 user user 4096 Oct 18 12:49 ..
-rwxrwxr-x. 1 user user 2072 Nov 18 11:51 bitbake
-rwxrwxr-x. 1 user user 7228 Oct 18 12:49 bitbake-diffsigs
-rwxrwxr-x. 1 user user 2894 Oct 18 12:49 bitbake-dumpsig
-rwxrwxr-x. 1 user user 4069 Oct 18 12:49 bitbake-layers
-rwxrwxr-x. 1 user user 2109 Oct 18 12:49 bitbake-prserv
-rwxrwxr-x. 1 user user 2128 Oct 18 12:49 bitbake-selftest
-rwxrwxr-x. 1 user user 17866 Oct 18 12:49 bitbake-worker
-rwxrwxr-x. 1 user user 13951 Oct 18 12:49 bitdoc
-rwxrwxr-x. 1 user user 5813 Oct 18 12:49 git-make-shallow
-rwxrwxr-x. 1 user user 8805 Oct 18 12:49 toaster
-rwxrwxr-x. 1 user user 4177 Oct 18 12:49 toaster-eventreplay
[user#localhost bin]$
It still exists/is listed in https://elinux.org/Bitbake_Cheat_Sheet from July 2016.
bitbake-env is a third party utility, and not actually a part of the OpenEmbedded Core hence why you will not see it unless you specifically install it. It is actually an 'improved' version of the bitbake -e flag for bitbake.
bash-4.3$ bitbake --help
Usage: bitbake [options] [recipename/target recipe:do_task ...]
Executes the specified task (default is 'build') for a given set of target recipes (.bb files).
It is assumed there is a conf/bblayers.conf available in cwd or in BBPATH which
will provide the layer, BBFILES and other configuration information.
Options:
...
-e, --environment Show the global or per-recipe environment complete
with information about where variables were
set/changed.

vagrant synced_folder file permissions

Vagrant Version 1.6.3
Virtual Box 4.3.12
VBoxGuestAdditions-4.3.2
Host OS -> Windows 8
Guest OS -> CentOS 6.4
This is the content of my Vagrantfile ( where developer is userName )
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/var/www"
# # comments-> I tried many combinations
# :owner=> 'developer',
# :group=> 'developer'
# :mount_options=> ['dmode=777', 'fmode=777']
Now when I try to change the access permissions of the synced_folder(/var/www) or sub directories or files of synced_folder by chmod command,the result is not as expected
For example
1) vim testFile.php
2) ls -al testFile.php
-rwxrwxrwx 1 developer developer 12 Sep 23 15:52 testFile.php
3) chmod 700 testFile.php
-rwxrwxrwx 1 developer developer 12 Sep 23 15:52 testFile.php
4) chmod 000 testFile.php
-r-xr-xr-x 1 developer developer 12 Sep 23 15:52 testFile.php
5) chmod 111 testFile.php
-r-xr-xr-x 1 developer developer 12 Sep 23 15:52 testFile.php
6) chmod 077 testFile.php
-rwxrwxrwx 1 developer developer 12 Sep 23 15:52 testFile.php
Basically the file is always readable and executable by "owner" , "group" and "others".
The question is why it is so ? Is there any solution for this? I want the synced_folder to behave according to centOS access permissions.
I am really stuck here for past few days.Please help.
Thank you
The guest OS normally preserves host's persmissions. Try adding permissions for other users on Windows.

Cannot build source code in Xcode 4.1 with iOS 4.3.5 device

I have been developing in Xcode 4.1 with iphone of iOS 4.3.5. It was fine without a version mismatch problem. Today, I connected another iphone which has the same version of iOS (4.3.5) and I could not build source code on to the device. The organizer window said,
The version of iOS on “Hee’s iPhone” does not match any of the
versions of iOS supported for development with this installation of
the iOS SDK. Please restore the device to a version of the OS listed
below, or update to the latest version of the iOS SDK; which is
available here.
I know it will be solved if I update Xcode or downgrade iPhone. However, I want to know other options if there are any. I really wonder why some devices are fine but others are not.
You can put additional SDKs/Symbols for the iPhoneOS/iPhoneSimulator platforms inside:
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/[insert ios version folder here]
and
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/[insert ios version folder here]
What I do is download old xcode and new beta xcode, install them to something like /Developer-3.2.3/, then symlink/alias the folders above from the /Developer-3.2.3 to the /Developer.
This lets my 4.1 xcode test on an iOS5.0 phone! The directory paths above might not be exact as I am writing this from my phone but they areaomething close to that. When I get back to my computer I will make sure those directories are correct.
For the simulator versions it would be:
/Developer/Platforms/iPhoneSimulator.platform/SDK/...
Edit (back at my computer):
Here is what my Developer directories looks like:
[ 17:49 root#MacBookPro / ]# ll
drwxrwxr-x+ 44 root admin 1.5K Sep 20 12:37 Applications
drwxrwxr-x 15 root admin 510B Sep 20 13:27 Developer
drwxrwxr-x# 17 root admin 578B Sep 20 13:12 Developer-3.2.4
drwxr-xr-x# 10 root admin 340B Sep 20 13:54 Developer-3.2.5
drwxrwxr-x# 18 root admin 612B Sep 20 13:44 Developer-4.2-beta7
[ 17:46 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/Developer/SDKs ]# ll
lrwxr-xr-x 1 root wheel 75B Sep 20 13:53 iPhoneOS3.2.sdk -> /Developer-3.2.4/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk
drwxr-xr-x 8 root wheel 272B Sep 20 13:26 iPhoneOS4.3.sdk
lrwxr-xr-x 1 root wheel 79B Sep 21 12:50 iPhoneOS5.0.sdk -> /Developer-4.2-beta7/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
[ 17:46 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/Developer ]# cd ../../DeviceSupport/
[ 17:46 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/DeviceSupport ]# ll
drwxrwxr-x 5 root admin 170B Sep 20 13:26 3.0
drwxrwxr-x 5 root admin 170B Sep 20 13:26 3.1
drwxrwxr-x 5 root admin 170B Sep 20 13:26 3.1.2
drwxrwxr-x 5 root admin 170B Sep 20 13:26 3.1.3
drwxrwxr-x 5 root admin 170B Sep 20 13:26 3.2
drwxrwxr-x 5 root admin 170B Sep 20 13:26 3.2.1
drwxrwxr-x 5 root admin 170B Sep 20 13:26 3.2.2
drwxrwxr-x 5 root admin 170B Sep 20 13:26 4.0
drwxrwxr-x 5 root admin 170B Sep 20 13:26 4.0.1
drwxrwxr-x 5 root admin 170B Sep 20 13:26 4.0.2
drwxrwxr-x 5 root admin 170B Sep 20 13:26 4.1
drwxrwxr-x 5 root admin 170B Sep 20 13:26 4.2
drwxrwxr-x 5 root admin 170B Sep 20 13:26 4.3
lrwxr-xr-x 1 root admin 77B Sep 21 12:54 5.0 (9A5313e) -> /Developer-4.2-beta7/Platforms/iPhoneOS.platform/DeviceSupport/5.0 (9A5313e)/
lrwxr-xr-x 1 root admin 13B Sep 21 12:54 Latest -> 5.0 (9A5313e)
[ 17:46 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/DeviceSupport ]#
In order to do this, you need to install the different versions of Xcode that have different iOS SDKs. To achieve the above, I only installed Xcode 3.2.4, 3.2.4, 4.1, and 4.2 (beta). I use 4.1 as my main /Developer directory.
Once each Xcode is installed into seperate locations, this is how you would symlink the Symbols/SDKs directories from a non-primary Xcode install to your main install path:
/Developer/Platforms/iPhoneOS.platform/DeviceSupport
[ 17:54 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/DeviceSupport ]# cd /Developer/Platforms/iPhoneOS.platform/DeviceSupport
[ 17:54 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/DeviceSupport ]# ln -sf "/Developer-4.2-beta7/Platforms/iPhoneOS.platform/DeviceSupport/5.0 (9A5313e)/" "5.0 (9A5313e)"
[ 17:54 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/DeviceSupport ]# cd ../Developer/SDKs
[ 17:54 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/DeviceSupport ]# ln -sf "/Developer-3.2.4/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk" "iPhoneOS3.2.sdk"
[ 17:54 root#MacBookPro /Developer/Platforms/iPhoneOS.platform/DeviceSupport ]# ln -sf "/Developer-4.2-beta7/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk" "iPhoneOS5.0.sdk"
After symlinking each SDK/Symbol directory in your main /Developer/Platforms/iPhoneOS.platform/DeviceSupport and /Developer/Platforms/iPhoneOS.platform/Developer/SDKs directories, open up Xcode, and you should be able to see your device and use it to test builds, etc.
Edit 2 (commands explained):
ll is an alias I made for the ls -l command:
[ 18:07 root#MacBookPro / ]# alias
cd..='cd ..'
cls='clear'
df='/usr/local/bin/df.nawk'
du='du -L'
l='ls -lsG'
ldir='ls -d */'
ll='ls -lhG'
ls='ls -G'
lsdir='ls -d */'
text='open -a TextWrangler'
v='ls -lhG'
vi='vim'
vu='vim'
vv='du . --max-depth=1 -L | sort -n | cut -f2 | xargs -d "\n" du -sh -L'
xcode='open -a xcode'
ln (symlink) is a command to create a shortcut/alias. The (very basic) syntax is:
[ 18:07 root#MacBookPro / ]# ln -s [TARGET_PATH] [LINK_NAME]
Here is the ln man page
Here is the ls man page