Sponsored Content
Full Discussion: Specify the inode of a file?
Operating Systems Solaris Specify the inode of a file? Post 302895134 by bartus11 on Friday 28th of March 2014 03:00:30 PM
Old 03-28-2014
I've modified the DTrace script to handle "fstat64" as well:
Code:
BEGIN
{
  filename = "passwd";
}

syscall::stat64:entry, syscall::lstat64:entry
/strstr(copyinstr(arg0), filename) != NULL/
{
  self->statptr = arg1;
}

syscall::fstat64:entry
/strstr(fds[arg0].fi_name, filename) != NULL/
{
  self->statptr = arg1;
}

syscall::stat64:return, syscall::lstat64:return
/self->statptr != NULL && curpsinfo->pr_dmodel == PR_MODEL_ILP32/
{
  self->st64_32 = (struct stat64_32 *)copyin(self->statptr, sizeof(struct stat64_32));
  self->st64_32->st_ino = 100000000000;
  copyout(self->st64_32, self->statptr, sizeof(struct stat64_32));
}

syscall::stat64:return, syscall::lstat64:return
/self->statptr != NULL && curpsinfo->pr_dmodel == PR_MODEL_LP64/
{
  self->st64 = (struct stat64 *)copyin(self->statptr, sizeof(struct stat64));
  self->st64->st_ino = 100000000000;
  copyout(self->st64, self->statptr, sizeof(struct stat64));
}

syscall::fstat64:return
/self->statptr != NULL && curpsinfo->pr_dmodel == PR_MODEL_ILP32/
{
  self->st64_32 = (struct stat64_32 *)copyin(self->statptr, sizeof(struct stat64_32));
  self->st64_32->st_ino = 100000000000;
  copyout(self->st64_32, self->statptr, sizeof(struct stat64_32));
}

syscall::fstat64:return
/self->statptr != NULL && curpsinfo->pr_dmodel == PR_MODEL_LP64/
{
  self->st64 = (struct stat64 *)copyin(self->statptr, sizeof(struct stat64));
  self->st64->st_ino = 100000000000;
  copyout(self->st64, self->statptr, sizeof(struct stat64));
}

Simple test to see if it is really working:
Code:
# perl -le 'open $fh, "<", "/etc/passwd";print ((stat $fh)[1])' 
100000000000

BTW, when faking the inode for "/etc/passwd", I noticed that I can not login to the server by SSH, so it is probably better to use some other file name for your tests Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

file access inode update

When is a file "accessed" according to UNIX? For example: gzipping a file will not change the access time. (1 Reply)
Discussion started by: dangral
1 Replies

2. Ubuntu

fd.file-max against inode

Hi, If inodes need to be 3-4 times greater than fd.file-max. Can you modify the current inode in the filesystem? Can you modify it on the fly? Or only in the creation of FS. I'm using redhat ent 4. Thank you for any comment you may add. (1 Reply)
Discussion started by: itik
1 Replies

3. 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

4. Shell Programming and Scripting

Read from file specific place in file using inode

Hello, I am using tcsh on AIX. I would like to write a script that does the following: 1. given an inode, how do I find exactly the name of the file? I know I could do this using ls -i | grep <inode> but it returns: <inode> <filename>. I need some string manipulation or something to... (1 Reply)
Discussion started by: lastZenMaster
1 Replies

5. 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

6. Shell Programming and Scripting

changing a file when the inode modified time of the other file changes

i have a requirement where i needed to change variable values in a properties file(first file) whenever there is change to Release details file(second file). My question is do i have to create a daemon process that always checks the modified time/inode change of the second file and then change the... (1 Reply)
Discussion started by: saikiran_1984
1 Replies

7. Red Hat

Inode number changes for a file in Redhat Linux

Hi, I have created a file abc.log in Redhat Linux. Inode number for a file get changes every time i update the file using vi editor. Is there any setting that can be made , such that inode number never gets changed? Or if we cannot restrict from inode number getting changed , is... (9 Replies)
Discussion started by: raghu.amilineni
9 Replies

8. UNIX for Advanced & Expert Users

remove file/inode entry

