Sponsored Content
Operating Systems Linux Red Hat Inode number changes for a file in Redhat Linux Post 302515165 by Perderabo on Tuesday 19th of April 2011 09:37:32 AM
Old 04-19-2011
A more complete response is to post something like:
Code:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Client release 5.1 (Tikanga)
$ /bin/vi --version
VIM - Vi IMproved 7.0 (2006 May 7, compiled May  4 2007 05:54:34)
Included patches: 1, 3-4, 7-9, 11, 13-17, 19-26, 29-31, 34-44, 47, 50-56, 58-64, 66-73, 75, 77-92, 94-107, 109, 202, 234-235, 237
Compiled by <bugzilla@redhat.com>
Tiny version without GUI.  Features included (+) or not (-):
-arabic -autocmd -balloon_eval -browse +builtin_terms -byte_offset -cindent
-clientserver -clipboard -cmdline_compl -cmdline_hist -cmdline_info -comments
-cryptv -cscope -cursorshape -dialog -diff -digraphs -dnd -ebcdic -emacs_tags
-eval -ex_extra -extra_search -farsi -file_in_path -find_in_path -folding
-footer +fork() -gettext -hangul_input +iconv -insert_expand -jumplist -keymap
-langmap -libcall -linebreak -lispindent -listcmds -localmap -menu -mksession
-modify_fname -mouse -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm
-mouse_xterm +multi_byte -multi_lang -mzscheme -netbeans_intg -osfiletype
-path_extra -perl -printer -profile -python -quickfix -reltime -rightleft -ruby
 -scrollbind -signs -smartindent -sniff -statusline -sun_workshop -syntax
-tag_binary -tag_old_static -tag_any_white -tcl +terminfo -termresponse
-textobjects -title -toolbar -user_commands -vertsplit -virtualedit -visual
-viminfo -vreplace +wildignore -wildmenu -windows +writebackup -X11 -xfontset
-xim -xsmp -xterm_clipboard -xterm_save
   system vimrc file: "/etc/virc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
        --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2
Linking: gcc   -L/usr/local/lib -o vim       -lselinux -ltermcap -lacl
$

I don't think that the real vi is available on RedHat. I assume that the same is true for other distros as well.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Directory Inode Number Not Unique

Hi, I know that inode for each file is unique, but is it the for the directory? So far I found different directories has the same inode nubmer when you do ls -i, could some one explain why? Thanks a lot. (9 Replies)
Discussion started by: nj302
9 Replies

2. Filesystems, Disks and Memory

Inode number

as kernel keeps track of user activities on a file by its INODE number and I node table . what is the structure of Inode table. and where does this Inode table mapped into?user space or kernel space? is the Inode Number is fixed for a file till its deletion? thanks (1 Reply)
Discussion started by: compbug
1 Replies

3. UNIX for Advanced & Expert Users

how to find out pathname from inode number

Hi all when I execute pmap command on one of my daemon process, I am able to see the following output. Address Kbytes RSS Anon Locked Mode Mapped File 00010000 40 40 - - r-x-- irs026bmd 00028000 56 56 16 - rwx-- irs026bmd 00036000... (3 Replies)
Discussion started by: axes
3 Replies

4. UNIX for Dummies Questions & Answers

Number of Inode on a disk

How we can know number of inode present in my Disk including free and occupied. Is there any tool or program to know how much free inode are there in inode free list . (2 Replies)
Discussion started by: mr_deb
2 Replies

5. Filesystems, Disks and Memory

Recreating a deleted hardlink to a file if I know the inode number

At risk of twisting the rules to nearly the point of breaking (if you think this goes too far mods, I apologise and accept that this should be deleted), I'm hoping someone might be able to cast a little light on the following problem regarding hard links to files. ... (6 Replies)
Discussion started by: Smiling Dragon
6 Replies

6. Solaris

How to increase or decrease inode number of the particular UFS filesystem

Hi Gurus I want to know the command & tips regarding, how to increase or decrease inode number of the particular ufs filesystem. Is it possible to do it in a live/production environment. Regards (3 Replies)
Discussion started by: girish.batra
3 Replies

7. AIX

How to get the filename of which has been deleted if I know the inode number?

