Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple fixes and cleanup for FreeBSD #584

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions open-vm-tools/lib/dynxdr/dynxdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ typedef struct DynXdrData {
} DynXdrData;

/*
* FreeBSD < 5.0 and Solaris do not declare some parameters as "const".
* Solaris do not declare some parameters as "const".
*/
#if defined(sun) || (defined(__FreeBSD__) && __FreeBSD_version < 500000)
#if defined(sun)
# define DYNXDR_CONST
#else
# define DYNXDR_CONST const
Expand Down
4 changes: 1 addition & 3 deletions open-vm-tools/lib/file/filePosix.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,11 +749,9 @@ File_GetTimes(const char *pathName, // IN:
#if defined(__FreeBSD__)
/*
* FreeBSD: All supported versions have timestamps with nanosecond
* resolution. FreeBSD 5+ has also file creation time.
* resolution and also file creation time.
*/
# if defined(__FreeBSD_version) && __FreeBSD_version >= 500043
*createTime = TimeUtil_UnixTimeToNtTime(statBuf.st_birthtimespec);
# endif
*accessTime = TimeUtil_UnixTimeToNtTime(statBuf.st_atimespec);
*writeTime = TimeUtil_UnixTimeToNtTime(statBuf.st_mtimespec);
*attrChangeTime = TimeUtil_UnixTimeToNtTime(statBuf.st_ctimespec);
Expand Down
30 changes: 11 additions & 19 deletions open-vm-tools/lib/hgfsServer/hgfsServerLinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,11 @@ getdents_apple(DIR *fd, // IN
#endif


#if defined(sun) || defined(__linux__) || \
(defined(__FreeBSD_version) && __FreeBSD_version < 490000)
#if defined(sun) || defined(__linux__)
/*
* Implements futimes(), which was introduced in glibc 2.3.3. FreeBSD 3.2
* doesn't have it, but 4.9 does. Unfortunately, these early FreeBSD versions
* don't have /proc/self, so futimes() will simply fail. For now the only
* caller to futimes() is HgfsServerSetattr which doesn't get invoked at all
* in the HGFS server which runs in the Tools, so it's OK.
* Implements futimes(), which was introduced in glibc 2.3.3.
* For now the only caller to futimes() is HgfsServerSetattr which doesn't get
* invoked at all in the HGFS server which runs in the Tools, so it's OK.
*/
#define PROC_SELF_FD "/proc/self/fd/"
#define STRLEN_OF_MAXINT_AS_STRING 10
Expand Down Expand Up @@ -1907,23 +1904,18 @@ HgfsGetCreationTime(const struct stat *stats)
{
uint64 creationTime;
/*
* Linux and FreeBSD before v5 doesn't know about creation time; we just use the time
* of last data modification for the creation time.
* FreeBSD 5+ supprots file creation time.
* Linux doesn't know about creation time; we just use the time of last
* data modification for the creation time.
*
* Using mtime when creation time is unavailable to be consistent with SAMBA.
*/

#ifdef __FreeBSD__
/*
* FreeBSD: All supported versions have timestamps with nanosecond resolution.
* FreeBSD 5+ has also file creation time.
* FreeBSD: All supported versions have timestamps with nanosecond resolution
* and also file creation time.
*/
# if __IS_FREEBSD_VER__(500043)
creationTime = HgfsConvertTimeSpecToNtTime(&stats->st_birthtimespec);
# else
creationTime = HgfsConvertTimeSpecToNtTime(&stats->st_mtimespec);
# endif
#elif defined(__linux__)
/*
* Linux: Glibc 2.3+ has st_Xtim. Glibc 2.1/2.2 has st_Xtime/__unusedX on
Expand Down Expand Up @@ -2522,8 +2514,8 @@ HgfsStatToFileAttr(struct stat *stats, // IN: stat information

#ifdef __FreeBSD__
/*
* FreeBSD: All supported versions have timestamps with nanosecond resolution.
* FreeBSD 5+ has also file creation time.
* FreeBSD: All supported versions have timestamps with nanosecond resolution
* and also file creation time.
*/
attr->accessTime = HgfsConvertTimeSpecToNtTime(&stats->st_atimespec);
attr->writeTime = HgfsConvertTimeSpecToNtTime(&stats->st_mtimespec);
Expand Down Expand Up @@ -2565,7 +2557,7 @@ HgfsStatToFileAttr(struct stat *stats, // IN: stat information
attr->specialPerms, attr->ownerPerms, attr->groupPerms,
attr->otherPerms, attr->size);
#ifdef __FreeBSD__
# if !defined(VM_X86_64) && !defined(VM_ARM_64) && __FreeBSD_version >= 500043
# if !defined(VM_X86_64) && !defined(VM_ARM_64)
# define FMTTIMET ""
# else
# define FMTTIMET "l"
Expand Down
8 changes: 0 additions & 8 deletions open-vm-tools/lib/include/vm_basic_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@
#include "includeCheck.h"
#include "vm_basic_types.h" // For INLINE.

/* Checks for FreeBSD, filtering out VMKERNEL. */
#if !defined(VMKERNEL) && defined(__FreeBSD__)
#define __IS_FREEBSD__ 1
#else
#define __IS_FREEBSD__ 0
#endif
#define __IS_FREEBSD_VER__(ver) (__IS_FREEBSD__ && __FreeBSD_version >= (ver))

/*
* <stddef.h> provides definitions for:
* NULL, offsetof
Expand Down
8 changes: 2 additions & 6 deletions open-vm-tools/lib/include/vm_basic_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,8 @@ typedef char Bool;
#if !defined(USING_AUTOCONF)
# if defined(__FreeBSD__) || defined(sun)
# ifndef KLD_MODULE
# if __FreeBSD_version >= 500043
# if !defined(VMKERNEL)
# include <inttypes.h>
# endif
# else
# include <sys/inttypes.h>
# if !defined(VMKERNEL)
# include <inttypes.h>
# endif
# endif
# elif defined __APPLE__
Expand Down
4 changes: 2 additions & 2 deletions open-vm-tools/lib/misc/idLinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Id_SetRESUid(uid_t uid, // IN: new uid
uid_t euid, // IN: new effective uid
uid_t suid) // IN: new saved uid
{
#if (defined(__FreeBSD__) && __FreeBSD_version >= 500043)
#if defined(__FreeBSD__)
return setresuid(uid, euid, suid);
#elif defined(__linux__)
if (uid32) {
Expand Down Expand Up @@ -281,7 +281,7 @@ Id_SetRESGid(gid_t gid, // IN: new gid
gid_t egid, // IN: new effective gid
gid_t sgid) // IN: new saved gid
{
#if (defined(__FreeBSD__) && __FreeBSD_version >= 500043)
#if defined(__FreeBSD__)
return setresgid(gid, egid, sgid);
#elif defined(__linux__)
if (uid32) {
Expand Down
2 changes: 1 addition & 1 deletion open-vm-tools/lib/misc/util_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ Util_CanonicalPathsIdentical(const char *path1, // IN:
return (strcmp(path1, path2) == 0);
#elif defined(_WIN32)
return (_stricmp(path1, path2) == 0);
#elif defined(__APPLE__)
#elif defined(__APPLE__) || defined(__FreeBSD__)
return (strcasecmp(path1, path2) == 0);
#else
NOT_IMPLEMENTED();
Expand Down
4 changes: 1 addition & 3 deletions open-vm-tools/lib/string/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ extern int vasprintf(char **ptr, const char *f, va_list arg);
* glibc >= 2.2. I.e., even though they should be able to work on
* FreeBSD 5.0+ and Solaris 8+, they aren't made available there.
*/
# if !(defined(__linux__) || \
(defined(__FreeBSD__) && (__FreeBSD_version >= 500000)) || \
defined(sun))
# if !(defined(__linux__) || defined(__FreeBSD__) || defined(sun))
extern int vswprintf(wchar_t *wcs, size_t maxlen, const wchar_t *format, va_list args);
# endif
#endif // _WIN32
Expand Down
3 changes: 3 additions & 0 deletions open-vm-tools/lib/vmCheck/vmcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ VmCheckSafe(SafeCheckFn checkFn)
#else
do {
int signals[] = {
#if defined(__FreeBSD__)
SIGBUS,
#endif
SIGILL,
SIGSEGV,
};
Expand Down
26 changes: 2 additions & 24 deletions open-vm-tools/lib/wiper/wiperPosix.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
# include <sys/ucred.h>
# include <sys/mount.h>
# include <fstab.h>
# if defined(__FreeBSD_version) && __FreeBSD_version >= 500000
# if defined(__FreeBSD_version)
# include <libgen.h>
# endif /* __FreeBSD_version >= 500000 */
# endif
#endif
#include <unistd.h>

Expand Down Expand Up @@ -344,27 +344,6 @@ WiperIsDiskDevice(MNTINFO *mnt, // IN: file system being considered
* function, as a whole, does not even apply to OS X, so this caveat is
* only minor.
*/
#if __FreeBSD_version < 500000
/*
* Before FreeBSD 5, device nodes had static major/minor numbers.
* (FreeBSD 5 included devfs which got rid of this concept.) So
* we'll stat(2) the mount source and test its major numbers
* against the values lifted from
* http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/i386/conf/Attic/majors.i386 (rev 1.65)
*
* Devnode Type Description Major
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* block "Winchester" (IDE, ATA, /dev/wd*) 0
* character " 3
* block SCSI "direct access" (/dev/da*) 4
* character " 13
*/
int maj = major(s->st_rdev);
if ((S_ISBLK(s->st_mode) && ((maj == 0) || (maj == 4))) ||
(S_ISCHR(s->st_mode) && ((maj == 3) || (maj == 13)))) {
retval = TRUE;
}
#else
/*
* Begin by testing whether file system source is really a character
* device node. (FreeBSD dropped support for block devices long ago.)
Expand All @@ -382,7 +361,6 @@ WiperIsDiskDevice(MNTINFO *mnt, // IN: file system being considered
}
#undef MASK_ATA_DISK
#undef MASK_SCSI_DISK
#endif /* __FreeBSD_version */

return retval;
}
Expand Down
5 changes: 0 additions & 5 deletions open-vm-tools/modules/freebsd/shared/compat_freebsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@
* FreeBSD version 8 and above uses the kproc API instead of the kthread API in its
* kernel.
*/
#if __FreeBSD_version > 800001
#define compat_kthread_create kproc_create
#define compat_kthread_exit kproc_exit
#else
#define compat_kthread_create kthread_create
#define compat_kthread_exit kthread_exit
#endif

#endif // __COMPAT_FREEBSD_H__
5 changes: 0 additions & 5 deletions open-vm-tools/modules/freebsd/shared/compat_mount.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@
#ifndef __COMPAT_MOUNT_H__
# define __COMPAT_MOUNT_H__ 1

#if __FreeBSD_version >= 800011
#define COMPAT_VFS_STATFS(mp, sbp, threadvar) VFS_STATFS((mp), (sbp))
#define compat_td curthread
#else
#define COMPAT_VFS_STATFS(mp, sbp, threadvar) VFS_STATFS((mp), (sbp), (threadvar))
#define compat_td td
#endif

#endif
4 changes: 0 additions & 4 deletions open-vm-tools/modules/freebsd/shared/compat_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
#ifndef __COMPAT_PRIV_H__
# define __COMPAT_PRIV_H__ 1

#if __FreeBSD_version >= 800011
#define compat_priv_check(td, priv) priv_check((td), (priv))
#else
#define compat_priv_check(td, priv) suser(td)
#endif

#endif
23 changes: 3 additions & 20 deletions open-vm-tools/modules/freebsd/shared/compat_vop.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#ifndef __COMPAT_VOP_H__
# define __COMPAT_VOP_H__ 1

#if __FreeBSD_version >= 800011
#define COMPAT_THREAD_VAR(varname, varval)
#define COMPAT_VOP_LOCK(vop, flags, threadvar) VOP_LOCK((vop), (flags))
#if __FreeBSD_version >= 1300074
Expand All @@ -57,29 +56,13 @@
#define compat_vn_lock(vp, flags, threadval) vn_lock((vp), (flags))
#define compat_accmode_t accmode_t
#define compat_a_accmode a_accmode
#else
#define COMPAT_THREAD_VAR(varname, varval) struct thread *varname = varval
#define COMPAT_VOP_LOCK(vop, flags, threadvar) VOP_LOCK((vop), (flags), (threadvar))
#define COMPAT_VOP_UNLOCK(vop, flags, threadvar) VOP_UNLOCK((vop), (flags), (threadvar))
#define compat_lockstatus(lock, threadvar) lockstatus((lock), (threadvar))
#define compat_vn_lock(vp, flags, threadval) vn_lock((vp), (flags), (threadval))
#define compat_lockmgr(lock, flags, randompointerparam, threadval) lockmgr((lock), (flags), (randompointerparam), (threadval))
#define compat_accmode_t mode_t
#define compat_a_accmode a_mode
#endif

/*
* We use defines rather than typedefs here to avoid causing problems for files that
* don't have a vnode_if.h available.
*/
#if __FreeBSD_version >= 700055
# define compat_vop_lock_t vop_lock1_t
# define compat_vop_lock_args struct vop_lock1_args
# define COMPAT_VOP_LOCK_OP_ELEMENT vop_lock1
#else
# define compat_vop_lock_t vop_lock_t
# define compat_vop_lock_args struct vop_lock_args
# define COMPAT_VOP_LOCK_OP_ELEMENT vop_lock
#endif
#define compat_vop_lock_t vop_lock1_t
#define compat_vop_lock_args struct vop_lock1_args
#define COMPAT_VOP_LOCK_OP_ELEMENT vop_lock1

#endif
3 changes: 1 addition & 2 deletions open-vm-tools/modules/freebsd/vmblock/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ SRCS := $(HEADERS) $(CSRCS)

KMOD = vmblock
PROG = ../$(KMOD).ko
NOMAN = t
NO_MAN = t
MK_MAN = no
KLDMOD = t

VMBLOCK := $(MAINSRCROOT)/modules/vmblock
Expand Down
11 changes: 7 additions & 4 deletions open-vm-tools/modules/freebsd/vmblock/subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ VMBlockHashRem(struct VMBlockNode *xp) // IN: node to remove
*-----------------------------------------------------------------------------
*/

#if __FreeBSD_version >= 700055
static void
VMBlockInsMntQueDtr(struct vnode *vp, // IN: node to cleanup
void *xp) // IN: FS private data
Expand All @@ -313,7 +312,6 @@ VMBlockInsMntQueDtr(struct vnode *vp, // IN: node to cleanup
vgone(vp);
vput(vp);
}
#endif


/*
Expand Down Expand Up @@ -391,8 +389,13 @@ VMBlockNodeGet(struct mount *mp, // IN: VMBlock fs info
panic("VMBlockNodeGet: Passed a NULL vnlock.\n");
}

/* Before FreeBSD 7, insmntque was called by getnewvnode. */
#if __FreeBSD_version >= 700055
#if __FreeBSD_version >= 1400051
error = insmntque1(vp, mp);
if (error != 0) {
VMBlockInsMntQueDtr(vp, xp);
return error;
}
#else
error = insmntque1(vp, mp, VMBlockInsMntQueDtr, xp);
if (error != 0) {
return error;
Expand Down
Loading