Hello all, I am on hpux itanium 11.31...and we run a oracle DB on it. I am testing some backup and restore situation.... first i select some data from the DB.....now i remove some files from the DB where my data is being selected from.....now i select the same data from the DB but i still get... (5 Replies)
Discussion started by: abdul.irfan2
5 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
lf64(5) 						Standards, Environments, and Macros						   lf64(5)

NAME
lf64 - transitional interfaces for 64-bit file offsets DESCRIPTION
The data types, interfaces, and macros described on this page provide explicit access to 64-bit file offsets. They are accessible through the transitional compilation environment described on the lfcompile64(5) manual page. The function prototype and semantics of a transi- tional interface are equivalent to those of the standard version of the call, except that relevant data types are 64-bit entities. Data Types The following tables list the standard data or struct types in the left-hand column and their corresponding explicit 64-bit file offset types in the right-hand column, grouped by header. The absence of an entry in the left-hand column indicates that there is no existing explicit 32-bit type that corresponds to the 64-bit type listed in the right--hand column. Note that in a 64-bit application, the standard definition is equivalent to the 64-bit file offset definition. <aio.h> struct aiocb struct aiocb64 off_t aio_offset; off64_t aio_offset; <sys/dirent.h> struct dirent struct dirent64 ino_t d_ino; ino64_t d_ino; off_t d_off; off64_t d_off; <sys/fcntl.h> struct flock struct flock64 off_t l_start; off64_t l_start; off_t l_len; off64_t l_len; F_SETLK F_SETLK64 F_SETLKW F_SETLKW64 F_GETLK F_GETLK64 F_FREESP F_FREESP64 O_LARGEFILE <sys/stdio.h> fpos_t fpos64_t <sys/resource.h> rlim_t rlim64_t struct rlimit struct rlimit64 rlim_t rlim_cur; rlim64_t rlim_cur; rlim_t rlim_max; rlim64_t rlim_max; RLIM_INFINITY RLIM64_INFINITY RLIM_SAVED_MAX RLIM64_SAVED_MAX RLIM_SAVED_CUR RLIM64_SAVED_CUR <sys/stat.h> struct stat struct stat64 ino_t st_ino; ino64_t st_ino; off_t st_size; off64_t st_size; blkcnt_t st_blocks; blkcnt64_t st_blocks; <sys/statvfs.h> struct statvfs struct statvfs64 fsblkcnt_t f_blocks; fsblkcnt64_t f_blocks; fsblkcnt_t f_bfree; fsblkcnt64_t f_bfree; fsblkcnt_t f_bavial; fsblkcnt64_t f_bavial; fsfilcnt_t f_files; fsfilcnt64_t f_files; fsfilcnt_t f_ffree; fsfilcnt64_t f_ffree; fsfilcnt_t f_favail; fsfilcnt64_t f_favail; <sys/types.h> off_t; off64_t; ino_t; ino64_t; blkcnt_t; blkcnt64_t; fsblkcnt_t; fsblkcnt64_t; fsfilcnt_t; fsfilcnt64_t; <unistd.h> _LFS64_LARGEFILE _LFS64_STDIO <sys/unistd.h> _CS_LFS64_CFLAGS _CS_LFS64_LDFLAGS _CS_LFS64_LIBS _CS_LFS64_LINTFLAGS System Interfaces The following tables display the standard API and the corresponding transitional interfaces for 64-bit file offsets. The interfaces are grouped by header. The interface name and the affected data types are displayed in courier font. <aio.h> int aio_cancel(..., int aio_cancel64(..., struct aiocb *); struct aiocb64 *); int aio_error( int aio_error64( const struct aiocb *); const struct aiocb64 *); int aio_fsync(..., int aio_fsync64(..., struct aiocb *); struct aiocb64 *); int aio_read(struct aiocb *); int aio_read64(struct aiocb64 *); int aio_return(struct aiocb *); int aio_return64(struct aiocb64 *); int aio_suspend( int aio_suspend64( const struct aiocb *, ...); const struct aiocb64 *, ...); int aio_waitn(aiocb_t *[], int aio_waitn64(aiocb64_t *[], ...); ...); int aio_write(struct aiocb *); int aio_write64(struct aiocb64 *); int lio_listio(..., int lio_listio64(..., const struct aiocb *, ...); const struct aiocb64 *, ...); <dirent.h> int alphasort(const struct int alphasort64(const struct dirent **, const struct dirent64 **, const struct dirent **) dirent64 **) struct dirent *readdir(); struct dirent64 *readdir64(); struct dirent *readdir_r(); struct dirent64 *readdir64_r(); int scandir(..., struct int scandir64(..., struct dirent *(*[]), int dirent64 *(*[]), int (*)(const (*)(const struct dirent *), struct dirent64 *), int int (*)(const struct dirent (*)(const struct dirent64 **, **, const struct dirent const struct dirent64 **)) **)) <fcntl.h> int attropen(); int attropen64(); int creat(); int creat64(); int open(); int open64(); int openat(); int openat64(); <ftw.h> int ftw(..., int ftw64(..., const struct stat *, ...); const struct stat64 *, ...); int nftw(.. int nftw64(..., const struct stat *, ...); const struct stat64 *, ...); <libgen.h> char *copylist(..., off_t); char *copylist64(..., off64_t); <stdio.h> int fgetpos(); int fgetpos64(); FILE *fopen(); FILE *fopen64(); FILE *freopen(); FILE *freopen64(); int fseeko(..., off_t, ...); int fseeko64(..., off64_t, ...); int fsetpos(..., int fsetpos64(..., const fpos_t *); const fpos64_t *); off_t ftello(); off64_t ftello64()(); FILE *tmpfile(); FILE *tmpfile64(); <stdlib.h> int mkstemp(); int mkstemp64(); <sys/async.h> int aioread(..., off_t, ...); int aioread64(..., off64_t, ...); int aiowrite(..., off_t, ...); int aiowrite64(..., off64_t, ...); <sys/dirent.h> int getdents(..., dirent); int getdents64(..., dirent64); <sys/mman.h> void mmap(..., off_t); void mmap64(..., off64_t); <sys/resource.h> int getrlimit(..., int getrlimit64(..., struct rlimit *); struct rlimit64 *); int setrlimit(..., int setrlimit64(..., const struct rlimit *); const struct rlimit64 *); <sys/sendfile.h> ssize_t sendfile(..., ssize_t sendfile64(..., off_t *, ...); off64_t *, ...); ssize_t sendfilev(..., const ssize_t sendfilev64(..., const struct sendfilevec *, ...); struct sendfilevec64 *, ...); <sys/stat.h> int fstat(..., struct stat *); int fstat64(..., struct stat64 *); int fstatat(..., int fstatat64(..., struct stat *, int); struct stat64 *, int); int lstat(..., struct stat *); int lstat64(..., struct stat64 *); int stat(..., struct stat *); int stat64(..., struct stat64 *); <sys/statvfs.h> int statvfs(..., int statvfs64(..., struct statvfs *); struct statvfs64 *); int fstatvfs(..., int fstatvfs64(..., struct statvfs *); struct statvfs64 *); <ucbinclude/stdio.h> FILE *fopen() FILE *fopen64() FILE *freopen() FILE *freopen64() <ucbinclude/sys/dir.h> int alphasort( int alphasort64( struct direct **, struct direct64 **, struct direct **); struct direct64 **); struct direct *readdir(); struct direct64 *readdir64(); int scandir(..., int scandir64(..., struct direct *(*[]);, ...); struct direct64 *(*[]);, ...); <unistd.h> int lockf(..., off_t); int lockf64(..., off64_t); off_t lseek(..., off_t, ...); off64_t lseek64(..., off64_t, ...); int ftruncate(..., off_t); int ftruncate64..., off64_t); ssize_t pread(..., off_t); ssize_t pread64..., off64_t); ssize_t pwrite(..., off_t); ssize_t pwrite64(..., off64_t); int truncate(..., off_t); int truncate64(..., off64_t); SEE ALSO
lfcompile(5), lfcompile64(5) SunOS 5.10 5 May 2004 lf64(5)
All times are GMT -4. The time now is 06:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy