RFC cifs-utils: Use autoconf to get kernel headers
Subsystems (2)
PATCH 1/1 RFC cifs-utils: Use autoconf to get kernel headers
From: Scott Lovenberg <[email protected]>
This is an RFC for how we'd use autoconf to get the Linux kernel headers in include/uapi/linux/cifs.h. If this is the correct approach, I'll formalize this patch. I've never played with autoconf before so this is completely untested but should (read: might) probably work.
--- configure.ac | 3 +++ mount.cifs.c | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-)
configure.ac +3 -0
@@ -111,6 +111,9 @@ AC_SUBST(RT_LDADD) # Checks for header files. AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h inttypes.h limits.h mntent.h netdb.h stddef.h stdint.h stdbool.h stdlib.h stdio.h errno.h string.h strings.h sys/mount.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h], , [AC_MSG_ERROR([necessary header(s) not found])]) +# Check for linux's cifs.h header that defines string lengths. +AC_CHECK_HEADER([linux/cifs.h], ,[AC_MSG_WARN([cifs kernel header not found. Using internal values.])]) + # do we have sys/fsuid.h and setfsuid()? AC_CHECK_HEADERS([sys/fsuid.h]) AC_CHECK_FUNC(setfsuid, , [AC_MSG_ERROR([System does not support setfsuid()])])
mount.cifs.c +19 -8
@@ -62,6 +62,9 @@#include "mount.h" #include "util.h" #include "resolve_host.h" +#ifdef HAVE_LINUX_CIFS_H +#include <linux/cifs.h> +#endif /* HAVE_LINUX_CIFS_h */ #ifndef MS_MOVE #define MS_MOVE 8192
@@ -91,16 +94,24 @@/* Max length of the share name portion of a UNC. Share names over 80 * characters cannot be accessed via commandline in Windows 2000/XP. */ -#define MAX_SHARE_LEN 256 +#ifndef MAX_SHARE_SIZE +#define MAX_SHARE_SIZE 256 +#endif /* Max user name length. */ +#ifndef MAX_USERNAME_SIZE #define MAX_USERNAME_SIZE 256 +#endif /* Max domain size. */ -#define MAX_DOMAIN_SIZE 256 +#ifndef MAX_DOMAINNAME_SIZE +#define MAX_DOMAINNAME_SIZE 256 +#endif /* Max password size. */ -#define MOUNT_PASSWD_SIZE 512 +#ifndef MAX_PASSWORD_SIZE +#define MAX_PASSWORD_SIZE 512 +#endif
@@ -176,12 +187,12 @@struct parsed_mount_info {unsigned long flags;char host[NI_MAXHOST +1 ]; -char share[MAX_SHARE_LEN +1 ]; +char share[MAX_SHARE_SIZE +1 ];char prefix[PATH_MAX +1 ];char options[MAX_OPTIONS_LEN ]; -char domain[MAX_DOMAIN_SIZE +1 ]; +char domain[MAX_DOMAINNAME_SIZE +1 ];char username[MAX_USERNAME_SIZE +1 ]; -char password[MOUNT_PASSWD_SIZE +1 ]; +char password[MAX_PASSWORD_SIZE +1 ];char addrlist[MAX_ADDR_LIST_LEN ];unsigned int got_user:1 ;unsigned int got_password:1 ;
@@ -1766,13 +1777,13 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info, }if (!parsed_info->got_password) { -char tmp_pass[MOUNT_PASSWD_SIZE +1 ]; +char tmp_pass[MAX_PASSWORD_SIZE +1 ];char *prompt =NULL ;if (asprintf (&prompt,"Password for %s@%s: " , parsed_info->username, orig_dev) <0 ) prompt =NULL ; -if (get_password (prompt ? prompt :"Password: " , tmp_pass,MOUNT_PASSWD_SIZE +1 )) { +if (get_password (prompt ? prompt :"Password: " , tmp_pass,MAX_PASSWORD_SIZE +1 )) { rc =set_password (parsed_info, tmp_pass); }else {fprintf (stderr,"Error reading password, exiting\n" );
Signature · 1 line
1.8.1.4
A message that is not in the archive (sent off-list or not yet received): 1374515243-21624-1-git-send-email-scott.lovenberg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 7 lines · On Mon, 22 Jul 2013 13:47:23 -0400 scott.lovenberg-Re5JQEeQqe8AvxtiuMwx3w@publi…
From: Scott Lovenberg <[email protected]>
This is an RFC for how we'd use autoconf to get the Linux kernel headers in
include/uapi/linux/cifs.h. If this is the correct approach, I'll formalize this patch. I've never played with autoconf before so this is completely untested but should (read: might) probably work.
Quoted 6 lines
Signed-off-by Scott Lovenberg <[email protected]>--- configure.ac | 3 +++ mount.cifs.c | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-)
I think the first step is to do a kernel patch that makes this cifs.h file. I won't commit any sort of patch like this until that's committed first.
Also "cifs.h" is somewhat generic. I think you should probably name it a bit more specifically -- maybe include/uapi/linux/cifs/cifs_mount.h...
Quoted 88 lines
configure.ac +3
-0@@ -111,6 +111,9 @@ AC_SUBST(RT_LDADD) # Checks for header files. AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h inttypes.h limits.h mntent.h netdb.h stddef.h stdint.h stdbool.h stdlib.h stdio.h errno.h string.h strings.h sys/mount.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h], , [AC_MSG_ERROR([necessary header(s) not found])]) +# Check for linux's cifs.h header that defines string lengths. +AC_CHECK_HEADER([linux/cifs.h], ,[AC_MSG_WARN([cifs kernel header not found. Using internal values.])]) + # do we have sys/fsuid.h and setfsuid()? AC_CHECK_HEADERS([sys/fsuid.h]) AC_CHECK_FUNC(setfsuid, , [AC_MSG_ERROR([System does not support setfsuid()])])mount.cifs.c +19
-8@@ -62,6 +62,9 @@#include "mount.h" #include "util.h" #include "resolve_host.h" +#ifdef HAVE_LINUX_CIFS_H +#include <linux/cifs.h> +#endif /* HAVE_LINUX_CIFS_h */ #ifndef MS_MOVE #define MS_MOVE 8192@@ -91,16 +94,24 @@/* Max length of the share name portion of a UNC. Share names over 80 * characters cannot be accessed via commandline in Windows 2000/XP. */ -#define MAX_SHARE_LEN 256 +#ifndef MAX_SHARE_SIZE +#define MAX_SHARE_SIZE 256 +#endif /* Max user name length. */ +#ifndef MAX_USERNAME_SIZE #define MAX_USERNAME_SIZE 256 +#endif /* Max domain size. */ -#define MAX_DOMAIN_SIZE 256 +#ifndef MAX_DOMAINNAME_SIZE +#define MAX_DOMAINNAME_SIZE 256 +#endif /* Max password size. */ -#define MOUNT_PASSWD_SIZE 512 +#ifndef MAX_PASSWORD_SIZE +#define MAX_PASSWORD_SIZE 512 +#endif @@ -176,12 +187,12 @@struct parsed_mount_info {unsigned long flags;char host[NI_MAXHOST +1 ]; -char share[MAX_SHARE_LEN +1 ]; +char share[MAX_SHARE_SIZE +1 ];char prefix[PATH_MAX +1 ];char options[MAX_OPTIONS_LEN ]; -char domain[MAX_DOMAIN_SIZE +1 ]; +char domain[MAX_DOMAINNAME_SIZE +1 ];char username[MAX_USERNAME_SIZE +1 ]; -char password[MOUNT_PASSWD_SIZE +1 ]; +char password[MAX_PASSWORD_SIZE +1 ];char addrlist[MAX_ADDR_LIST_LEN ];unsigned int got_user:1 ;unsigned int got_password:1 ;@@ -1766,13 +1777,13 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info, }if (!parsed_info->got_password) { -char tmp_pass[MOUNT_PASSWD_SIZE +1 ]; +char tmp_pass[MAX_PASSWORD_SIZE +1 ];char *prompt =NULL ;if (asprintf (&prompt,"Password for %s@%s: " , parsed_info->username, orig_dev) <0 ) prompt =NULL ; -if (get_password (prompt ? prompt :"Password: " , tmp_pass,MOUNT_PASSWD_SIZE +1 )) { +if (get_password (prompt ? prompt :"Password: " , tmp_pass,MAX_PASSWORD_SIZE +1 )) { rc =set_password (parsed_info, tmp_pass); }else {fprintf (stderr,"Error reading password, exiting\n" );
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20130722142752.046fde43-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Quoted 17 lines · Jeff Layton
Quoted 7 lines · On Mon, 22 Jul 2013 13:47:23 -0400 scott.lovenberg-Re5JQEeQqe8AvxtiuMwx3w@publi…
From: Scott Lovenberg <[email protected]>
This is an RFC for how we'd use autoconf to get the Linux kernel headers in
include/uapi/linux/cifs.h. If this is the correct approach, I'll formalize this patch. I've never played with autoconf before so this is completely untested but should (read: might) probably work.Quoted 6 lines
Signed-off-by Scott Lovenberg <[email protected]>--- configure.ac | 3 +++ mount.cifs.c | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-)
Quoted 7 lines
I think the first step is to do a kernel patch that makes this
cifs.hfile. I won't commit any sort of patch like this until that's committed first.Also "
cifs.h" is somewhat generic. I think you should probably name it a bit more specifically -- maybeinclude/uapi/linux/cifs/cifs_mount.h...
Do we need add prefix 'CIFS_' for the macro constants to let them in their own name space ? (e.g. use 'CIFS_MAX_DOMAIN_SIZE' instead of 'MAX_DOMAIN_SIZE').
Thanks.
Quoted 90 lines
Quoted 88 lines
configure.ac +3
-0@@ -111,6 +111,9 @@ AC_SUBST(RT_LDADD) # Checks for header files. AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h inttypes.h limits.h mntent.h netdb.h stddef.h stdint.h stdbool.h stdlib.h stdio.h errno.h string.h strings.h sys/mount.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h], , [AC_MSG_ERROR([necessary header(s) not found])]) +# Check for linux's cifs.h header that defines string lengths. +AC_CHECK_HEADER([linux/cifs.h], ,[AC_MSG_WARN([cifs kernel header not found. Using internal values.])]) + # do we have sys/fsuid.h and setfsuid()? AC_CHECK_HEADERS([sys/fsuid.h]) AC_CHECK_FUNC(setfsuid, , [AC_MSG_ERROR([System does not support setfsuid()])])mount.cifs.c +19
-8@@ -62,6 +62,9 @@#include "mount.h" #include "util.h" #include "resolve_host.h" +#ifdef HAVE_LINUX_CIFS_H +#include <linux/cifs.h> +#endif /* HAVE_LINUX_CIFS_h */ #ifndef MS_MOVE #define MS_MOVE 8192@@ -91,16 +94,24 @@/* Max length of the share name portion of a UNC. Share names over 80 * characters cannot be accessed via commandline in Windows 2000/XP. */ -#define MAX_SHARE_LEN 256 +#ifndef MAX_SHARE_SIZE +#define MAX_SHARE_SIZE 256 +#endif /* Max user name length. */ +#ifndef MAX_USERNAME_SIZE #define MAX_USERNAME_SIZE 256 +#endif /* Max domain size. */ -#define MAX_DOMAIN_SIZE 256 +#ifndef MAX_DOMAINNAME_SIZE +#define MAX_DOMAINNAME_SIZE 256 +#endif /* Max password size. */ -#define MOUNT_PASSWD_SIZE 512 +#ifndef MAX_PASSWORD_SIZE +#define MAX_PASSWORD_SIZE 512 +#endif @@ -176,12 +187,12 @@struct parsed_mount_info {unsigned long flags;char host[NI_MAXHOST +1 ]; -char share[MAX_SHARE_LEN +1 ]; +char share[MAX_SHARE_SIZE +1 ];char prefix[PATH_MAX +1 ];char options[MAX_OPTIONS_LEN ]; -char domain[MAX_DOMAIN_SIZE +1 ]; +char domain[MAX_DOMAINNAME_SIZE +1 ];char username[MAX_USERNAME_SIZE +1 ]; -char password[MOUNT_PASSWD_SIZE +1 ]; +char password[MAX_PASSWORD_SIZE +1 ];char addrlist[MAX_ADDR_LIST_LEN ];unsigned int got_user:1 ;unsigned int got_password:1 ;@@ -1766,13 +1777,13 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info, }if (!parsed_info->got_password) { -char tmp_pass[MOUNT_PASSWD_SIZE +1 ]; +char tmp_pass[MAX_PASSWORD_SIZE +1 ];char *prompt =NULL ;if (asprintf (&prompt,"Password for %s@%s: " , parsed_info->username, orig_dev) <0 ) prompt =NULL ; -if (get_password (prompt ? prompt :"Password: " , tmp_pass,MOUNT_PASSWD_SIZE +1 )) { +if (get_password (prompt ? prompt :"Password: " , tmp_pass,MAX_PASSWORD_SIZE +1 )) { rc =set_password (parsed_info, tmp_pass); }else {fprintf (stderr,"Error reading password, exiting\n" );
Signature · 1 line
Chen Gang
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 88 lines · Chen Gang
Quoted 17 lines · Jeff Layton
Quoted 7 lines · On Mon, 22 Jul 2013 13:47:23 -0400 scott.lovenberg-Re5JQEeQqe8AvxtiuMwx3w@publi…
From: Scott Lovenberg <[email protected]>
This is an RFC for how we'd use autoconf to get the Linux kernel headers in
include/uapi/linux/cifs.h. If this is the correct approach, I'll formalize this patch. I've never played with autoconf before so this is completely untested but should (read: might) probably work.Quoted 6 lines
Signed-off-by Scott Lovenberg <[email protected]>--- configure.ac | 3 +++ mount.cifs.c | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-)Quoted 7 lines
I think the first step is to do a kernel patch that makes this
cifs.hfile. I won't commit any sort of patch like this until that's committed first.Also "
cifs.h" is somewhat generic. I think you should probably name it a bit more specifically -- maybeinclude/uapi/linux/cifs/cifs_mount.h...Do we need add prefix '
CIFS_' for the macro constants to let them in their own name space ? (e.g. use 'CIFS_MAX_DOMAIN_SIZE' instead of 'MAX_DOMAIN_SIZE').Thanks.
Quoted 56 lines
Quoted 56 lines
configure.ac +3
-0@@ -111,6 +111,9 @@ AC_SUBST(RT_LDADD) # Checks for header files. AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h inttypes.h limits.h mntent.h netdb.h stddef.h stdint.h stdbool.h stdlib.h stdio.h errno.h string.h strings.h sys/mount.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h], , [AC_MSG_ERROR([necessary header(s) not found])]) +# Check for linux's cifs.h header that defines string lengths. +AC_CHECK_HEADER([linux/cifs.h], ,[AC_MSG_WARN([cifs kernel header not found. Using internal values.])]) + # do we have sys/fsuid.h and setfsuid()? AC_CHECK_HEADERS([sys/fsuid.h]) AC_CHECK_FUNC(setfsuid, , [AC_MSG_ERROR([System does not support setfsuid()])])mount.cifs.c +14
-3@@ -62,6 +62,9 @@#include "mount.h" #include "util.h" #include "resolve_host.h" +#ifdef HAVE_LINUX_CIFS_H +#include <linux/cifs.h> +#endif /* HAVE_LINUX_CIFS_h */ #ifndef MS_MOVE #define MS_MOVE 8192@@ -91,16 +94,24 @@/* Max length of the share name portion of a UNC. Share names over 80 * characters cannot be accessed via commandline in Windows 2000/XP. */ -#define MAX_SHARE_LEN 256 +#ifndef MAX_SHARE_SIZE +#define MAX_SHARE_SIZE 256 +#endif /* Max user name length. */ +#ifndef MAX_USERNAME_SIZE #define MAX_USERNAME_SIZE 256 +#endif /* Max domain size. */ -#define MAX_DOMAIN_SIZE 256 +#ifndef MAX_DOMAINNAME_SIZE +#define MAX_DOMAINNAME_SIZE 256 +#endif /* Max password size. */ -#define MOUNT_PASSWD_SIZE 512 +#ifndef MAX_PASSWORD_SIZE +#define MAX_PASSWORD_SIZE 512 +#endif
Quoted 10 lines
Quoted 10 lines
mount.cifs.c line 193
Quoted 10 lines
mount.cifs.c +2
-2@@ -176,12 +187,12 @@struct parsed_mount_info {unsigned long flags;char host[NI_MAXHOST +1 ]; -char share[MAX_SHARE_LEN +1 ]; +char share[MAX_SHARE_SIZE +1 ];char prefix[PATH_MAX +1 ];char options[MAX_OPTIONS_LEN ]; -char domain[MAX_DOMAIN_SIZE +1 ]; +char domain[MAX_DOMAINNAME_SIZE +1 ];
Also, as far as I know, MAX_DOMAINNAME_SIZE is 256 which already content '\0', do we need consider about it ? (and the same to another macro constants).
Quoted 26 lines
Quoted 24 lines
Quoted 22 lines
mount.cifs.c +3
-3char username[MAX_USERNAME_SIZE +1 ]; -char password[MOUNT_PASSWD_SIZE +1 ]; +char password[MAX_PASSWORD_SIZE +1 ];char addrlist[MAX_ADDR_LIST_LEN ]; unsigned int got_user:1; unsigned int got_password:1;@@ -1766,13 +1777,13 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info, }if (!parsed_info->got_password) { -char tmp_pass[MOUNT_PASSWD_SIZE +1 ]; +char tmp_pass[MAX_PASSWORD_SIZE +1 ];char *prompt =NULL ;if (asprintf (&prompt,"Password for %s@%s: " , parsed_info->username, orig_dev) <0 ) prompt =NULL ; -if (get_password (prompt ? prompt :"Password: " , tmp_pass,MOUNT_PASSWD_SIZE +1 )) { +if (get_password (prompt ? prompt :"Password: " , tmp_pass,MAX_PASSWORD_SIZE +1 )) { rc =set_password (parsed_info, tmp_pass); }else {fprintf (stderr,"Error reading password, exiting\n" );
Signature · 1 line
Chen Gang
Quoted 26 lines · Chen Gang
Quoted 17 lines · Jeff Layton
Quoted 7 lines · On Mon, 22 Jul 2013 13:47:23 -0400 [email protected] wrote:
From: Scott Lovenberg <[email protected]>
This is an RFC for how we'd use autoconf to get the Linux kernel headers in
include/uapi/linux/cifs.h. If this is the correct approach, I'll formalize this patch. I've never played with autoconf before so this is completely untested but should (read: might) probably work.Quoted 6 lines
Signed-off-by Scott Lovenberg <[email protected]>--- configure.ac | 3 +++ mount.cifs.c | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-)Quoted 7 lines
I think the first step is to do a kernel patch that makes this
cifs.hfile. I won't commit any sort of patch like this until that's committed first.Also "
cifs.h" is somewhat generic. I think you should probably name it a bit more specifically -- maybeinclude/uapi/linux/cifs/cifs_mount.h...
Quoted 8 lines
Do we need add prefix '
CIFS_' for the macro constants to let them in their own name space ? (e.g. use 'CIFS_MAX_DOMAIN_SIZE' instead of 'MAX_DOMAIN_SIZE').Thanks.
--
Quoted 2 lines
Chen Gang
That's probably a good idea. I'll be submitting this patch set later today.
Signature · 2 lines
Peace and Blessings, -Scott.