Sponsored Content
Full Discussion: Hi errno in sys/stat.h
Top Forums Programming Hi errno in sys/stat.h Post 302095890 by Perderabo on Saturday 11th of November 2006 07:48:11 PM
Old 11-11-2006
According to the latest Posix Standard:
Quote:
It is unspecified whether errno is a macro or an identifier declared with external linkage. If a macro definition is suppressed in order to access an actual object, or a program defines an identifier with the name errno, the behavior is undefined.
This means that:
extern int errno;
is not legal anymore. You are supposed to include errno.h and depend on that include file to define errno for you. You will get unpredicable behavior if you use the external variable in a multi-threaded process.
 

10 More Discussions You Might Find Interesting

1. Programming

Getting errno in a Multithreaded program

In Tru64 Unix, the 'errno' variable is not thread safe. Could anybody help me about how to make it thread safe or how to check 'errno' in a Multithreaded program ???? The Programming process is like this. There are some definite number of threads having their own task. There is one... (2 Replies)
Discussion started by: S.Vishwanath
2 Replies

2. UNIX for Dummies Questions & Answers

login error after sys-unconfig, errno = 13

Hi, I have a SPARCstation 10 with SunOS 5.6 This erlier was in a network and now I have it at home to make a webserver. At fist there was NIS and things left from erlier. So the "Console login:" newer appered only the white window with sun logo topleft and some text info. I made... (14 Replies)
Discussion started by: roing
14 Replies

3. Programming

errno pb

Hello, I need to make a lib with pthread, when I run my make file all is good. But when I run my test program, I test errno in the begining and is already set to 251. Is it normal ??? What can I modify in my Makefile to have errno set to 0 ??? Thanks $make gcc -D_REENTRANT -shared -fpic... (3 Replies)
Discussion started by: dts
3 Replies

4. Programming

errno

Hey, Can I assume that for certain function calls, errno can never be set to a certain value. More specifically, can I assume that for if the stat function call fails, the errno can never be or "No space left on device." I am assuming that a read function cannot fail because of no space... (5 Replies)
Discussion started by: the_learner
5 Replies

5. Programming

does perror() set errno?

here the program gives a odd result: #include <stdio.h> int main(){ perror("first"); perror("next"); return 0; } result: first: Success next: Illegal seek why? any resonable explanation? i found no information about this in man pages. thanks in advance (2 Replies)
Discussion started by: ebd
2 Replies

6. Programming

Open function of sys/stat.h

If a process already has the entire file locked for read and write using newstruct.l_type = F_WRLCK; what would happen if another process would try to open it in read only mode using open(filename, O_RDONLY); ? I want to check if the file exists and I want it to work even if another process has... (4 Replies)
Discussion started by: cyler
4 Replies

7. Solaris

How to resolve error "INIT: Cannot stat /etc/inittab, errno: 2"

Hi All, I am getting an error message when I execute command “zlogin -C sunsrv4z5” on my root server. INIT: Cannot stat /etc/inittab, errno: 2 INIT: Cannot stat /etc/inittab, errno: 2 As per my analysis it seems that some files inside /etc folder are deleted. This server was... (14 Replies)
Discussion started by: surbhit4u
14 Replies

8. Linux

[Errno 256] No more mirrors to try.

Dear all, CentOS 6 After executing "yum update -y" command I am facing this error. Please help me out. thanks in advance. Full error & error code is given as follow: ... (7 Replies)
Discussion started by: saqlain.bashir
7 Replies

9. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies

10. AIX

Errno.h symbols

Hi, I need to look at a recent copy of /usr/include/errno.h from AIX 7.2 to check some symbols. In particular, I'm curious if it defines EOWNERDEAD and ENOTRECOVERABLE. Can someone who has access to 7.2 please check for me? Thanks! (1 Reply)
Discussion started by: topcat
1 Replies
stat(2) 							System Calls Manual							   stat(2)

