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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [linux_sd_driver/] [include/] [linux/] [smb_fs.h] - Blame information for rev 62

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 62 marcus.erl
/*
2
 *  smb_fs.h
3
 *
4
 *  Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5
 *  Copyright (C) 1997 by Volker Lendecke
6
 *
7
 */
8
 
9
#ifndef _LINUX_SMB_FS_H
10
#define _LINUX_SMB_FS_H
11
 
12
#include <linux/smb.h>
13
 
14
/*
15
 * ioctl commands
16
 */
17
#define SMB_IOC_GETMOUNTUID             _IOR('u', 1, __kernel_old_uid_t)
18
#define SMB_IOC_NEWCONN                 _IOW('u', 2, struct smb_conn_opt)
19
 
20
/* __kernel_uid_t can never change, so we have to use __kernel_uid32_t */
21
#define SMB_IOC_GETMOUNTUID32           _IOR('u', 3, __kernel_uid32_t)
22
 
23
 
24
#ifdef __KERNEL__
25
#include <linux/smb_fs_i.h>
26
#include <linux/smb_fs_sb.h>
27
 
28
#include <linux/fs.h>
29
#include <linux/pagemap.h>
30
#include <linux/vmalloc.h>
31
#include <linux/smb_mount.h>
32
#include <linux/jiffies.h>
33
#include <asm/unaligned.h>
34
 
35
static inline struct smb_sb_info *SMB_SB(struct super_block *sb)
36
{
37
        return sb->s_fs_info;
38
}
39
 
40
static inline struct smb_inode_info *SMB_I(struct inode *inode)
41
{
42
        return container_of(inode, struct smb_inode_info, vfs_inode);
43
}
44
 
45
/* macro names are short for word, double-word, long value (?) */
46
#define WVAL(buf,pos) \
47
        (le16_to_cpu(get_unaligned((__le16 *)((u8 *)(buf) + (pos)))))
48
#define DVAL(buf,pos) \
49
        (le32_to_cpu(get_unaligned((__le32 *)((u8 *)(buf) + (pos)))))
50
#define LVAL(buf,pos) \
51
        (le64_to_cpu(get_unaligned((__le64 *)((u8 *)(buf) + (pos)))))
52
#define WSET(buf,pos,val) \
53
        put_unaligned(cpu_to_le16((u16)(val)), (__le16 *)((u8 *)(buf) + (pos)))
54
#define DSET(buf,pos,val) \
55
        put_unaligned(cpu_to_le32((u32)(val)), (__le32 *)((u8 *)(buf) + (pos)))
56
#define LSET(buf,pos,val) \
57
        put_unaligned(cpu_to_le64((u64)(val)), (__le64 *)((u8 *)(buf) + (pos)))
58
 
59
/* where to find the base of the SMB packet proper */
60
#define smb_base(buf) ((u8 *)(((u8 *)(buf))+4))
61
 
62
/*
63
 * Flags for the in-memory inode
64
 */
65
#define SMB_F_LOCALWRITE        0x02    /* file modified locally */
66
 
67
 
68
/* NT1 protocol capability bits */
69
#define SMB_CAP_RAW_MODE         0x00000001
70
#define SMB_CAP_MPX_MODE         0x00000002
71
#define SMB_CAP_UNICODE          0x00000004
72
#define SMB_CAP_LARGE_FILES      0x00000008
73
#define SMB_CAP_NT_SMBS          0x00000010
74
#define SMB_CAP_RPC_REMOTE_APIS  0x00000020
75
#define SMB_CAP_STATUS32         0x00000040
76
#define SMB_CAP_LEVEL_II_OPLOCKS 0x00000080
77
#define SMB_CAP_LOCK_AND_READ    0x00000100
78
#define SMB_CAP_NT_FIND          0x00000200
79
#define SMB_CAP_DFS              0x00001000
80
#define SMB_CAP_LARGE_READX      0x00004000
81
#define SMB_CAP_LARGE_WRITEX     0x00008000
82
#define SMB_CAP_UNIX             0x00800000     /* unofficial ... */
83
 
84
 
85
/*
86
 * This is the time we allow an inode, dentry or dir cache to live. It is bad
87
 * for performance to have shorter ttl on an inode than on the cache. It can
88
 * cause refresh on each inode for a dir listing ... one-by-one
89
 */
90
#define SMB_MAX_AGE(server) (((server)->mnt->ttl * HZ) / 1000)
91
 
92
static inline void
93
smb_age_dentry(struct smb_sb_info *server, struct dentry *dentry)
94
{
95
        dentry->d_time = jiffies - SMB_MAX_AGE(server);
96
}
97
 
98
struct smb_cache_head {
99
        time_t          mtime;  /* unused */
100
        unsigned long   time;   /* cache age */
101
        unsigned long   end;    /* last valid fpos in cache */
102
        int             eof;
103
};
104
 
105
#define SMB_DIRCACHE_SIZE       ((int)(PAGE_CACHE_SIZE/sizeof(struct dentry *)))
106
union smb_dir_cache {
107
        struct smb_cache_head   head;
108
        struct dentry           *dentry[SMB_DIRCACHE_SIZE];
109
};
110
 
111
#define SMB_FIRSTCACHE_SIZE     ((int)((SMB_DIRCACHE_SIZE * \
112
        sizeof(struct dentry *) - sizeof(struct smb_cache_head)) / \
113
        sizeof(struct dentry *)))
114
 
115
#define SMB_DIRCACHE_START      (SMB_DIRCACHE_SIZE - SMB_FIRSTCACHE_SIZE)
116
 
117
struct smb_cache_control {
118
        struct  smb_cache_head          head;
119
        struct  page                    *page;
120
        union   smb_dir_cache           *cache;
121
        unsigned long                   fpos, ofs;
122
        int                             filled, valid, idx;
123
};
124
 
125
#define SMB_OPS_NUM_STATIC      5
126
struct smb_ops {
127
        int (*read)(struct inode *inode, loff_t offset, int count,
128
                    char *data);
129
        int (*write)(struct inode *inode, loff_t offset, int count, const
130
                     char *data);
131
        int (*readdir)(struct file *filp, void *dirent, filldir_t filldir,
132
                       struct smb_cache_control *ctl);
133
 
134
        int (*getattr)(struct smb_sb_info *server, struct dentry *dir,
135
                       struct smb_fattr *fattr);
136
        /* int (*setattr)(...); */      /* setattr is really icky! */
137
 
138
        int (*truncate)(struct inode *inode, loff_t length);
139
 
140
 
141
        /* --- --- --- end of "static" entries --- --- --- */
142
 
143
        int (*convert)(unsigned char *output, int olen,
144
                       const unsigned char *input, int ilen,
145
                       struct nls_table *nls_from,
146
                       struct nls_table *nls_to);
147
};
148
 
149
static inline int
150
smb_is_open(struct inode *i)
151
{
152
        return (SMB_I(i)->open == server_from_inode(i)->generation);
153
}
154
 
155
extern void smb_install_null_ops(struct smb_ops *);
156
#endif /* __KERNEL__ */
157
 
158
#endif /* _LINUX_SMB_FS_H */

powered by: WebSVN 2.1.0

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