@@ -89,6 +89,7 @@ struct smb_vol {
8989 unsigned int wsize ;
9090 unsigned int sockopt ;
9191 unsigned short int port ;
92+ char * prepath ;
9293};
9394
9495static int ipv4_connect (struct sockaddr_in * psin_server ,
@@ -993,6 +994,28 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
993994 printk (KERN_WARNING "CIFS: domain name too long\n" );
994995 return 1 ;
995996 }
997+ } else if (strnicmp (data , "prefixpath" , 10 ) == 0 ) {
998+ if (!value || !* value ) {
999+ printk (KERN_WARNING
1000+ "CIFS: invalid path prefix\n" );
1001+ return 1 ; /* needs_arg; */
1002+ }
1003+ if ((temp_len = strnlen (value , 1024 )) < 1024 ) {
1004+ if (value [0 ] != '/' )
1005+ temp_len ++ ; /* missing leading slash */
1006+ vol -> prepath = kmalloc (temp_len + 1 ,GFP_KERNEL );
1007+ if (vol -> prepath == NULL )
1008+ return 1 ;
1009+ if (value [0 ] != '/' ) {
1010+ vol -> prepath [0 ] = '/' ;
1011+ strcpy (vol -> prepath + 1 ,value );
1012+ } else
1013+ strcpy (vol -> prepath ,value );
1014+ cFYI (1 ,("prefix path %s" ,vol -> prepath ));
1015+ } else {
1016+ printk (KERN_WARNING "CIFS: prefix too long\n" );
1017+ return 1 ;
1018+ }
9961019 } else if (strnicmp (data , "iocharset" , 9 ) == 0 ) {
9971020 if (!value || !* value ) {
9981021 printk (KERN_WARNING "CIFS: invalid iocharset specified\n" );
@@ -1605,6 +1628,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
16051628 if (cifs_parse_mount_options (mount_data , devname , & volume_info )) {
16061629 kfree (volume_info .UNC );
16071630 kfree (volume_info .password );
1631+ kfree (volume_info .prepath );
16081632 FreeXid (xid );
16091633 return - EINVAL ;
16101634 }
@@ -1619,6 +1643,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
16191643 locations such as env variables and files on disk */
16201644 kfree (volume_info .UNC );
16211645 kfree (volume_info .password );
1646+ kfree (volume_info .prepath );
16221647 FreeXid (xid );
16231648 return - EINVAL ;
16241649 }
@@ -1639,6 +1664,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
16391664 /* we failed translating address */
16401665 kfree (volume_info .UNC );
16411666 kfree (volume_info .password );
1667+ kfree (volume_info .prepath );
16421668 FreeXid (xid );
16431669 return - EINVAL ;
16441670 }
@@ -1651,13 +1677,15 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
16511677 cERROR (1 ,("Connecting to DFS root not implemented yet" ));
16521678 kfree (volume_info .UNC );
16531679 kfree (volume_info .password );
1680+ kfree (volume_info .prepath );
16541681 FreeXid (xid );
16551682 return - EINVAL ;
16561683 } else /* which servers DFS root would we conect to */ {
16571684 cERROR (1 ,
16581685 ("CIFS mount error: No UNC path (e.g. -o unc=//192.168.1.100/public) specified" ));
16591686 kfree (volume_info .UNC );
16601687 kfree (volume_info .password );
1688+ kfree (volume_info .prepath );
16611689 FreeXid (xid );
16621690 return - EINVAL ;
16631691 }
@@ -1672,6 +1700,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
16721700 cERROR (1 ,("CIFS mount error: iocharset %s not found" ,volume_info .iocharset ));
16731701 kfree (volume_info .UNC );
16741702 kfree (volume_info .password );
1703+ kfree (volume_info .prepath );
16751704 FreeXid (xid );
16761705 return - ELIBACC ;
16771706 }
@@ -1688,6 +1717,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
16881717 else {
16891718 kfree (volume_info .UNC );
16901719 kfree (volume_info .password );
1720+ kfree (volume_info .prepath );
16911721 FreeXid (xid );
16921722 return - EINVAL ;
16931723 }
@@ -1710,6 +1740,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
17101740 sock_release (csocket );
17111741 kfree (volume_info .UNC );
17121742 kfree (volume_info .password );
1743+ kfree (volume_info .prepath );
17131744 FreeXid (xid );
17141745 return rc ;
17151746 }
@@ -1720,6 +1751,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
17201751 sock_release (csocket );
17211752 kfree (volume_info .UNC );
17221753 kfree (volume_info .password );
1754+ kfree (volume_info .prepath );
17231755 FreeXid (xid );
17241756 return rc ;
17251757 } else {
@@ -1744,6 +1776,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
17441776 sock_release (csocket );
17451777 kfree (volume_info .UNC );
17461778 kfree (volume_info .password );
1779+ kfree (volume_info .prepath );
17471780 FreeXid (xid );
17481781 return rc ;
17491782 }
@@ -1831,6 +1864,14 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
18311864 /* Windows ME may prefer this */
18321865 cFYI (1 ,("readsize set to minimum 2048" ));
18331866 }
1867+ /* calculate prepath */
1868+ cifs_sb -> prepath = volume_info .prepath ;
1869+ if (cifs_sb -> prepath ) {
1870+ cifs_sb -> prepathlen = strlen (cifs_sb -> prepath );
1871+ cifs_sb -> prepath [0 ] = CIFS_DIR_SEP (cifs_sb );
1872+ volume_info .prepath = NULL ;
1873+ } else
1874+ cifs_sb -> prepathlen = 0 ;
18341875 cifs_sb -> mnt_uid = volume_info .linux_uid ;
18351876 cifs_sb -> mnt_gid = volume_info .linux_gid ;
18361877 cifs_sb -> mnt_file_mode = volume_info .file_mode ;
@@ -2008,6 +2049,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
20082049 the password ptr is put in the new session structure (in which case the
20092050 password will be freed at unmount time) */
20102051 kfree (volume_info .UNC );
2052+ kfree (volume_info .prepath );
20112053 FreeXid (xid );
20122054 return rc ;
20132055}
@@ -3195,6 +3237,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
31953237 int xid ;
31963238 struct cifsSesInfo * ses = NULL ;
31973239 struct task_struct * cifsd_task ;
3240+ char * tmp ;
31983241
31993242 xid = GetXid ();
32003243
@@ -3228,6 +3271,10 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
32283271 }
32293272
32303273 cifs_sb -> tcon = NULL ;
3274+ tmp = cifs_sb -> prepath ;
3275+ cifs_sb -> prepathlen = 0 ;
3276+ cifs_sb -> prepath = NULL ;
3277+ kfree (tmp );
32313278 if (ses )
32323279 schedule_timeout_interruptible (msecs_to_jiffies (500 ));
32333280 if (ses )
0 commit comments