Sponsored Content
Full Discussion: lstat long path problem
Top Forums Programming lstat long path problem Post 302248104 by Saurabh78 on Friday 17th of October 2008 03:13:11 AM
Old 10-17-2008
Jim, thanks for input.
But i like the substitute of lstat. So, i will get the same info as lstat but also support the long path.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl: why the return valure of stat and lstat are the same?

i tried to use stat to get the attributes of a file and a soft link. but the result i got from stat and lstat are the same. say: ln -s f1 soft1 (soft is a soft link , point to f1) if i use > ls -il shows the inode and modify time of soft1 and f1 are different. but the modify... (1 Reply)
Discussion started by: gusla
1 Replies

2. UNIX for Dummies Questions & Answers

cc path problem - no acceptable path found

Hello everyone, I'm a unix noob. I have a powerbook running mac os x 10.4 and for one of my classes I need to install the latest version of php (5.0.5). I'm following the instructions at http://developer.apple.com/internet/opensource/php.html to install but I've run into a problem. The... (2 Replies)
Discussion started by: kendokendokendo
2 Replies

3. Shell Programming and Scripting

Searching for SETUID and SETGID using PERL file find with lstat

About System and Perl: Sun Solaris 5.9 sparc, Perl 5.6.1 I've decided to use the perl file::find module to look for all the SETUID and SETGID files on my unix boxes. I wrote something like this: (I've shorted it a little to make it simple) #!/opt/perl/bin/perl use File::Find; find... (1 Reply)
Discussion started by: x96riley3
1 Replies

4. AIX

mkdir: A file or path name is too long

Hi, I have an AIX machine. I am trying to create a directory from within the script, but the message being shown is "mkdir: 0653-358 Cannot create directory 'xxx': A file or path name is too long" I am not giving any 'long' pathname to mkdir. The commands being issued within the script are: ... (0 Replies)
Discussion started by: greenhorn007
0 Replies

5. Windows & DOS: Issues & Discussions

Long UNC path not working in CMD.EXE on remote machine

Hi, I am trying to connect to a remote server using Plink tool. Both my local and remote machines are Windows. On remote server, I have OpenSSH server installed. I am able to run commands on remote machine but there is some problem with long UNC path, which I noticed today. For... (3 Replies)
Discussion started by: Technext
3 Replies

6. Shell Programming and Scripting

specified path name is too long passing parameters to awk via shell script

Hello, I have this shell script that runs awk code by passing in parameters however now it doesn't work anymore with the parameters and I don't know why. It removes duplicates from an input file based on a part of the last field and a key column. It removes the record with the older datetime... (0 Replies)
Discussion started by: script_op2a
0 Replies

7. Shell Programming and Scripting

0403-035 specified path name too long

I get this error when attempting to run a simple .ksh script. This script runs fine on other servers. What causes this error? (3 Replies)
Discussion started by: ivanachukapawn
3 Replies

8. Programming

lstat problem

Hello, I have a little problem with lstat. I use the find utility, to find a path for a file in my system. After that,I take that path and I pass it in lstat, but lstat returns -1, and this error : no such file or directory. So I m trying to "ls" the path in the shell, but it also fails. ... (1 Reply)
Discussion started by: garag11
1 Replies

9. UNIX for Dummies Questions & Answers

lstat problem

Hello, I have a little problem with lstat. I use the find utility, to find a path for a file in my system. After that,I take that path and I pass it in lstat, but lstat returns -1, and this error : no such file or directory. So I m trying to "ls" the path in the shell, but it also fails. ... (2 Replies)
Discussion started by: garag11
2 Replies

10. Shell Programming and Scripting

Long PATH, LD_LIBRARY_PATH, LIBPATH, … – what kind of performance impact do they have?

Hi, there! a long PATH... makes the OS access the disk quite often, hence there is a lot of disk I/O a long PATH... makes the OS compute a lot of ..., hence a high CPU load (Edited/added later: Yes, this is not about the lenght of the env. var., but about the number of directories listed.)... (1 Reply)
Discussion started by: Jochen_Hayek
1 Replies
READLINK(2)						     Linux Programmer's Manual						       READLINK(2)

NAME
readlink - read value of a symbolic link SYNOPSIS
#include <unistd.h> ssize_t readlink(const char *path, char *buf, size_t bufsiz); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): readlink(): _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _POSIX_C_SOURCE >= 200112L DESCRIPTION
readlink() places the contents of the symbolic link path in the buffer buf, which has size bufsiz. readlink() does not append a null byte to buf. It will truncate the contents (to a length of bufsiz characters), in case the buffer is too small to hold all of the contents. RETURN VALUE
On success, readlink() returns the number of bytes placed in buf. On error, -1 is returned and errno is set to indicate the error. ERRORS
EACCES Search permission is denied for a component of the path prefix. (See also path_resolution(7).) EFAULT buf extends outside the process's allocated address space. EINVAL bufsiz is not positive. EINVAL The named file is not a symbolic link. EIO An I/O error occurred while reading from the file system. ELOOP Too many symbolic links were encountered in translating the pathname. ENAMETOOLONG A pathname, or a component of a pathname, was too long. ENOENT The named file does not exist. ENOMEM Insufficient kernel memory was available. ENOTDIR A component of the path prefix is not a directory. CONFORMING TO
4.4BSD (readlink() first appeared in 4.2BSD), POSIX.1-2001. NOTES
In versions of glibc up to and including glibc 2.4, the return type of readlink() was declared as int. Nowadays, the return type is declared as ssize_t, as (newly) required in POSIX.1-2001. Using a statically sized buffer might not provide enough room for the symbolic link contents. The required size for the buffer can be obtained from the stat.st_size value returned by a call to lstat(2) on the link. However, the number of bytes written by readlink() should be checked to make sure that the size of the symbolic link did not increase between the calls. Dynamically allocating the buffer for read- link() also addresses a common portability problem when using PATH_MAX for the buffer size, as this constant is not guaranteed to be defined per POSIX if the system does not have such limit. EXAMPLE
The following program allocates the buffer needed by readlink() dynamically from the information provided by lstat(), making sure there's no race condition between the calls. #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { struct stat sb; char *linkname; ssize_t r; if (argc != 2) { fprintf(stderr, "Usage: %s <pathname> ", argv[0]); exit(EXIT_FAILURE); } if (lstat(argv[1], &sb) == -1) { perror("lstat"); exit(EXIT_FAILURE); } linkname = malloc(sb.st_size + 1); if (linkname == NULL) { fprintf(stderr, "insufficient memory "); exit(EXIT_FAILURE); } r = readlink(argv[1], linkname, sb.st_size + 1); if (r == -1) { perror("lstat"); exit(EXIT_FAILURE); } if (r > sb.st_size) { fprintf(stderr, "symlink increased in size " "between lstat() and readlink() "); exit(EXIT_FAILURE); } linkname[r] = ''; printf("'%s' points to '%s' ", argv[1], linkname); exit(EXIT_SUCCESS); } SEE ALSO
readlink(1), lstat(2), readlinkat(2), stat(2), symlink(2), path_resolution(7), symlink(7) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2013-07-18 READLINK(2)
All times are GMT -4. The time now is 11:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy