OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [fs/] [smbfs/] [inode.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  inode.c
3
 *
4
 *  Copyright (C) 1995, 1996 by Paal-Kr. Engstad and Volker Lendecke
5
 *  Copyright (C) 1997 by Volker Lendecke
6
 *
7
 *  Please add a note about your changes to smbfs in the ChangeLog file.
8
 */
9
 
10
#include <linux/config.h>
11
#include <linux/module.h>
12
#include <linux/sched.h>
13
#include <linux/kernel.h>
14
#include <linux/mm.h>
15
#include <linux/string.h>
16
#include <linux/stat.h>
17
#include <linux/errno.h>
18
#include <linux/locks.h>
19
#include <linux/slab.h>
20
#include <linux/init.h>
21
#include <linux/file.h>
22
#include <linux/dcache.h>
23
#include <linux/smp_lock.h>
24
#include <linux/nls.h>
25
#include <linux/seq_file.h>
26
 
27
#include <linux/smb_fs.h>
28
#include <linux/smbno.h>
29
#include <linux/smb_mount.h>
30
 
31
#include <asm/system.h>
32
#include <asm/uaccess.h>
33
 
34
#include "smb_debug.h"
35
#include "getopt.h"
36
#include "proto.h"
37
 
38
/* Always pick a default string */
39
#ifdef CONFIG_SMB_NLS_REMOTE
40
#define SMB_NLS_REMOTE CONFIG_SMB_NLS_REMOTE
41
#else
42
#define SMB_NLS_REMOTE ""
43
#endif
44
 
45
#define SMB_TTL_DEFAULT 1000
46
#define SMB_TIMEO_DEFAULT 30
47
 
48
static void smb_delete_inode(struct inode *);
49
static void smb_put_super(struct super_block *);
50
static int  smb_statfs(struct super_block *, struct statfs *);
51
static int  smb_show_options(struct seq_file *, struct vfsmount *);
52
 
53
static struct super_operations smb_sops =
54
{
55
        put_inode:      force_delete,
56
        delete_inode:   smb_delete_inode,
57
        put_super:      smb_put_super,
58
        statfs:         smb_statfs,
59
        show_options:   smb_show_options,
60
};
61
 
62
 
63
/* We are always generating a new inode here */
64
struct inode *
65
smb_iget(struct super_block *sb, struct smb_fattr *fattr)
66
{
67
        struct inode *result;
68
 
69
        DEBUG1("smb_iget: %p\n", fattr);
70
 
71
        result = new_inode(sb);
72
        if (!result)
73
                return result;
74
        result->i_ino = fattr->f_ino;
75
        memset(&(result->u.smbfs_i), 0, sizeof(result->u.smbfs_i));
76
        smb_set_inode_attr(result, fattr);
77
        if (S_ISREG(result->i_mode)) {
78
                result->i_op = &smb_file_inode_operations;
79
                result->i_fop = &smb_file_operations;
80
                result->i_data.a_ops = &smb_file_aops;
81
        } else if (S_ISDIR(result->i_mode)) {
82
                struct smb_sb_info *server = &(sb->u.smbfs_sb);
83
                if (server->opt.capabilities & SMB_CAP_UNIX)
84
                        result->i_op = &smb_dir_inode_operations_unix;
85
                else
86
                        result->i_op = &smb_dir_inode_operations;
87
                result->i_fop = &smb_dir_operations;
88
        } else if(S_ISLNK(result->i_mode)) {
89
                result->i_op = &smb_link_inode_operations;
90
        } else {
91
                init_special_inode(result, result->i_mode, fattr->f_rdev);
92
        }
93
        insert_inode_hash(result);
94
        return result;
95
}
96
 
97
/*
98
 * Copy the inode data to a smb_fattr structure.
99
 */
100
void
101
smb_get_inode_attr(struct inode *inode, struct smb_fattr *fattr)
102
{
103
        memset(fattr, 0, sizeof(struct smb_fattr));
104
        fattr->f_mode   = inode->i_mode;
105
        fattr->f_nlink  = inode->i_nlink;
106
        fattr->f_ino    = inode->i_ino;
107
        fattr->f_uid    = inode->i_uid;
108
        fattr->f_gid    = inode->i_gid;
109
        fattr->f_rdev   = inode->i_rdev;
110
        fattr->f_size   = inode->i_size;
111
        fattr->f_mtime  = inode->i_mtime;
112
        fattr->f_ctime  = inode->i_ctime;
113
        fattr->f_atime  = inode->i_atime;
114
        fattr->f_blksize= inode->i_blksize;
115
        fattr->f_blocks = inode->i_blocks;
116
 
117
        fattr->attr     = inode->u.smbfs_i.attr;
118
        /*
119
         * Keep the attributes in sync with the inode permissions.
120
         */
121
        if (fattr->f_mode & S_IWUSR)
122
                fattr->attr &= ~aRONLY;
123
        else
124
                fattr->attr |= aRONLY;
125
}
126
 
127
/*
128
 * Update the inode, possibly causing it to invalidate its pages if mtime/size
129
 * is different from last time.
130
 */
131
void
132
smb_set_inode_attr(struct inode *inode, struct smb_fattr *fattr)
133
{
134
        /*
135
         * A size change should have a different mtime, or same mtime
136
         * but different size.
137
         */
138
        time_t last_time = inode->i_mtime;
139
        loff_t last_sz = inode->i_size;
140
 
141
        inode->i_mode   = fattr->f_mode;
142
        inode->i_nlink  = fattr->f_nlink;
143
        inode->i_uid    = fattr->f_uid;
144
        inode->i_gid    = fattr->f_gid;
145
        inode->i_rdev   = fattr->f_rdev;
146
        inode->i_ctime  = fattr->f_ctime;
147
        inode->i_blksize= fattr->f_blksize;
148
        inode->i_blocks = fattr->f_blocks;
149
        inode->i_size   = fattr->f_size;
150
        inode->i_mtime  = fattr->f_mtime;
151
        inode->i_atime  = fattr->f_atime;
152
        inode->u.smbfs_i.attr = fattr->attr;
153
        /*
154
         * Update the "last time refreshed" field for revalidation.
155
         */
156
        inode->u.smbfs_i.oldmtime = jiffies;
157
 
158
        if (inode->i_mtime != last_time || inode->i_size != last_sz) {
159
                VERBOSE("%ld changed, old=%ld, new=%ld, oz=%ld, nz=%ld\n",
160
                        inode->i_ino,
161
                        (long) last_time, (long) inode->i_mtime,
162
                        (long) last_sz, (long) inode->i_size);
163
 
164
                if (!S_ISDIR(inode->i_mode))
165
                        invalidate_inode_pages(inode);
166
        }
167
}
168
 
169
/*
170
 * This is called if the connection has gone bad ...
171
 * try to kill off all the current inodes.
172
 */
173
void
174
smb_invalidate_inodes(struct smb_sb_info *server)
175
{
176
        VERBOSE("\n");
177
        shrink_dcache_sb(SB_of(server));
178
        invalidate_inodes(SB_of(server));
179
}
180
 
181
/*
182
 * This is called to update the inode attributes after
183
 * we've made changes to a file or directory.
184
 */
185
static int
186
smb_refresh_inode(struct dentry *dentry)
187
{
188
        struct inode *inode = dentry->d_inode;
189
        int error;
190
        struct smb_fattr fattr;
191
 
192
        error = smb_proc_getattr(dentry, &fattr);
193
        if (!error) {
194
                smb_renew_times(dentry);
195
                /*
196
                 * Check whether the type part of the mode changed,
197
                 * and don't update the attributes if it did.
198
                 *
199
                 * And don't dick with the root inode
200
                 */
201
                if (inode->i_ino == 2)
202
                        return error;
203
                if (S_ISLNK(inode->i_mode))
204
                        return error;   /* VFS will deal with it */
205
 
206
                if ((inode->i_mode & S_IFMT) == (fattr.f_mode & S_IFMT)) {
207
                        smb_set_inode_attr(inode, &fattr);
208
                } else {
209
                        /*
210
                         * Big trouble! The inode has become a new object,
211
                         * so any operations attempted on it are invalid.
212
                         *
213
                         * To limit damage, mark the inode as bad so that
214
                         * subsequent lookup validations will fail.
215
                         */
216
                        PARANOIA("%s/%s changed mode, %07o to %07o\n",
217
                                 DENTRY_PATH(dentry),
218
                                 inode->i_mode, fattr.f_mode);
219
 
220
                        fattr.f_mode = inode->i_mode; /* save mode */
221
                        make_bad_inode(inode);
222
                        inode->i_mode = fattr.f_mode; /* restore mode */
223
                        /*
224
                         * No need to worry about unhashing the dentry: the
225
                         * lookup validation will see that the inode is bad.
226
                         * But we do want to invalidate the caches ...
227
                         */
228
                        if (!S_ISDIR(inode->i_mode))
229
                                invalidate_inode_pages(inode);
230
                        else
231
                                smb_invalid_dir_cache(inode);
232
                        error = -EIO;
233
                }
234
        }
235
        return error;
236
}
237
 
238
/*
239
 * This is called when we want to check whether the inode
240
 * has changed on the server.  If it has changed, we must
241
 * invalidate our local caches.
242
 */
243
int
244
smb_revalidate_inode(struct dentry *dentry)
245
{
246
        struct smb_sb_info *s = server_from_dentry(dentry);
247
        struct inode *inode = dentry->d_inode;
248
        int error = 0;
249
 
250
        DEBUG1("smb_revalidate_inode\n");
251
        lock_kernel();
252
 
253
        /*
254
         * Check whether we've recently refreshed the inode.
255
         */
256
        if (time_before(jiffies, inode->u.smbfs_i.oldmtime + SMB_MAX_AGE(s))) {
257
                VERBOSE("up-to-date, ino=%ld, jiffies=%lu, oldtime=%lu\n",
258
                        inode->i_ino, jiffies, inode->u.smbfs_i.oldmtime);
259
                goto out;
260
        }
261
 
262
        error = smb_refresh_inode(dentry);
263
out:
264
        unlock_kernel();
265
        return error;
266
}
267
 
268
/*
269
 * This routine is called when i_nlink == 0 and i_count goes to 0.
270
 * All blocking cleanup operations need to go here to avoid races.
271
 */
272
static void
273
smb_delete_inode(struct inode *ino)
274
{
275
        DEBUG1("ino=%ld\n", ino->i_ino);
276
        lock_kernel();
277
        if (smb_close(ino))
278
                PARANOIA("could not close inode %ld\n", ino->i_ino);
279
        unlock_kernel();
280
        clear_inode(ino);
281
}
282
 
283
static struct option opts[] = {
284
        { "version",    0, 'v' },
285
        { "win95",      SMB_MOUNT_WIN95, 1 },
286
        { "oldattr",    SMB_MOUNT_OLDATTR, 1 },
287
        { "dirattr",    SMB_MOUNT_DIRATTR, 1 },
288
        { "case",       SMB_MOUNT_CASE, 1 },
289
        { "uid",        0, 'u' },
290
        { "gid",        0, 'g' },
291
        { "file_mode",  0, 'f' },
292
        { "dir_mode",   0, 'd' },
293
        { "iocharset",  0, 'i' },
294
        { "codepage",   0, 'c' },
295
        { "ttl",        0, 't' },
296
        { "timeo",      0, 'o' },
297
        { NULL,         0, 0}
298
};
299
 
300
static int
301
parse_options(struct smb_mount_data_kernel *mnt, char *options)
302
{
303
        int c;
304
        unsigned long flags;
305
        unsigned long value;
306
        char *optarg;
307
        char *optopt;
308
 
309
        flags = 0;
310
        while ( (c = smb_getopt("smbfs", &options, opts,
311
                                &optopt, &optarg, &flags, &value)) > 0) {
312
 
313
                VERBOSE("'%s' -> '%s'\n", optopt, optarg ? optarg : "<none>");
314
 
315
                switch (c) {
316
                case 1:
317
                        /* got a "flag" option */
318
                        break;
319
                case 'v':
320
                        if (value != SMB_MOUNT_VERSION) {
321
                        printk ("smbfs: Bad mount version %ld, expected %d\n",
322
                                value, SMB_MOUNT_VERSION);
323
                                return 0;
324
                        }
325
                        mnt->version = value;
326
                        break;
327
                case 'u':
328
                        mnt->uid = value;
329
                        break;
330
                case 'g':
331
                        mnt->gid = value;
332
                        break;
333
                case 'f':
334
                        mnt->file_mode = (value & S_IRWXUGO) | S_IFREG;
335
                        break;
336
                case 'd':
337
                        mnt->dir_mode = (value & S_IRWXUGO) | S_IFDIR;
338
                        break;
339
                case 'i':
340
                        strncpy(mnt->codepage.local_name, optarg,
341
                                SMB_NLS_MAXNAMELEN);
342
                        break;
343
                case 'c':
344
                        strncpy(mnt->codepage.remote_name, optarg,
345
                                SMB_NLS_MAXNAMELEN);
346
                        break;
347
                case 't':
348
                        mnt->ttl = value;
349
                        break;
350
                case 'o':
351
                        mnt->timeo = value;
352
                        break;
353
                default:
354
                        printk ("smbfs: Unrecognized mount option %s\n",
355
                                optopt);
356
                        return -1;
357
                }
358
        }
359
        mnt->flags = flags;
360
        return c;
361
}
362
 
363
/*
364
 * smb_show_options() is for displaying mount options in /proc/mounts.
365
 * It tries to avoid showing settings that were not changed from their
366
 * defaults.
367
 */
368
static int
369
smb_show_options(struct seq_file *s, struct vfsmount *m)
370
{
371
        struct smb_mount_data_kernel *mnt = m->mnt_sb->u.smbfs_sb.mnt;
372
        int i;
373
 
374
        for (i = 0; opts[i].name != NULL; i++)
375
                if (mnt->flags & opts[i].flag)
376
                        seq_printf(s, ",%s", opts[i].name);
377
 
378
        if (mnt->uid != 0)
379
                seq_printf(s, ",uid=%d", mnt->uid);
380
        if (mnt->gid != 0)
381
                seq_printf(s, ",gid=%d", mnt->gid);
382
        if (mnt->mounted_uid != 0)
383
                seq_printf(s, ",mounted_uid=%d", mnt->mounted_uid);
384
 
385
        /*
386
         * Defaults for file_mode and dir_mode are unknown to us; they
387
         * depend on the current umask of the user doing the mount.
388
         */
389
        seq_printf(s, ",file_mode=%04o", mnt->file_mode & S_IRWXUGO);
390
        seq_printf(s, ",dir_mode=%04o", mnt->dir_mode & S_IRWXUGO);
391
 
392
        if (strcmp(mnt->codepage.local_name, CONFIG_NLS_DEFAULT))
393
                seq_printf(s, ",iocharset=%s", mnt->codepage.local_name);
394
        if (strcmp(mnt->codepage.remote_name, SMB_NLS_REMOTE))
395
                seq_printf(s, ",codepage=%s", mnt->codepage.remote_name);
396
 
397
        if (mnt->ttl != SMB_TTL_DEFAULT)
398
                seq_printf(s, ",ttl=%d", mnt->ttl);
399
        if (mnt->timeo != SMB_TIMEO_DEFAULT)
400
                seq_printf(s, ",timeo=%d", mnt->timeo);
401
 
402
        return 0;
403
}
404
 
405
static void
406
smb_put_super(struct super_block *sb)
407
{
408
        struct smb_sb_info *server = &(sb->u.smbfs_sb);
409
 
410
        if (server->sock_file) {
411
                smb_dont_catch_keepalive(server);
412
                fput(server->sock_file);
413
        }
414
 
415
        if (server->conn_pid)
416
               kill_proc(server->conn_pid, SIGTERM, 1);
417
 
418
        smb_kfree(server->mnt);
419
        smb_kfree(server->temp_buf);
420
        if (server->packet)
421
                smb_vfree(server->packet);
422
 
423
        if (server->remote_nls) {
424
                unload_nls(server->remote_nls);
425
                server->remote_nls = NULL;
426
        }
427
        if (server->local_nls) {
428
                unload_nls(server->local_nls);
429
                server->local_nls = NULL;
430
        }
431
}
432
 
433
struct super_block *
434
smb_read_super(struct super_block *sb, void *raw_data, int silent)
435
{
436
        struct smb_sb_info *server = &sb->u.smbfs_sb;
437
        struct smb_mount_data_kernel *mnt;
438
        struct smb_mount_data *oldmnt;
439
        struct inode *root_inode;
440
        struct smb_fattr root;
441
        int ver;
442
        void *mem;
443
 
444
        if (!raw_data)
445
                goto out_no_data;
446
 
447
        oldmnt = (struct smb_mount_data *) raw_data;
448
        ver = oldmnt->version;
449
        if (ver != SMB_MOUNT_OLDVERSION && cpu_to_be32(ver) != SMB_MOUNT_ASCII)
450
                goto out_wrong_data;
451
 
452
        sb->s_blocksize = 1024; /* Eh...  Is this correct? */
453
        sb->s_blocksize_bits = 10;
454
        sb->s_maxbytes = MAX_NON_LFS;
455
        sb->s_magic = SMB_SUPER_MAGIC;
456
        sb->s_op = &smb_sops;
457
 
458
        server->mnt = NULL;
459
        server->sock_file = NULL;
460
        init_MUTEX(&server->sem);
461
        init_waitqueue_head(&server->wait);
462
        server->conn_pid = 0;
463
        server->state = CONN_INVALID; /* no connection yet */
464
        server->generation = 0;
465
        server->packet_size = smb_round_length(SMB_INITIAL_PACKET_SIZE);
466
        server->packet = smb_vmalloc(server->packet_size);
467
        if (!server->packet)
468
                goto out_no_mem;
469
 
470
        /* Allocate the global temp buffer */
471
        server->temp_buf = smb_kmalloc(2*SMB_MAXPATHLEN+20, GFP_KERNEL);
472
        if (!server->temp_buf)
473
                goto out_no_temp;
474
 
475
        /* Setup NLS stuff */
476
        server->remote_nls = NULL;
477
        server->local_nls = NULL;
478
        server->name_buf = server->temp_buf + SMB_MAXPATHLEN + 20;
479
 
480
        /* Allocate the mount data structure */
481
        /* FIXME: merge this with the other malloc and get a whole page? */
482
        mem = smb_kmalloc(sizeof(struct smb_ops) +
483
                          sizeof(struct smb_mount_data_kernel), GFP_KERNEL);
484
        if (!mem)
485
                goto out_no_mount;
486
        server->mnt = mnt = mem;
487
        server->ops = mem + sizeof(struct smb_mount_data_kernel);
488
        smb_install_null_ops(server->ops);
489
 
490
        memset(mnt, 0, sizeof(struct smb_mount_data_kernel));
491
        strncpy(mnt->codepage.local_name, CONFIG_NLS_DEFAULT,
492
                SMB_NLS_MAXNAMELEN);
493
        strncpy(mnt->codepage.remote_name, SMB_NLS_REMOTE,
494
                SMB_NLS_MAXNAMELEN);
495
 
496
        mnt->ttl = SMB_TTL_DEFAULT;
497
        mnt->timeo = SMB_TIMEO_DEFAULT;
498
        if (ver == SMB_MOUNT_OLDVERSION) {
499
                mnt->version = oldmnt->version;
500
 
501
                /* FIXME: is this enough to convert uid/gid's ? */
502
                mnt->uid = oldmnt->uid;
503
                mnt->gid = oldmnt->gid;
504
 
505
                mnt->file_mode = (oldmnt->file_mode & S_IRWXUGO) | S_IFREG;
506
                mnt->dir_mode = (oldmnt->dir_mode & S_IRWXUGO) | S_IFDIR;
507
 
508
                mnt->flags = (oldmnt->file_mode >> 9);
509
        } else {
510
                if (parse_options(mnt, raw_data))
511
                        goto out_bad_option;
512
        }
513
        smb_setcodepage(server, &mnt->codepage);
514
        mnt->mounted_uid = current->uid;
515
 
516
        /*
517
         * Display the enabled options
518
         * Note: smb_proc_getattr uses these in 2.4 (but was changed in 2.2)
519
         */
520
        if (mnt->flags & SMB_MOUNT_OLDATTR)
521
                printk("SMBFS: Using core getattr (Win 95 speedup)\n");
522
        else if (mnt->flags & SMB_MOUNT_DIRATTR)
523
                printk("SMBFS: Using dir ff getattr\n");
524
 
525
        /*
526
         * Keep the super block locked while we get the root inode.
527
         */
528
        smb_init_root_dirent(server, &root);
529
        root_inode = smb_iget(sb, &root);
530
        if (!root_inode)
531
                goto out_no_root;
532
 
533
        sb->s_root = d_alloc_root(root_inode);
534
        if (!sb->s_root)
535
                goto out_no_root;
536
        smb_new_dentry(sb->s_root);
537
 
538
        return sb;
539
 
540
out_no_root:
541
        iput(root_inode);
542
out_bad_option:
543
        smb_kfree(server->mnt);
544
out_no_mount:
545
        smb_kfree(server->temp_buf);
546
out_no_temp:
547
        smb_vfree(server->packet);
548
out_no_mem:
549
        if (!server->mnt)
550
                printk(KERN_ERR "smb_read_super: allocation failure\n");
551
        goto out_fail;
552
out_wrong_data:
553
        printk(KERN_ERR "smbfs: mount_data version %d is not supported\n", ver);
554
        goto out_fail;
555
out_no_data:
556
        printk(KERN_ERR "smb_read_super: missing data argument\n");
557
out_fail:
558
        return NULL;
559
}
560
 
561
static int
562
smb_statfs(struct super_block *sb, struct statfs *buf)
563
{
564
        int result = smb_proc_dskattr(sb, buf);
565
 
566
        buf->f_type = SMB_SUPER_MAGIC;
567
        buf->f_namelen = SMB_MAXPATHLEN;
568
        return result;
569
}
570
 
571
int
572
smb_notify_change(struct dentry *dentry, struct iattr *attr)
573
{
574
        struct inode *inode = dentry->d_inode;
575
        struct smb_sb_info *server = server_from_dentry(dentry);
576
        unsigned int mask = (S_IFREG | S_IFDIR | S_IRWXUGO);
577
        int error, changed, refresh = 0;
578
        struct smb_fattr fattr;
579
 
580
        error = smb_revalidate_inode(dentry);
581
        if (error)
582
                goto out;
583
 
584
        if ((error = inode_change_ok(inode, attr)) < 0)
585
                goto out;
586
 
587
        error = -EPERM;
588
        if ((attr->ia_valid & ATTR_UID) && (attr->ia_uid != server->mnt->uid))
589
                goto out;
590
 
591
        if ((attr->ia_valid & ATTR_GID) && (attr->ia_uid != server->mnt->gid))
592
                goto out;
593
 
594
        if ((attr->ia_valid & ATTR_MODE) && (attr->ia_mode & ~mask))
595
                goto out;
596
 
597
        if ((attr->ia_valid & ATTR_SIZE) != 0) {
598
                VERBOSE("changing %s/%s, old size=%ld, new size=%ld\n",
599
                        DENTRY_PATH(dentry),
600
                        (long) inode->i_size, (long) attr->ia_size);
601
 
602
                filemap_fdatasync(inode->i_mapping);
603
                filemap_fdatawait(inode->i_mapping);
604
 
605
                error = smb_open(dentry, O_WRONLY);
606
                if (error)
607
                        goto out;
608
                error = server->ops->truncate(inode, attr->ia_size);
609
                if (error)
610
                        goto out;
611
                error = vmtruncate(inode, attr->ia_size);
612
                if (error)
613
                        goto out;
614
                refresh = 1;
615
        }
616
 
617
        if (server->opt.capabilities & SMB_CAP_UNIX) {
618
                /* For now we don't want to set the size with setattr_unix */
619
                attr->ia_valid &= ~ATTR_SIZE;
620
                /* FIXME: only call if we actually want to set something? */
621
                error = smb_proc_setattr_unix(dentry, attr, 0, 0);
622
                if (!error)
623
                        refresh = 1;
624
                goto out;
625
        }
626
 
627
        /*
628
         * Initialize the fattr and check for changed fields.
629
         * Note: CTIME under SMB is creation time rather than
630
         * change time, so we don't attempt to change it.
631
         */
632
        smb_get_inode_attr(inode, &fattr);
633
 
634
        changed = 0;
635
        if ((attr->ia_valid & ATTR_MTIME) != 0) {
636
                fattr.f_mtime = attr->ia_mtime;
637
                changed = 1;
638
        }
639
        if ((attr->ia_valid & ATTR_ATIME) != 0) {
640
                fattr.f_atime = attr->ia_atime;
641
                /* Earlier protocols don't have an access time */
642
                if (server->opt.protocol >= SMB_PROTOCOL_LANMAN2)
643
                        changed = 1;
644
        }
645
        if (changed) {
646
                error = smb_proc_settime(dentry, &fattr);
647
                if (error)
648
                        goto out;
649
                refresh = 1;
650
        }
651
 
652
        /*
653
         * Check for mode changes ... we're extremely limited in
654
         * what can be set for SMB servers: just the read-only bit.
655
         */
656
        if ((attr->ia_valid & ATTR_MODE) != 0) {
657
                VERBOSE("%s/%s mode change, old=%x, new=%x\n",
658
                        DENTRY_PATH(dentry), fattr.f_mode, attr->ia_mode);
659
                changed = 0;
660
                if (attr->ia_mode & S_IWUSR) {
661
                        if (fattr.attr & aRONLY) {
662
                                fattr.attr &= ~aRONLY;
663
                                changed = 1;
664
                        }
665
                } else {
666
                        if (!(fattr.attr & aRONLY)) {
667
                                fattr.attr |= aRONLY;
668
                                changed = 1;
669
                        }
670
                }
671
                if (changed) {
672
                        error = smb_proc_setattr(dentry, &fattr);
673
                        if (error)
674
                                goto out;
675
                        refresh = 1;
676
                }
677
        }
678
        error = 0;
679
 
680
out:
681
        if (refresh)
682
                smb_refresh_inode(dentry);
683
        return error;
684
}
685
 
686
#ifdef DEBUG_SMB_MALLOC
687
int smb_malloced;
688
int smb_current_kmalloced;
689
int smb_current_vmalloced;
690
#endif
691
 
692
static DECLARE_FSTYPE( smb_fs_type, "smbfs", smb_read_super, 0);
693
 
694
static int __init init_smb_fs(void)
695
{
696
        DEBUG1("registering ...\n");
697
 
698
#ifdef DEBUG_SMB_MALLOC
699
        smb_malloced = 0;
700
        smb_current_kmalloced = 0;
701
        smb_current_vmalloced = 0;
702
#endif
703
 
704
        return register_filesystem(&smb_fs_type);
705
}
706
 
707
static void __exit exit_smb_fs(void)
708
{
709
        DEBUG1("unregistering ...\n");
710
        unregister_filesystem(&smb_fs_type);
711
#ifdef DEBUG_SMB_MALLOC
712
        printk(KERN_DEBUG "smb_malloced: %d\n", smb_malloced);
713
        printk(KERN_DEBUG "smb_current_kmalloced: %d\n",smb_current_kmalloced);
714
        printk(KERN_DEBUG "smb_current_vmalloced: %d\n",smb_current_vmalloced);
715
#endif
716
}
717
 
718
EXPORT_NO_SYMBOLS;
719
 
720
module_init(init_smb_fs)
721
module_exit(exit_smb_fs)
722
MODULE_LICENSE("GPL");

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.