NAME
stat, fstat, lstat - Provides information about a file SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> int stat( const char *path, struct stat *buffer ); int lstat( const char *path, struct stat *buffer ); int fstat( int filedes, struct stat *buffer ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: fstat(): POSIX.1, XSH5.0 lstat(): POSIX.1, XSH5.0 stat(): POSIX.1, XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the pathname identifying the file. Specifies the file descriptor identifying the open file. Points to the stat structure in which information is returned. The stat structure is described in the <sys/stat.h> header file. DESCRIPTION
The stat() function obtains information about the file named by the path parameter. Read, write, or execute permission for the named file is not required, but all directories listed in the pathname leading to the file must be searchable. The file information is written to the area specified by the buffer parameter, which is a pointer to a stat structure, defined in sys/stat.h. The values of the stat structure's member, mode_t, are defined in <sys/mode.h>. The fstat() function is like the stat() function except that the information obtained is about an open file referenced by the filedes parameter. The lstat() function is like the stat() function except in the case where the named file is a symbolic link. In this case, the lstat() function returns information about the link, while the stat() and fstat() functions return information about the file the link references. In the case of a symbolic link, the stat() functions set the st_size field of the stat structure to the length of the symbolic link, and sets the st_mode field to indicate the file type. The stat(), lstat(), and fstat() functions update any time-related fields associated with the file before writing into the stat structure. [Tru64 UNIX] When run on a file in an AdvFS clone fileset, the value returned for st_blocks is the number of blocks in the original file at the time the clone fileset was created. NOTES
Two structure members in <stat.h> uniquely identify a file in a file system: st_ino, the file serial number, and st_dev, the device id for the directory that contains the file. [Tru64 UNIX] However, in the rare case when a user application has been deleting open files, and a file serial number is reused, a third structure member in <stat.h>, the file generation number, is needed to uniquely identify a file. This member, st_gen, is used in addition to st_ino and st_dev. RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the stat() or lstat() function fails, errno may be set to one of the following values: Search permission is denied for a component of the path parameter. Either the buffer parameter or the path parameter points to a location outside of the allocated address space of the process. An I/O error occurred while reading from the file system. Too many links were encountered in translating path. The length of the path parameter exceeds PATH_MAX or a pathname component is longer than NAME_MAX. The file named by the path parameter does not exist or is an empty string. A component of the path parameter is not a directory. [Tru64 UNIX] The structure pointed to by the buffer argu- ment cannot correctly represent the value to be returned. This error occurs in applications compiled either on a system earlier than Tru64 UNIX Version 5.0 or on any system while using the __V40_OBJ_COMPAT compiler macro. These applications use a <statfs> structure for the for st_blocks fields that is not compatible with the same structure in Tru64 UNIX Version 5.0. [Tru64 UNIX] For NFS file access, if the stat() or lstat() function fails, errno may also be set to one of the following values: The file position pointer associated with the filedes parameter was negative. Indicates either that the request was for a write access to a file but the specified filename was actually a directory, or that the function was trying to rename a directory as a file. Indicates either that the system file table is full, or that there are too many files currently open in the system. Indicates a stale NFS file handle. An opened file was deleted by the server or another client; a client cannot open a file because the server has unmounted or unexported the remote directory; or the directory that contains an opened file was either unmounted or unexported by the server. If the fstat() function fails, errno may be set to one of the following values: The filedes parameter is not a valid file descriptor. The buffer parameter points to a location outside of the allocated address space of the process. An I/O error occurred while reading from the file system. [Tru64 UNIX] The structure pointed to by the buffer argument cannot correctly represent the value to be returned. This error occurs in applications compiled either on a system earlier than Tru64 UNIX Version 5.0 or or on any system while using the __V40_OBJ_COMPAT compiler macro. These applications use a <statfs> structure for st_blocks fields that is not compatible with the same structure in Tru64 UNIX Version 5.0 or later. RELATED INFORMATION
Functions: chmod(2), chown(2), link(2), mknod(2), open(2), pipe(2), symlink(2), utime(2) Standards: standards(5) delim off stat(2)
All times are GMT -4. The time now is 01:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy