Professional Web Applications Themes

Can the value of NAME_MAX be changed? - UNIX Programming

Can the value of NAME_MAX be changed? Changing its value does not seem to make any difference. ____________________________________ #include <stdlib.h> #include <stdio.h> #include <limits.h> #define _POSIX_SOURCE #ifndef NAME_MAX #error NAME_MAX not defined #endif #undef NAME_MAX #define NAME_MAX 100000 #ifndef _POSIX_NAME_MAX #error _POSIX_NAME_MAX not defined #endif #undef _POSIX_NAME_MAX #define _POSIX_NAME_MAX 100000 int main(void) { char c; FILE *s,*d; printf("%d\n",NAME_MAX); printf("%d\n",_POSIX_NAME_MAX); getchar(); s=fopen("temp.c","r"); if (s==NULL) { perror("Cannot open"); getchar(); return -1; } d=fopen("ddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddd ddddddddddddddddddddddddddddddddddddddtemp2.c","w" ); if (d==NULL) { perror("Cannot open"); getchar(); return -1; ...

  1. #1

    Default Can the value of NAME_MAX be changed?

    Can the value of NAME_MAX be changed?
    Changing its value does not seem to make any difference.

    ____________________________________
    #include <stdlib.h>
    #include <stdio.h>
    #include <limits.h>

    #define _POSIX_SOURCE

    #ifndef NAME_MAX
    #error NAME_MAX not defined
    #endif

    #undef NAME_MAX

    #define NAME_MAX 100000


    #ifndef _POSIX_NAME_MAX
    #error _POSIX_NAME_MAX not defined
    #endif

    #undef _POSIX_NAME_MAX
    #define _POSIX_NAME_MAX 100000


    int main(void)
    {
    char c;
    FILE *s,*d;
    printf("%d\n",NAME_MAX);
    printf("%d\n",_POSIX_NAME_MAX);
    getchar();
    s=fopen("temp.c","r");
    if (s==NULL)
    {
    perror("Cannot open");
    getchar();
    return -1;
    }

    d=fopen("ddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddd
    ddddddddddddddddddddddddddddddddddddddtemp2.c","w" );
    if (d==NULL)
    {
    perror("Cannot open");
    getchar();
    return -1;
    }
    while((c=fgetc(s))!=EOF) putc(c,d);

    getchar();
    return 0;
    }


    --
    [email]somebudydespammed.com[/email]
    You need not make any modifications, the mail id is valid
    Me Guest

  2. #2

    Default Re: Can the value of NAME_MAX be changed?

    Me <somebudydespammed.com> writes:
    > Can the value of NAME_MAX be changed?
    > Changing its value does not seem to make any difference.
    NAME_MAX is referenced in the source code of the fopen() function,
    which you did not recompile.

    If you are willing to recompile the entire standard library, then
    yes, you can probably set it to whatever you want.

    ---
    John Gordon "Your hat makes baby Brell cry."
    [email]gordonjtan.com[/email] -- James Grahame in alt.games.everquest
    John Gordon Guest

  3. #3

    Default Re: Can the value of NAME_MAX be changed?

    Me wrote:
    > Can the value of NAME_MAX be changed?
    > Changing its value does not seem to make any difference.
    >
    > ____________________________________
    > #include <stdlib.h>
    > #include <stdio.h>
    > #include <limits.h>
    >
    > #define _POSIX_SOURCE
    >
    > #ifndef NAME_MAX
    > #error NAME_MAX not defined
    > #endif
    >
    > #undef NAME_MAX
    >
    > #define NAME_MAX 100000
    >
    >
    > #ifndef _POSIX_NAME_MAX
    > #error _POSIX_NAME_MAX not defined
    > #endif
    >
    > #undef _POSIX_NAME_MAX
    > #define _POSIX_NAME_MAX 100000
    >
    >
    > int main(void)
    > {
    > char c;
    > FILE *s,*d;
    > printf("%d\n",NAME_MAX);
    > printf("%d\n",_POSIX_NAME_MAX);
    > getchar();
    > s=fopen("temp.c","r");
    > if (s==NULL)
    > {
    > perror("Cannot open");
    > getchar();
    > return -1;
    > }
    >
    >
    d=fopen("ddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddddd dddddddddddddddddddddddddddddddddddddddddddddddd
    > ddddddddddddddddddddddddddddddddddddddtemp2.c","w" );
    > if (d==NULL)
    > {
    > perror("Cannot open");
    > getchar();
    > return -1;
    > }
    > while((c=fgetc(s))!=EOF) putc(c,d);
    >
    > getchar();
    > return 0;
    > }
    >
    >
    Why do you want to change it? It exists as a pre-defined value for a good
    reason.
    Sean Fraley Guest

  4. #4

    Default Re: Can the value of NAME_MAX be changed?

    On Wed, 25 Jun 2003 21:41:26 GMT, John Gordon wrote:
    >Me <somebudydespammed.com> writes:
    >
    >> Can the value of NAME_MAX be changed?
    >> Changing its value does not seem to make any difference.
    >
    >NAME_MAX is referenced in the source code of the fopen() function,
    >which you did not recompile.
    >
    >If you are willing to recompile the entire standard library, then
    >yes, you can probably set it to whatever you want.
    Any way, lets say I change it somehow to a lower value; how will the operating
    system treat files with longer names? What if I set it to 0? Will it ever boot
    again?

    On my system in KDE when I try to rename a file I have the following problem.
    In the text box if the number of characters exceed a certain value (NAME_MAX?) I
    am automatically logged off.
    Do you face such a problem?

    Try and put 2 dashes followed by one space as a sig separator, like this "-- "
    (without quotes) 8-)

    Thanks a lot.


    --
    [email]somebudydespammed.com[/email]
    You need not make any modifications, the mail id is valid
    Me Guest

  5. #5

    Default Re: Can the value of NAME_MAX be changed?

    On Thu, 26 Jun 2003 18:29:30 +0530, Me <somebudydespammed.com> wrote:


    [snip]
    >
    > On my system in KDE when I try to rename a file I have the following
    > problem.
    > In the text box if the number of characters exceed a certain value
    > (NAME_MAX?) I
    > am automatically logged off.
    > Do you face such a problem?
    >
    > Try and put 2 dashes followed by one space as a sig separator, like this
    > "-- "
    > (without quotes) 8-)
    >
    > Thanks a lot.
    >
    >
    This is a bug in KDE or whatever, having nothing to do with NAME_MAX or any
    other part of the UNIX kernel.

    And, should you get that far, NAME_MAX is only the length of a component of
    the path. It's not a limit on the whole path, which is what users are
    normally concerned with. That's a different constant (if the system even
    has a limit), and it's similarly read-only: PATH_MAX. It may not be
    defined, as having a limit isn't a requirement.

    Generally, software has to be designed to:

    1. Handle all paths, no matter the length, up to a reasonable number (e.g.,
    4K). But 4K paths occur only when the program is generating the path. Users
    never type or paste paths that long, although in theory they could.

    2. Give an error message or whatever if the path is too long. Aborting
    (which is what's hapenning here, from your description) is never
    acceptable.

    --Marc
    Marc Rochkind Guest

Similar Threads

  1. Check if PDF has changed
    By CasparNielsen@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 1
    Last Post: November 17th, 12:07 PM
  2. What's changed in Studio 8?
    By JoeyDay in forum Macromedia Flash Data Integration
    Replies: 1
    Last Post: December 22nd, 02:41 AM
  3. Everything I changed is gone
    By BJKNJ in forum Macromedia Contribute General Discussion
    Replies: 2
    Last Post: November 20th, 01:07 AM
  4. Reading URL is changed
    By Dan J. Rychlik in forum PHP Development
    Replies: 2
    Last Post: September 20th, 12:57 AM
  5. $name getting changed to $_
    By Brian in forum PERL Miscellaneous
    Replies: 2
    Last Post: August 5th, 11:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139