2 # User Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3 # Date 1432407475 -7200
4 # Sat May 23 20:57:55 2015 +0200
5 # Node ID 93e5dd955c8bd944fd64bb04fd117c963c3758bc
6 # Parent 8bf81e6a8e60e37c2dec9577a1be6357b8d56165
7 Change MAXNAMLEN to POSIX's NAME_MAX
9 By Felix Janda <felix.janda@posteo.de>:
10 MAXNAMLEN is usually defined in <sys/param.h> but it is
11 better to use the equivalent POSIX NAME_MAX.
13 Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
14 [Taken from upstream Mercurial commit 93e5dd955c8b]
16 diff -r 8bf81e6a8e60 -r 93e5dd955c8b src/getsdir.c
17 --- a/src/getsdir.c Sat May 23 20:57:11 2015 +0200
18 +++ b/src/getsdir.c Sat May 23 20:57:55 2015 +0200
21 * The data will be in the form:
22 * typedef struct dirEntry {
23 - * char fname[MAXNAMLEN + 1];
24 + * char fname[NAME_MAX + 1];
31 /* copy the filename */
32 - strncpy((*datptr)[cnt].fname, dp->d_name, MAXNAMLEN);
33 + strncpy((*datptr)[cnt].fname, dp->d_name, NAME_MAX);
35 /* get information about the directory entry */
36 snprintf(fpath, sizeof(fpath), "%s/%s", dirpath, dp->d_name);
37 diff -r 8bf81e6a8e60 -r 93e5dd955c8b src/getsdir.h
38 --- a/src/getsdir.h Sat May 23 20:57:11 2015 +0200
39 +++ b/src/getsdir.h Sat May 23 20:57:55 2015 +0200
46 typedef struct dirEntry { /* structure of data item */
47 - char fname[MAXNAMLEN + 1]; /* filename + terminating null */
48 + char fname[NAME_MAX + 1]; /* filename + terminating null */
49 time_t time; /* last modification date */
50 mode_t mode; /* file mode (dir? etc.) */
51 ushort cflags; /* caller field for convenience */