1 From: Goldwyn Rodrigues <rgoldwyn@suse.de>
2 Subject: Unlink mapped drives on exit
5 Mapped drives were not being unlinked properly because
6 of ABI change in the kernel. Fixed local_unlink function
7 to correctly unlink files.
10 fs/novfs/daemon.c | 97 +++++++++++++++++++++++++++++++-----------------------
11 fs/novfs/nwcapi.c | 2 -
12 2 files changed, 57 insertions(+), 42 deletions(-)
14 Index: linux-2.6.27/fs/novfs/daemon.c
15 ===================================================================
16 --- linux-2.6.27.orig/fs/novfs/daemon.c 2008-11-27 16:02:22.000000000 +0530
17 +++ linux-2.6.27/fs/novfs/daemon.c 2008-11-28 11:20:08.000000000 +0530
20 #include <linux/module.h>
22 +#include <linux/mount.h>
23 #include <linux/slab.h>
24 #include <linux/list.h>
25 #include <linux/timer.h>
26 @@ -96,7 +97,7 @@ static int NwdConvertNetwareHandle(struc
27 static int set_map_drive(struct novfs_xplat *pdata, struct novfs_schandle Session);
28 static int unmap_drive(struct novfs_xplat *pdata, struct novfs_schandle Session);
29 static int NwdGetMountPath(struct novfs_xplat *pdata);
30 -static int local_unlink(const char *pathname);
31 +static long local_unlink(const char *pathname);
34 /*===[ Global variables ]=================================================*/
35 @@ -1610,7 +1611,7 @@ int novfs_daemon_lib_ioctl(struct inode
37 case NWC_SET_CONN_INFO:
39 - ("[VFS XPLAT] Call NwGetConnInfo\n");
40 + ("[VFS XPLAT] Call NwSetConnInfo\n");
42 novfs_set_conn_info(&data, dh->session);
44 @@ -2061,54 +2062,68 @@ static void RemoveDriveMaps(void)
48 -static int local_unlink(const char *pathname)
49 +/* As picked from do_unlinkat() */
51 +static long local_unlink(const char *pathname)
54 struct dentry *dentry;
57 struct inode *inode = NULL;
59 - DbgPrint("local_unlink: %s\n", pathname);
60 error = path_lookup(pathname, LOOKUP_PARENT, &nd);
61 - DbgPrint("local_unlink: path_lookup %d\n", error);
64 - if (nd.last_type == LAST_NORM) {
65 - dentry = lookup_create(&nd, 1);
66 - DbgPrint("local_unlink: lookup_hash 0x%p\n", dentry);
68 - error = PTR_ERR(dentry);
69 - if (!IS_ERR(dentry)) {
70 - if (nd.last.name[nd.last.len]) {
73 - d_inode ? -ENOENT : S_ISDIR(dentry->
76 - ? -EISDIR : -ENOTDIR;
78 - inode = dentry->d_inode;
80 - atomic_inc(&inode->i_count);
82 - error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt);
84 - ("local_unlink: vfs_unlink %d\n",
89 - mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
93 + DbgPrint("local_unlink: path_lookup %s error: %d\n", pathname, error);
98 + if (nd.last_type != LAST_NORM)
100 + mutex_lock(&nd.path.dentry->d_inode->i_mutex);
101 + /* Get the filename of pathname */
102 + name=c=(char *)pathname;
108 + dentry = lookup_one_len(name, nd.path.dentry, strlen(name));
109 + error = PTR_ERR(dentry);
110 + DbgPrint("local_unlink: dentry %p\n", dentry);
111 + if (!(dentry->d_inode->i_mode & S_IFLNK)) {
112 + DbgPrint("local_unlink: %s not a link", name);
117 + if (!IS_ERR(dentry)) {
118 + /* Why not before? Because we want correct error value */
119 + if (nd.last.name[nd.last.len])
121 + inode = dentry->d_inode;
123 + atomic_inc(&inode->i_count);
124 + error = mnt_want_write(nd.path.mnt);
125 + DbgPrint("local_unlink: inode %p mnt_want_write error %d\n", inode, error);
128 + error = vfs_unlink(nd.path.dentry->d_inode, dentry, nd.path.mnt);
129 + mnt_drop_write(nd.path.mnt);
135 + mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
137 iput(inode); /* truncate the inode here */
140 - DbgPrint("local_unlink: error=%d\n", error);
142 + path_put(&nd.path);
143 + DbgPrint("local_unlink: returning error %d\n", error);
147 + error = !dentry->d_inode ? -ENOENT :
148 + S_ISDIR(dentry->d_inode->i_mode) ? -EISDIR : -ENOTDIR;
152 Index: linux-2.6.27/fs/novfs/nwcapi.c
153 ===================================================================
154 --- linux-2.6.27.orig/fs/novfs/nwcapi.c 2008-11-27 16:02:22.000000000 +0530
155 +++ linux-2.6.27/fs/novfs/nwcapi.c 2008-11-28 11:02:15.000000000 +0530
156 @@ -993,7 +993,7 @@ int novfs_scan_conn_info(struct novfs_xp
157 DbgPrint("NwScanConnInfo: Reply recieved\n");
158 DbgPrint(" NextIndex = %x\n", connInfo.uScanIndex);
159 DbgPrint(" ErrorCode = %x\n", reply->Reply.ErrorCode);
160 - DbgPrint(" data = %x\n", reply->data);
161 + DbgPrint(" data = %p\n", reply->data);
163 pDConnInfo = (struct nwd_scan_conn_info *) reply->data;
164 retCode = (unsigned long) reply->Reply.ErrorCode;