diff options
author | Jeff Layton <jlayton@redhat.com> | 2011-07-06 08:10:38 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2011-07-07 23:51:23 -0400 |
commit | 04db79b015dafcb79371fda6b5c32ffdbd31a2ff (patch) | |
tree | eef264d76b4f352d56be896b950631d857ec61b0 /fs/cifs/connect.c | |
parent | f9e59bcba2cff580a3ccf62e89460f9eed295d89 (diff) |
cifs: factor smb_vol allocation out of cifs_setup_volume_info
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Pavel Shilovsky <piastryyy@gmail.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index dd064075ddfb..46cc0ad03487 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -2931,33 +2931,20 @@ expand_dfs_referral(int xid, struct cifs_ses *pSesInfo, | |||
2931 | } | 2931 | } |
2932 | #endif | 2932 | #endif |
2933 | 2933 | ||
2934 | int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, | 2934 | static int |
2935 | const char *devname) | 2935 | cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, |
2936 | const char *devname) | ||
2936 | { | 2937 | { |
2937 | struct smb_vol *volume_info; | ||
2938 | int rc = 0; | 2938 | int rc = 0; |
2939 | 2939 | ||
2940 | *pvolume_info = NULL; | 2940 | if (cifs_parse_mount_options(mount_data, devname, volume_info)) |
2941 | 2941 | return -EINVAL; | |
2942 | volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); | ||
2943 | if (!volume_info) { | ||
2944 | rc = -ENOMEM; | ||
2945 | goto out; | ||
2946 | } | ||
2947 | |||
2948 | if (cifs_parse_mount_options(mount_data, devname, | ||
2949 | volume_info)) { | ||
2950 | rc = -EINVAL; | ||
2951 | goto out; | ||
2952 | } | ||
2953 | 2942 | ||
2954 | if (volume_info->nullauth) { | 2943 | if (volume_info->nullauth) { |
2955 | cFYI(1, "null user"); | 2944 | cFYI(1, "null user"); |
2956 | volume_info->username = kzalloc(1, GFP_KERNEL); | 2945 | volume_info->username = kzalloc(1, GFP_KERNEL); |
2957 | if (volume_info->username == NULL) { | 2946 | if (volume_info->username == NULL) |
2958 | rc = -ENOMEM; | 2947 | return -ENOMEM; |
2959 | goto out; | ||
2960 | } | ||
2961 | } else if (volume_info->username) { | 2948 | } else if (volume_info->username) { |
2962 | /* BB fixme parse for domain name here */ | 2949 | /* BB fixme parse for domain name here */ |
2963 | cFYI(1, "Username: %s", volume_info->username); | 2950 | cFYI(1, "Username: %s", volume_info->username); |
@@ -2965,8 +2952,7 @@ int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, | |||
2965 | cifserror("No username specified"); | 2952 | cifserror("No username specified"); |
2966 | /* In userspace mount helper we can get user name from alternate | 2953 | /* In userspace mount helper we can get user name from alternate |
2967 | locations such as env variables and files on disk */ | 2954 | locations such as env variables and files on disk */ |
2968 | rc = -EINVAL; | 2955 | return -EINVAL; |
2969 | goto out; | ||
2970 | } | 2956 | } |
2971 | 2957 | ||
2972 | /* this is needed for ASCII cp to Unicode converts */ | 2958 | /* this is needed for ASCII cp to Unicode converts */ |
@@ -2978,18 +2964,32 @@ int cifs_setup_volume_info(struct smb_vol **pvolume_info, char *mount_data, | |||
2978 | if (volume_info->local_nls == NULL) { | 2964 | if (volume_info->local_nls == NULL) { |
2979 | cERROR(1, "CIFS mount error: iocharset %s not found", | 2965 | cERROR(1, "CIFS mount error: iocharset %s not found", |
2980 | volume_info->iocharset); | 2966 | volume_info->iocharset); |
2981 | rc = -ELIBACC; | 2967 | return -ELIBACC; |
2982 | goto out; | ||
2983 | } | 2968 | } |
2984 | } | 2969 | } |
2985 | 2970 | ||
2986 | *pvolume_info = volume_info; | ||
2987 | return rc; | ||
2988 | out: | ||
2989 | cifs_cleanup_volume_info(volume_info); | ||
2990 | return rc; | 2971 | return rc; |
2991 | } | 2972 | } |
2992 | 2973 | ||
2974 | struct smb_vol * | ||
2975 | cifs_get_volume_info(char *mount_data, const char *devname) | ||
2976 | { | ||
2977 | int rc; | ||
2978 | struct smb_vol *volume_info; | ||
2979 | |||
2980 | volume_info = kzalloc(sizeof(struct smb_vol), GFP_KERNEL); | ||
2981 | if (!volume_info) | ||
2982 | return ERR_PTR(-ENOMEM); | ||
2983 | |||
2984 | rc = cifs_setup_volume_info(volume_info, mount_data, devname); | ||
2985 | if (rc) { | ||
2986 | cifs_cleanup_volume_info(volume_info); | ||
2987 | volume_info = ERR_PTR(rc); | ||
2988 | } | ||
2989 | |||
2990 | return volume_info; | ||
2991 | } | ||
2992 | |||
2993 | int | 2993 | int |
2994 | cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) | 2994 | cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) |
2995 | { | 2995 | { |