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

NetBSD supports statvfs #49

Closed
0-wiz-0 opened this issue Aug 9, 2014 · 4 comments
Closed

NetBSD supports statvfs #49

0-wiz-0 opened this issue Aug 9, 2014 · 4 comments

Comments

@0-wiz-0
Copy link
Contributor

0-wiz-0 commented Aug 9, 2014

NetBSD supports statvfs (and dropped support for statfs), but the code only checks for SunOS.
As an additional complication, some members of statvfs are called slightly differently, see
http://netbsd.gw.com/cgi-bin/man-cgi?statvfs+5+NetBSD-current

The following patch makes fstype.c compile on NetBSD; please check that I chose the correct field:

--- fstype.c.orig       2014-05-20 21:14:24.000000000 +0000
+++ fstype.c
@@ -53,11 +53,15 @@ w_string_t *w_fstype(const char *path)
   }

   return w_string_new(name);
-#elif defined(sun)
+#elif HAVE_SYS_STATVFS_H
   struct statvfs sfs;

   if (statvfs(path, &sfs) == 0) {
+#ifdef __NetBSD__
+    return w_string_new(sfs.f_fstypename);
+#else
     return w_string_new(sfs.f_basetype);
+#endif
   }
 #elif HAVE_STATFS
   struct statfs sfs;
@wez
Copy link
Contributor

wez commented Aug 10, 2014

Thanks!

I've verified that this doesn't break the Solaris code path, and the man page you referenced makes this seem like f_fstypename is the correct field name.

Would you like to submit this as a pull request so that we can take it in and associate it with you in the repo history?

@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented Aug 10, 2014

Thanks for the very quick feedback!
I've created
#51
for this.

@0-wiz-0
Copy link
Contributor Author

0-wiz-0 commented Aug 10, 2014

Ok, Travis reports this patch doesn't work on OS X.
fstype.c:63:29: error: no member named 'f_basetype' in 'struct statvfs'
return w_string_new(sfs.f_basetype);

We could either move the statfs block above the statvfs, or add an explicit check for OS X and do not enter the statvfs case then. What do you prefer, or do you have another suggestion? What symbol properly checks for OS X?

@wez
Copy link
Contributor

wez commented Aug 10, 2014

Thanks! Let's move the discussion to #51; I'll close this one in favor of that one

@wez wez closed this as completed Aug 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants