Bug 4121 - PATH_MAX undefined since it is undefined in limits.h
Summary: PATH_MAX undefined since it is undefined in limits.h
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.0.23c
Hardware: x86 Other
: P3 normal
Target Milestone: none
Assignee: Tim Potter
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-22 19:45 UTC by Larry Manulak
Modified: 2019-06-18 10:40 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Manulak 2006-09-22 19:45:57 UTC
OS: SCO OpenServer 5.0.7 using gcc 2.95.3p4

client/client.c:3000:'PATH_MAX' undeclared.

This is related to bug 3746.

In SCO OpenServer 5, PATH_MAX is undefined in limits.h. Below is the relevant part of limits.h:
--------------------
/*
 * The following are not defined since the value can vary according
 * to the file referred to.
 *
 * In all cases, pathconf should be checked to find the actual value for
 * a particular file.
 *
 *	LINK_MAX		_PC_LINK_MAX	_POSIX_LINK_MAX
 *	NAME_MAX		_PC_NAME_MAX	PATHSIZE
 *	PATH_MAX		_PC_PATH_MAX	PATHSIZE
 *	PIPE_BUF		_PC_PIPE_BUF	_POSIX_PIPE_BUF
 *
 *  A similar rationale applies to the following cross compatibility values.
 *
 *	MAXPATHLEN		(from 4.2 BSD params.h)
 */


/*
 * It is arguable whether these should be defined even in _IBCS2 mode since
 * the defintions are WRONG on recent SCO OS's and pathconf should be
 * used instead
 */

#ifdef _IBCS2
#define LINK_MAX  1000
#define PATH_MAX   256
#define PIPE_BUF  5120
#endif /* _IBCS2 */
--------------------

The recommended solution is to use pathconf to find this value. Alternatively, you could use _POSIX_PATH_MAX since that is defined as 255 but that could be too restrictive.

A workaround to get this compiled is:
make FLAGS2="-DPATH_MAX=_POSIX_PATH_MAX"

But then I got 
utils/smbget.c:118:'MAXPATHLEN' undeclared.

As you can see from the part of limits.h extracted above, that is also deliberately undefined.

Adding -DMAXPATHLEN=_POSIX_PATH_MAX would probably work here too but it is time to go home.

Thanks
Larry Manulak
Programmer
Omega Computer Services Ltd.
Comment 1 Larry Manulak 2006-09-25 15:25:29 UTC
This seems to be the same as bug 4008 (Compile error in client/client.c when building for SCO OSR 5). I think I have provided additional informatiion about why it happens.
Comment 2 Larry Manulak 2006-09-25 16:44:54 UTC
This appears to be similar to bug 2560 where it showed up in 3.0.13 in smbd/vfs.c and appeared to have been solved by 3.0.14a.

It reappears here in client.c (is that new code?).
Comment 3 Andrew Bartlett 2019-06-18 10:40:27 UTC
Fixed in Samba 3.4 by 

commit 2b3c44e4fb980335c22abcc07a88f32b13e5918f
Author: Jeremy Allison <jra@samba.org>
Date:   Sat Nov 10 22:31:34 2007 -0800

    Always define PATH_MAX. Makes code simpler (removes
    a bunch of #defines). Remove pstring from msdfs.c.
    Jeremy.
    (This used to be commit e203ba22275320808bc11b17361ad1f2d5b0b897)