Creation of directoryname with Max limit

Hi,

Please provide your inputs..

# define PATH_MAX 1023 /* max number of characters in a pathname (not including terminating null) */

Could you please let me know how to create directory name(or pathname) with above PATH_MAX length in korn shell scripting..

Thanks in Advance,
Mansa

You should also do "getconf -a |grep PATH_MAX" to see the actual limit. Whatever that limit is, it's unlikely you can do anything to do to get around that. (While some commands might work, there's no guarantee the OS will.)

ENAMETOOLONG is the error returned when you attempt to access a file or directory that
has a path name that is too long. Are you trying to create a path like that?

yes jim mcnamara ..

I am trying to create PATH such that i must receive "ENAMETOOLONG" error..

Please let me know how to create it..

Thanks in Advance,
Mansa

If you have some deep directory trees, try adding a symbolic link from the bottom of one tree to the top of another directory tree. Referencing a file way down on the second tree via the full name of the first tree + link > directory name of second tree

Are you trying to secure files?

Hi Jim mcnamara,

As i am poor at scripting.. Could you please send me in the form of script that helps me alot...

And i am going to use that pathname(which is too long) as first argument in statvfs systemcall...

int statvfs (const char *path, struct statvfs *buf);

Thanks,
Mansa

So you WANT a path that is too long?

cd /tmp
while true; do
  mkdir TEST 
  cd TEST || break
done
pwd
rm -rf /tmp/TEST

The output will be the name of the long directory.

If your shell is buggy, the script won't end properly. It will start producing error messages. Just hit CTRL-C (break) and type 'pwd' manually.

Hi,

Thanks for spending time on this..

I am expecting output as below:

/tmp/filesssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

and that length must exceed till PATHMAX=1023..

Thanks,
Mansa

You are confusing PATH_MAX with max filename length, which is filesystem dependent. If you want to see what is the max file length possible on a particular filesystem, you can use:

perl -e '$fn="files" . ("s" x shift(@ARGV)); mkdir($fn) || die "Cannot create: $fn";' 200

Increase 200 until it fails. That will be the filename that's too long.

Hi,

Could you please send me the same code in shell programming(sh) instead of perl..

Thanks in Advance,
Mansa