How to get the filename of which has been deleted if I know the inode number. i can use the command "istat" to get the inode number of the file. # istat /proc//fd/x If this file has been deleted,but the process of this file has not been closed and handle has not been released ,so this... (3 Replies)
Discussion started by: JoyOnLine
3 Replies

8. Shell Programming and Scripting

Modifying a file without changing inode number

Hi all, I am struggling to change the content of a file without changing the inode number. The exact issue is as below. I have a file name test.bak which has 100 lines of text. I am trying to to delete the first 90 lines of the text in the file. I know that using sed/awk/head/tail I can... (3 Replies)
Discussion started by: sathishkmrv
3 Replies

9. Solaris

Retreive deleted file name if you having inode number

Some one please help me to find deleted file name, if I am having inode number in Solaris without using any 3rd party tool. Thanks :) (3 Replies)
Discussion started by: aksijain
3 Replies

10. Linux

Inode number changes for a file in Redhat Linux

Hi, I have created a file a.txt in Redhat Linux. Inode number for a file changes every time i update the file using vi editor , gedit etc. Is there any setting that can be made , such that inode number never changes as that is supposed to be the expected behavior? Or if we cannot... (13 Replies)
Discussion started by: srirammanohar
13 Replies
IOCTL_NS(2)                                                  Linux Programmer's Manual                                                 IOCTL_NS(2)

NAME
ioctl_ns - ioctl() operations for Linux namespaces DESCRIPTION
Discovering namespace relationships The following ioctl(2) operations are provided to allow discovery of namespace relationships (see user_namespaces(7) and pid_names- paces(7)). The form of the calls is: new_fd = ioctl(fd, request); In each case, fd refers to a /proc/[pid]/ns/* file. Both operations return a new file descriptor on success. NS_GET_USERNS (since Linux 4.9) Returns a file descriptor that refers to the owning user namespace for the namespace referred to by fd. NS_GET_PARENT (since Linux 4.9) Returns a file descriptor that refers to the parent namespace of the namespace referred to by fd. This operation is valid only for hierarchical namespaces (i.e., PID and user namespaces). For user namespaces, NS_GET_PARENT is synonymous with NS_GET_USERNS. The new file descriptor returned by these operations is opened with the O_RDONLY and O_CLOEXEC (close-on-exec; see fcntl(2)) flags. By applying fstat(2) to the returned file descriptor, one obtains a stat structure whose st_dev (resident device) and st_ino (inode number) fields together identify the owning/parent namespace. This inode number can be matched with the inode number of another /proc/[pid]/ns/{pid,user} file to determine whether that is the owning/parent namespace. Either of these ioctl(2) operations can fail with the following errors: EPERM The requested namespace is outside of the caller's namespace scope. This error can occur if, for example, the owning user namespace is an ancestor of the caller's current user namespace. It can also occur on attempts to obtain the parent of the initial user or PID namespace. ENOTTY The operation is not supported by this kernel version. Additionally, the NS_GET_PARENT operation can fail with the following error: EINVAL fd refers to a nonhierarchical namespace. See the EXAMPLE section for an example of the use of these operations. Discovering the namespace type The NS_GET_NSTYPE operation (available since Linux 4.11) can be used to discover the type of namespace referred to by the file descriptor fd: nstype = ioctl(fd, NS_GET_NSTYPE); fd refers to a /proc/[pid]/ns/* file. The return value is one of the CLONE_NEW* values that can be specified to clone(2) or unshare(2) in order to create a namespace. Discovering the owner of a user namespace The NS_GET_OWNER_UID operation (available since Linux 4.11) can be used to discover the owner user ID of a user namespace (i.e., the effec- tive user ID of the process that created the user namespace). The form of the call is: uid_t uid; ioctl(fd, NS_GET_OWNER_UID, &uid); fd refers to a /proc/[pid]/ns/user file. The owner user ID is returned in the uid_t pointed to by the third argument. This operation can fail with the following error: EINVAL fd does not refer to a user namespace. ERRORS
Any of the above ioctl() operations can return the following errors: ENOTTY fd does not refer to a /proc/[pid]/ns/* file. CONFORMING TO
Namespaces and the operations described on this page are a Linux-specific. EXAMPLE
The example shown below uses the ioctl(2) operations described above to perform simple discovery of namespace relationships. The following shell sessions show various examples of the use of this program. Trying to get the parent of the initial user namespace fails, since it has no parent: $ ./ns_show /proc/self/ns/user p The parent namespace is outside your namespace scope Create a process running sleep(1) that resides in new user and UTS namespaces, and show that the new UTS namespace is associated with the new user namespace: $ unshare -Uu sleep 1000 & [1] 23235 $ ./ns_show /proc/23235/ns/uts u Device/Inode of owning user namespace is: [0,3] / 4026532448 $ readlink /proc/23235/ns/user user:[4026532448] Then show that the parent of the new user namespace in the preceding example is the initial user namespace: $ readlink /proc/self/ns/user user:[4026531837] $ ./ns_show /proc/23235/ns/user p Device/Inode of parent namespace is: [0,3] / 4026531837 Start a shell in a new user namespace, and show that from within this shell, the parent user namespace can't be discovered. Similarly, the UTS namespace (which is associated with the initial user namespace) can't be discovered. $ PS1="sh2$ " unshare -U bash sh2$ ./ns_show /proc/self/ns/user p The parent namespace is outside your namespace scope sh2$ ./ns_show /proc/self/ns/uts u The owning user namespace is outside your namespace scope Program source /* ns_show.c Licensed under the GNU General Public License v2 or later. */ #include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <fcntl.h> #include <string.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <errno.h> #include <sys/sysmacros.h> #ifndef NS_GET_USERNS #define NSIO 0xb7 #define NS_GET_USERNS _IO(NSIO, 0x1) #define NS_GET_PARENT _IO(NSIO, 0x2) #endif int main(int argc, char *argv[]) { int fd, userns_fd, parent_fd; struct stat sb; if (argc < 2) { fprintf(stderr, "Usage: %s /proc/[pid]/ns/[file] [p|u] ", argv[0]); fprintf(stderr, " Display the result of one or both " "of NS_GET_USERNS (u) or NS_GET_PARENT (p) " "for the specified /proc/[pid]/ns/[file]. If neither " "'p' nor 'u' is specified, " "NS_GET_USERNS is the default. "); exit(EXIT_FAILURE); } /* Obtain a file descriptor for the 'ns' file specified in argv[1] */ fd = open(argv[1], O_RDONLY); if (fd == -1) { perror("open"); exit(EXIT_FAILURE); } /* Obtain a file descriptor for the owning user namespace and then obtain and display the inode number of that namespace */ if (argc < 3 || strchr(argv[2], 'u')) { userns_fd = ioctl(fd, NS_GET_USERNS); if (userns_fd == -1) { if (errno == EPERM) printf("The owning user namespace is outside " "your namespace scope "); else perror("ioctl-NS_GET_USERNS"); exit(EXIT_FAILURE); } if (fstat(userns_fd, &sb) == -1) { perror("fstat-userns"); exit(EXIT_FAILURE); } printf("Device/Inode of owning user namespace is: " "[%lx,%lx] / %ld ", (long) major(sb.st_dev), (long) minor(sb.st_dev), (long) sb.st_ino); close(userns_fd); } /* Obtain a file descriptor for the parent namespace and then obtain and display the inode number of that namespace */ if (argc > 2 && strchr(argv[2], 'p')) { parent_fd = ioctl(fd, NS_GET_PARENT); if (parent_fd == -1) { if (errno == EINVAL) printf("Can' get parent namespace of a " "nonhierarchical namespace "); else if (errno == EPERM) printf("The parent namespace is outside " "your namespace scope "); else perror("ioctl-NS_GET_PARENT"); exit(EXIT_FAILURE); } if (fstat(parent_fd, &sb) == -1) { perror("fstat-parentns"); exit(EXIT_FAILURE); } printf("Device/Inode of parent namespace is: [%lx,%lx] / %ld ", (long) major(sb.st_dev), (long) minor(sb.st_dev), (long) sb.st_ino); close(parent_fd); } exit(EXIT_SUCCESS); } SEE ALSO
fstat(2), ioctl(2), proc(5), namespaces(7) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 IOCTL_NS(2)
All times are GMT -4. The time now is 03:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy