Skip to content

Commit 3eeab61

Browse files
author
Linus Torvalds
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: [CIFS] statfs for cifs unix extensions no longer experimental [CIFS] New POSIX locking code not setting rc properly to zero on successful [CIFS] Support deep tree mounts (e.g. mounts to //server/share/path)
2 parents 6585b57 + b8c06a2 commit 3eeab61

9 files changed

Lines changed: 76 additions & 14 deletions

File tree

‎fs/cifs/CHANGES‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 1.46
2+
------------
3+
Support deep tree mounts. Better support OS/2, Win9x (DOS) time stamps.
4+
15
Version 1.45
26
------------
37
Do not time out lockw calls when using posix extensions. Do not
@@ -6,7 +10,8 @@ on requests on other threads. Improve POSIX locking emulation,
610
(lock cancel now works, and unlock of merged range works even
711
to Windows servers now). Fix oops on mount to lanman servers
812
(win9x, os/2 etc.) when null password. Do not send listxattr
9-
(SMB to query all EAs) if nouser_xattr specified.
13+
(SMB to query all EAs) if nouser_xattr specified. Fix SE Linux
14+
problem (instantiate inodes/dentries in right order for readdir).
1015

1116
Version 1.44
1217
------------

‎fs/cifs/cifs_fs_sb.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@ struct cifs_sb_info {
4040
mode_t mnt_file_mode;
4141
mode_t mnt_dir_mode;
4242
int mnt_cifs_flags;
43+
int prepathlen;
44+
char * prepath;
4345
};
4446
#endif /* _CIFS_FS_SB_H */

‎fs/cifs/cifsfs.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
189189
buf->f_files = 0; /* undefined */
190190
buf->f_ffree = 0; /* unlimited */
191191

192-
#ifdef CONFIG_CIFS_EXPERIMENTAL
193192
/* BB we could add a second check for a QFS Unix capability bit */
194193
/* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */
195194
if ((pTcon->ses->capabilities & CAP_UNIX) && (CIFS_POSIX_EXTENSIONS &
@@ -199,7 +198,6 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
199198
/* Only need to call the old QFSInfo if failed
200199
on newer one */
201200
if(rc)
202-
#endif /* CIFS_EXPERIMENTAL */
203201
rc = CIFSSMBQFSInfo(xid, pTcon, buf);
204202

205203
/* Old Windows servers do not support level 103, retry with level

‎fs/cifs/cifsfs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,5 @@ extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
100100
extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
101101
extern int cifs_ioctl (struct inode * inode, struct file * filep,
102102
unsigned int command, unsigned long arg);
103-
#define CIFS_VERSION "1.45"
103+
#define CIFS_VERSION "1.46"
104104
#endif /* _CIFSFS_H */

‎fs/cifs/cifspdu.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,7 @@ struct smb_t2_rsp {
13441344
#define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
13451345
#define SMB_QUERY_POSIX_PERMISSION 0x207
13461346
#define SMB_QUERY_POSIX_LOCK 0x208
1347+
/* #define SMB_POSIX_OPEN 0x209 */
13471348
#define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
13481349
#define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
13491350
#define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
@@ -1363,6 +1364,7 @@ struct smb_t2_rsp {
13631364
#define SMB_SET_XATTR 0x205
13641365
#define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
13651366
#define SMB_SET_POSIX_LOCK 0x208
1367+
#define SMB_POSIX_OPEN 0x209
13661368
#define SMB_SET_FILE_BASIC_INFO2 0x3ec
13671369
#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo level too */
13681370
#define SMB_FILE_ALL_INFO2 0x3fa

‎fs/cifs/connect.c‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

9495
static 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)

‎fs/cifs/dir.c‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ char *
4646
build_path_from_dentry(struct dentry *direntry)
4747
{
4848
struct dentry *temp;
49-
int namelen = 0;
49+
int namelen;
50+
int pplen;
5051
char *full_path;
5152
char dirsep;
5253

@@ -56,7 +57,9 @@ build_path_from_dentry(struct dentry *direntry)
5657
when the server crashed */
5758

5859
dirsep = CIFS_DIR_SEP(CIFS_SB(direntry->d_sb));
60+
pplen = CIFS_SB(direntry->d_sb)->prepathlen;
5961
cifs_bp_rename_retry:
62+
namelen = pplen;
6063
for (temp = direntry; !IS_ROOT(temp);) {
6164
namelen += (1 + temp->d_name.len);
6265
temp = temp->d_parent;
@@ -70,7 +73,6 @@ build_path_from_dentry(struct dentry *direntry)
7073
if(full_path == NULL)
7174
return full_path;
7275
full_path[namelen] = 0; /* trailing null */
73-
7476
for (temp = direntry; !IS_ROOT(temp);) {
7577
namelen -= 1 + temp->d_name.len;
7678
if (namelen < 0) {
@@ -79,7 +81,7 @@ build_path_from_dentry(struct dentry *direntry)
7981
full_path[namelen] = dirsep;
8082
strncpy(full_path + namelen + 1, temp->d_name.name,
8183
temp->d_name.len);
82-
cFYI(0, (" name: %s ", full_path + namelen));
84+
cFYI(0, ("name: %s", full_path + namelen));
8385
}
8486
temp = temp->d_parent;
8587
if(temp == NULL) {
@@ -88,18 +90,23 @@ build_path_from_dentry(struct dentry *direntry)
8890
return NULL;
8991
}
9092
}
91-
if (namelen != 0) {
93+
if (namelen != pplen) {
9294
cERROR(1,
93-
("We did not end path lookup where we expected namelen is %d",
95+
("did not end path lookup where expected namelen is %d",
9496
namelen));
95-
/* presumably this is only possible if we were racing with a rename
97+
/* presumably this is only possible if racing with a rename
9698
of one of the parent directories (we can not lock the dentries
9799
above us to prevent this, but retrying should be harmless) */
98100
kfree(full_path);
99-
namelen = 0;
100101
goto cifs_bp_rename_retry;
101102
}
102-
103+
/* DIR_SEP already set for byte 0 / vs \ but not for
104+
subsequent slashes in prepath which currently must
105+
be entered the right way - not sure if there is an alternative
106+
since the '\' is a valid posix character so we can not switch
107+
those safely to '/' if any are found in the middle of the prepath */
108+
/* BB test paths to Windows with '/' in the midst of prepath */
109+
strncpy(full_path,CIFS_SB(direntry->d_sb)->prepath,pplen);
103110
return full_path;
104111
}
105112

‎fs/cifs/file.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
752752
int stored_rc = 0;
753753
struct cifsLockInfo *li, *tmp;
754754

755+
rc = 0;
755756
down(&fid->lock_sem);
756757
list_for_each_entry_safe(li, tmp, &fid->llist, llist) {
757758
if (pfLock->fl_start <= li->offset &&
@@ -766,7 +767,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
766767
kfree(li);
767768
}
768769
}
769-
up(&fid->lock_sem);
770+
up(&fid->lock_sem);
770771
}
771772
}
772773

‎fs/cifs/xattr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ ssize_t cifs_getxattr(struct dentry * direntry, const char * ea_name,
269269
rc = CIFSSMBGetCIFSACL(xid, pTcon, fid,
270270
ea_value, buf_size,
271271
ACL_TYPE_ACCESS);
272-
CIFSSMBClose(xid, pTcon, fid)
272+
CIFSSMBClose(xid, pTcon, fid);
273273
}
274274
} */ /* BB enable after fixing up return data */
275275

0 commit comments

Comments
 (0)