The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/ncpfs/ncplib_kernel.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  *  ncplib_kernel.h
    3  *
    4  *  Copyright (C) 1995, 1996 by Volker Lendecke
    5  *  Modified for big endian by J.F. Chadima and David S. Miller
    6  *  Modified 1997 Peter Waltenberg, Bill Hawes, David Woodhouse for 2.1 dcache
    7  *  Modified 1998, 1999 Wolfram Pienkoss for NLS
    8  *  Modified 1999 Wolfram Pienkoss for directory caching
    9  *
   10  */
   11 
   12 #ifndef _NCPLIB_H
   13 #define _NCPLIB_H
   14 
   15 #include <linux/config.h>
   16 
   17 #include <linux/fs.h>
   18 #include <linux/types.h>
   19 #include <linux/errno.h>
   20 #include <linux/slab.h>
   21 #include <linux/stat.h>
   22 #include <linux/fcntl.h>
   23 #include <linux/pagemap.h>
   24 
   25 #include <asm/uaccess.h>
   26 #include <asm/byteorder.h>
   27 #include <asm/unaligned.h>
   28 #include <asm/string.h>
   29 
   30 #ifdef CONFIG_NCPFS_NLS
   31 #include <linux/nls.h>
   32 #else
   33 #include <linux/ctype.h>
   34 #endif /* CONFIG_NCPFS_NLS */
   35 
   36 #include <linux/ncp_fs.h>
   37 
   38 #define NCP_MIN_SYMLINK_SIZE    8
   39 #define NCP_MAX_SYMLINK_SIZE    512
   40 
   41 #define NCP_BLOCK_SHIFT         9
   42 #define NCP_BLOCK_SIZE          (1 << (NCP_BLOCK_SHIFT))
   43 
   44 int ncp_negotiate_buffersize(struct ncp_server *, int, int *);
   45 int ncp_negotiate_size_and_options(struct ncp_server *server, int size,
   46                           int options, int *ret_size, int *ret_options);
   47 int ncp_get_volume_info_with_number(struct ncp_server *, int,
   48                                 struct ncp_volume_info *);
   49 int ncp_close_file(struct ncp_server *, const char *);
   50 static inline int ncp_read_bounce_size(__u32 size) {
   51         return sizeof(struct ncp_reply_header) + 2 + 2 + size + 8;
   52 };
   53 int ncp_read_bounce(struct ncp_server *, const char *, __u32, __u16, 
   54                 char *, int *, void* bounce, __u32 bouncelen);
   55 int ncp_read_kernel(struct ncp_server *, const char *, __u32, __u16, 
   56                 char *, int *);
   57 int ncp_write_kernel(struct ncp_server *, const char *, __u32, __u16,
   58                 const char *, int *);
   59 
   60 static inline void ncp_inode_close(struct inode *inode) {
   61         atomic_dec(&NCP_FINFO(inode)->opened);
   62 }
   63 
   64 int ncp_obtain_info(struct ncp_server *server, struct inode *, char *,
   65                 struct nw_info_struct *target);
   66 int ncp_lookup_volume(struct ncp_server *, char *, struct nw_info_struct *);
   67 int ncp_modify_file_or_subdir_dos_info(struct ncp_server *, struct inode *,
   68          __u32, const struct nw_modify_dos_info *info);
   69 int ncp_modify_file_or_subdir_dos_info_path(struct ncp_server *, struct inode *,
   70          const char* path, __u32, const struct nw_modify_dos_info *info);
   71 
   72 int ncp_del_file_or_subdir2(struct ncp_server *, struct dentry*);
   73 int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, char *);
   74 int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, char *,
   75                                 int, __u32, int, struct ncp_entry_info *);
   76 
   77 int ncp_initialize_search(struct ncp_server *, struct inode *,
   78                       struct nw_search_sequence *target);
   79 int ncp_search_for_file_or_subdir(struct ncp_server *server,
   80                               struct nw_search_sequence *seq,
   81                               struct nw_info_struct *target);
   82 
   83 int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
   84                               struct inode *, char *, struct inode *, char *);
   85 
   86 
   87 int
   88 ncp_LogPhysicalRecord(struct ncp_server *server,
   89                       const char *file_id, __u8 locktype,
   90                       __u32 offset, __u32 length, __u16 timeout);
   91 
   92 #ifdef CONFIG_NCPFS_IOCTL_LOCKING
   93 int
   94 ncp_ClearPhysicalRecord(struct ncp_server *server,
   95                         const char *file_id,
   96                         __u32 offset, __u32 length);
   97 #endif  /* CONFIG_NCPFS_IOCTL_LOCKING */
   98 
   99 int
  100 ncp_mount_subdir(struct ncp_server *, struct nw_info_struct *,
  101                         __u8, __u8, __u32);
  102 
  103 #ifdef CONFIG_NCPFS_NLS
  104 
  105 unsigned char ncp__tolower(struct nls_table *, unsigned char);
  106 unsigned char ncp__toupper(struct nls_table *, unsigned char);
  107 int ncp__io2vol(struct ncp_server *, unsigned char *, unsigned int *,
  108                                 const unsigned char *, unsigned int, int);
  109 int ncp__vol2io(struct ncp_server *, unsigned char *, unsigned int *,
  110                                 const unsigned char *, unsigned int, int);
  111 
  112 #define NCP_ESC                 ':'
  113 #define NCP_IO_TABLE(dentry)    (NCP_SERVER((dentry)->d_inode)->nls_io)
  114 #define ncp_tolower(t, c)       ncp__tolower(t, c)
  115 #define ncp_toupper(t, c)       ncp__toupper(t, c)
  116 #define ncp_io2vol(S,m,i,n,k,U) ncp__io2vol(S,m,i,n,k,U)
  117 #define ncp_vol2io(S,m,i,n,k,U) ncp__vol2io(S,m,i,n,k,U)
  118 
  119 #else
  120 
  121 int ncp__io2vol(unsigned char *, unsigned int *,
  122                                 const unsigned char *, unsigned int, int);
  123 int ncp__vol2io(unsigned char *, unsigned int *,
  124                                 const unsigned char *, unsigned int, int);
  125 
  126 #define NCP_IO_TABLE(dentry)    NULL
  127 #define ncp_tolower(t, c)       tolower(c)
  128 #define ncp_toupper(t, c)       toupper(c)
  129 #define ncp_io2vol(S,m,i,n,k,U) ncp__io2vol(m,i,n,k,U)
  130 #define ncp_vol2io(S,m,i,n,k,U) ncp__vol2io(m,i,n,k,U)
  131 
  132 #endif /* CONFIG_NCPFS_NLS */
  133 
  134 inline int
  135 ncp_strnicmp(struct nls_table *,
  136                 const unsigned char *, const unsigned char *, int);
  137 
  138 #define NCP_GET_AGE(dentry)     (jiffies - (dentry)->d_time)
  139 #define NCP_MAX_AGE(server)     ((server)->dentry_ttl)
  140 #define NCP_TEST_AGE(server,dentry)     (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server))
  141 
  142 static inline void
  143 ncp_age_dentry(struct ncp_server* server, struct dentry* dentry)
  144 {
  145         dentry->d_time = jiffies - server->dentry_ttl;
  146 }
  147 
  148 static inline void
  149 ncp_new_dentry(struct dentry* dentry)
  150 {
  151         dentry->d_time = jiffies;
  152 }
  153 
  154 static inline void
  155 ncp_renew_dentries(struct dentry *parent)
  156 {
  157         struct ncp_server *server = NCP_SERVER(parent->d_inode);
  158         struct list_head *next;
  159         struct dentry *dentry;
  160 
  161         spin_lock(&dcache_lock);
  162         next = parent->d_subdirs.next;
  163         while (next != &parent->d_subdirs) {
  164                 dentry = list_entry(next, struct dentry, d_child);
  165 
  166                 if (dentry->d_fsdata == NULL)
  167                         ncp_age_dentry(server, dentry);
  168                 else
  169                         ncp_new_dentry(dentry);
  170 
  171                 next = next->next;
  172         }
  173         spin_unlock(&dcache_lock);
  174 }
  175 
  176 static inline void
  177 ncp_invalidate_dircache_entries(struct dentry *parent)
  178 {
  179         struct ncp_server *server = NCP_SERVER(parent->d_inode);
  180         struct list_head *next;
  181         struct dentry *dentry;
  182 
  183         spin_lock(&dcache_lock);
  184         next = parent->d_subdirs.next;
  185         while (next != &parent->d_subdirs) {
  186                 dentry = list_entry(next, struct dentry, d_child);
  187                 dentry->d_fsdata = NULL;
  188                 ncp_age_dentry(server, dentry);
  189                 next = next->next;
  190         }
  191         spin_unlock(&dcache_lock);
  192 }
  193 
  194 struct ncp_cache_head {
  195         time_t          mtime;
  196         unsigned long   time;   /* cache age */
  197         unsigned long   end;    /* last valid fpos in cache */
  198         int             eof;
  199 };
  200 
  201 #define NCP_DIRCACHE_SIZE       ((int)(PAGE_CACHE_SIZE/sizeof(struct dentry *)))
  202 union ncp_dir_cache {
  203         struct ncp_cache_head   head;
  204         struct dentry           *dentry[NCP_DIRCACHE_SIZE];
  205 };
  206 
  207 #define NCP_FIRSTCACHE_SIZE     ((int)((NCP_DIRCACHE_SIZE * \
  208         sizeof(struct dentry *) - sizeof(struct ncp_cache_head)) / \
  209         sizeof(struct dentry *)))
  210 
  211 #define NCP_DIRCACHE_START      (NCP_DIRCACHE_SIZE - NCP_FIRSTCACHE_SIZE)
  212 
  213 struct ncp_cache_control {
  214         struct  ncp_cache_head          head;
  215         struct  page                    *page;
  216         union   ncp_dir_cache           *cache;
  217         unsigned long                   fpos, ofs;
  218         int                             filled, valid, idx;
  219 };
  220 
  221 #endif /* _NCPLIB_H */

Cache object: e148df60cc15fd8a39edc045ccc128da


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.