The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Q with stat() JamesGoh High Level Programming 3 09-11-2008 09:30 PM
stat gajju UNIX for Advanced & Expert Users 6 09-08-2008 09:55 PM
Cannot stat? lgardner UNIX for Dummies Questions & Answers 1 05-27-2005 04:05 PM
stat command emreatlier Shell Programming and Scripting 2 08-14-2003 04:03 PM
stat() fails!!! what can i do? solvman High Level Programming 3 02-06-2002 05:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2008
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 255
Thumbs up stat fails HP unix

Hi all,

I have scenario here , In my C program i check the stat for a file as
stat(fname, &stat_buf);

If it is succesfull, i will process else i will make my program to fail.

The file which i am checking has no stat information. What might be the reason, file has no stat information even though it has all data loaded

I am using HP unix

(sys05nmx:/pmx/d4>) ll 173_i.001
-rw-rw-rw- 1 pmx00 pmx 4941517719 Oct 6 13:37 173_i.001



(sys05nmx:/pmx/d4>)stat 173_i.001
Can't lstat 100373_ipd.001



Please help, stat is working for all other files , only for this file it is not working what might be the reason.

Thanks in Advance,
Arun
  #2 (permalink)  
Old 10-10-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
The stat() function call returns -1 on error. Are you checking the return code?
Then finding what errno references to produce a meaningful error message?
perror() will do that for you.

lstat() works on symlinks only -- you aren't calling lstat? Even though your error message says so.

These are the two calls you should be using. stat() is a much more likely choice.
Code:
int stat(const char *path, struct stat *buf);
int fstat(int filesdes, struct stat *buf);
  #3 (permalink)  
Old 10-10-2008
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 255
This is my Code

ret = stat(fname, &stat_buf);
if (ret == 0)
return &stat_buf;
else
{
fprintf(stderr,"stat: Can't get filesystem information\n");
fprintf(stderr,"stat: Current file %s\n", fname);
perror("stat");
abort();
}


The below is the error

stat: Can't get filesystem information
stat: Current file /pmx/d4/173_i.001
stat: Value too large to be stored in data type
sm_au3[336]: 4740 Abort(coredump)



I am trying to find the stat for a file with size 4.60215 GB , Is it caousing the problem,
I mean the file size is a problem ???

Thanks in Advance,
Arun
  #4 (permalink)  
Old 10-10-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
You have a largefiles problem. Base stat has a size_t st.size element. It can handle up to the max un unsigned loing value can store.

If the output of this:
Code:
getconf ULONG_MAX
is less than the size of the file then that is your problem. You will have to do some reading on large files for your system - there may be a stat64 or fstat64 call which will handle the issue. What OS?
  #5 (permalink)  
Old 10-10-2008
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 255
Thanks for your answer

This is in HP UNIX
  #6 (permalink)  
Old 10-10-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
Then you do have stat64(), fopen64() etc.

man stat64 will explain it.
  #7 (permalink)  
Old 10-11-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,859
Do a Web search for LFS (Large File Summit) for more information about file size limitations on ILP32 data models and how this problem was overcome.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0