473,394 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

lstat() and stat()

I'm running into an issue.

To my understanding, when lstat() returns -1 (FAILURE) it's because it
hit a broken link?
If that is not the case, then how can i retrieve information on either
a broken link, or even a soft link?
Sep 30 '08 #1
6 7089
On Mon, 29 Sep 2008 19:03:37 -0700 (PDT), onLINES
<do*******@gmail.comwrote in comp.lang.c:
I'm running into an issue.

To my understanding, when lstat() returns -1 (FAILURE) it's because it
hit a broken link?
If that is not the case, then how can i retrieve information on either
a broken link, or even a soft link?
There are no functions named stat() or lstat() in the C standard
library, they are extensions provided by your compiler and operating
system. That makes them off-topic here.

You need to ask this question in a group that supports your particular
compiler/OS combination. Based on the headers in your post, it is
possible that news:comp.os.ms-windows.programmer.win32 might be a good
choice.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Sep 30 '08 #2
onLINES <dopeli...@gmail.comwrote:
I'm running into an issue.

To my understanding, when lstat() returns -1 (FAILURE)
it's because it hit a broken link?
If that is not the case, then how can i retrieve
information on either a broken link, or even a soft link?
lstat is not a standard C function. I suggest you take your
question to POSIX or *nix group. I also suggest you RTM and
Google your question before posting.

--
Peter
Sep 30 '08 #3
onLINES wrote, On 30/09/08 03:03:
I'm running into an issue.

To my understanding, when lstat() returns -1 (FAILURE) it's because it
hit a broken link?
If that is not the case, then how can i retrieve information on either
a broken link, or even a soft link?
stat and stat are not part of the C standard. They are, however,
extensions provided on Unix. So I suggest you ask on
comp.unix.programmer where there are lots of people who know about Unix
extensions.

It is possible that someone here will provide what looks like a useful
answer, but as the real experts are not here but over in
comp.unix.programmer there is a real possibility that any errors on what
they say won't be corrected (or better solutions be pointed out) and
such errors might not show up until you try demonstrating the code to
your boss.
--
Flash Gordon
If spamming me sent it to sm**@spam.causeway.com
If emailing me use my reply-to address
See the comp.lang.c Wiki hosted by me at http://clc-wiki.net/
Sep 30 '08 #4
On 30 Sep 2008 at 2:03, onLINES wrote:
To my understanding, when lstat() returns -1 (FAILURE) it's because it
hit a broken link?
If that is not the case, then how can i retrieve information on either
a broken link, or even a soft link?
You are quite mistaken. lstat() will stat the symlink itself, and not
the file that it refers to. Since it therefore never tries to follow the
link, how could it know it's broken?

If you try to stat() a broken link, stat() will return -1 and set errno
to indicate that there is no such file or directory.

The stat(2) manpage lists all the possible things errno can be set to.

Sep 30 '08 #5
onLINES wrote:
I'm running into an issue.

To my understanding, when lstat() returns -1 (FAILURE) it's because it
hit a broken link?
As per my understanding (of the POSIX manual page of lstat) your
understanding is wrong
If that is not the case, then how can i retrieve information on either
a broken link, or even a soft link?
[OT]
Assuming you mean the lstat from POSIX:
Whether the filename fed to lstat() is a symbolic link is encoded into
st_mode, which will have S_IFLINK set in this case.
stat() will report an error if operating on an orphaned symbolic link, so
first call lstat(), check whether st_mode has S_IFLINK set, then call stat
and check whether it fails with ernno set to ENOENT
[/OT]

Bye, Jojo
Sep 30 '08 #6
Flash Gordon <sm**@spam.causeway.comwrites:
onLINES wrote, On 30/09/08 03:03:
>I'm running into an issue.
To my understanding, when lstat() returns -1 (FAILURE) it's because
it
hit a broken link?
If that is not the case, then how can i retrieve information on either
a broken link, or even a soft link?

stat and stat are not part of the C standard. They are, however,
extensions provided on Unix. So I suggest you ask on
comp.unix.programmer where there are lots of people who know about
Unix extensions.
[...]

But if you ask this question on comp.unix.programmer, their first
question for you will be why you didn't read the documentation first.
So read the documentation first.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 30 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steven T. Hatton | last post by:
I found the following two statements in the file linked below: struct stat st; stat(fileName.c_str(), &st); http://websvn.kde.org/branches/work/kdevelop4-parser/main.cpp?rev=420247&view=markup...
10
by: David Farning | last post by:
I am new to c and not yet sure of the boundary between c and it's implementations. So please redirect me if this should be asked elsewhere. I am working on a function to determine if a directory...
5
by: diadia | last post by:
#include <sys/types.h> #include <sys/stat.h> #include "ctype.h" #include <stdio.h> int estimateLen(struct stat buf, FILE *fp) { size_t _size = buf.st_size / 4;
2
by: Michael Glassford | last post by:
The Python 2.5 News at http://www.python.org/download/releases/2.5/NEWS.txt states that Python 2.5 was changed to "Use Win32 API to implement os.stat/fstat. As a result, subsecond timestamps are...
6
by: one2001boy | last post by:
Hello, I tried to find the access time of a file using stat() function. but the following C code in windows vc.net 2003 always give the same access time. the same code works correctly in linux...
6
by: Hansen | last post by:
Hi Group, I've made a statistic module for our framework, and have put it in a namespace called stat (which resides in a namespace called dao) My problem is that now the compiler thinks that it...
24
by: Joe Salmeri | last post by:
I just upgraded from Python 2.4.2 to Python 2.5.1 and have found some unexpected behavior that appears to be a bug in the os.stat module. My OS is Windows XP SP2 + all updates. I have several...
2
by: Giampaolo Rodola' | last post by:
Hi there. In a code of mine I'd like to use os.lstat whenever possible. My only concern is if it's available on all platforms. It could be safe using always os.lstat instead of: try: os.lstat...
3
by: Deniz Dogan | last post by:
Hello. I have a question regarding the st_mode field of the "stat" struct in sys/stat.h. I'd like to know how to use the S_IRWXU, S_IRWXG and S_IRWXO flags to mask the mode_t value into human...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.