LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-12-2019, 03:03 PM   #1
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.3 with Cinnamon & KDE
Posts: 1,668
Blog Entries: 3

Rep: Reputation: 105Reputation: 105
how many chars/bytes can 'pathname' be using 'open' or 'fopen'


I believe that the shell and some utilities have a limit of 256 chars total characters in a path+filename. I've read all of the C-library man pages and do not find mention of a limit within the library routine descriptions.

pathname apppears and is a pointer to array of char item. Since I might 'malloc( )' any size and load that array, will open( ), fopen( ) and friends handle whatever I feed it?

ASIDE -- Wrote a lot of embedded C-code in the 80s and 90s. There is lots of rust and dust on what I remember, and even more changes to what is current implementation and practice.

Thanks in advance,
~~~ 0;-Dan
 
Old 09-13-2019, 07:56 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,334

Rep: Reputation: 362Reputation: 362Reputation: 362Reputation: 362
Hi

It's PATH_MAX

https://stackoverflow.com/questions/...fined-in-linux

Some comments there too about if the last \0 is included or not...
 
Old 09-26-2019, 04:03 PM   #3
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.3 with Cinnamon & KDE
Posts: 1,668

Original Poster
Blog Entries: 3

Rep: Reputation: 105Reputation: 105
Quote:
Originally Posted by Guttorm View Post
Hi

It's PATH_MAX

https://stackoverflow.com/questions/...fined-in-linux

Some comments there too about if the last \0 is included or not...
Since this value is part of the header /usr/include/*/limits.h and I see the value of 4096 on my workstation, am I correct that whatever appears as a path+filename+filetype must be less than this number? Does "pathname" include any remote-node or similar prefix? What about IP address and socket number? I did not find any details about "pathname" length when reading man 2 open.

I tried to inspect PATH_MAX using both of these:
Code:
prompt$  set | grep PAT
... and ...
Code:
prompt$  env | grep PAT
Neither displayed anything that came close to the PATH_MAX that you named.
NOTE -- 'sudo' didn't change the results. I take this to mean that the "pathname" length is hard-coded into whichever application is doing the file-open operations.

Thanks in advance,
~~~ 0;-Dan
 
Old 09-30-2019, 12:17 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,670

Rep: Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487
As you discovered, it's in the C ..h include file; it's not an env setting.
 
1 members found this post helpful.
Old 09-30-2019, 04:51 PM   #5
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.3 with Cinnamon & KDE
Posts: 1,668

Original Poster
Blog Entries: 3

Rep: Reputation: 105Reputation: 105
Thanks to all who made the effort to reply.

Cheers,
~~~ 0;-Dan
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sed: replace regexp w/ variable #s of chars with the same # of (diff.) chars? kmkocot Linux - Newbie 6 11-18-2011 05:36 AM
"Too many open files in system" PHP fopen() MicahCarrick Programming 5 12-20-2007 08:40 PM
TX bytes vs. httpd bytes ovrload Linux - Networking 3 10-12-2005 04:19 PM
Use of unsigned chars as _real_ bytes (abyte=10111100) elmafiacs Programming 8 08-31-2004 06:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration