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/ntfs/ntfs.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ntfs.h,v 1.8 2004/12/27 18:14:36 jdolecek Exp $        */
    2 
    3 /*-
    4  * Copyright (c) 1998, 1999 Semen Ustimenko
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  *
   28  *      Id: ntfs.h,v 1.5 1999/05/12 09:42:51 semenu Exp
   29  */
   30 
   31 /*#define NTFS_DEBUG 1*/
   32 #if defined(__NetBSD__) && defined(_KERNEL_OPT)
   33 #include "opt_ntfs.h"
   34 #endif
   35 
   36 typedef u_int64_t cn_t;
   37 typedef u_int16_t wchar;
   38 
   39 #pragma pack(1)
   40 #define BBSIZE                  1024
   41 #define BBOFF                   ((off_t)(0))
   42 #define BBLOCK                  ((daddr_t)(0))
   43 #define NTFS_MFTINO             0
   44 #define NTFS_VOLUMEINO          3
   45 #define NTFS_ATTRDEFINO         4
   46 #define NTFS_ROOTINO            5
   47 #define NTFS_BITMAPINO          6
   48 #define NTFS_BOOTINO            7
   49 #define NTFS_BADCLUSINO         8
   50 #define NTFS_UPCASEINO          10
   51 #define NTFS_MAXFILENAME        255
   52 
   53 struct fixuphdr {
   54         u_int32_t       fh_magic;
   55         u_int16_t       fh_foff;
   56         u_int16_t       fh_fnum;
   57 };
   58 
   59 #define NTFS_AF_INRUN   0x00000001
   60 struct attrhdr {
   61         u_int32_t       a_type;
   62         u_int32_t       reclen;
   63         u_int8_t        a_flag;
   64         u_int8_t        a_namelen;
   65         u_int8_t        a_nameoff;
   66         u_int8_t        reserved1;
   67         u_int8_t        a_compression;
   68         u_int8_t        reserved2;
   69         u_int16_t       a_index;
   70 };
   71 #define NTFS_A_STD      0x10
   72 #define NTFS_A_ATTRLIST 0x20
   73 #define NTFS_A_NAME     0x30
   74 #define NTFS_A_VOLUMENAME       0x60
   75 #define NTFS_A_DATA     0x80
   76 #define NTFS_A_INDXROOT 0x90
   77 #define NTFS_A_INDX     0xA0
   78 #define NTFS_A_INDXBITMAP 0xB0
   79 
   80 #define NTFS_MAXATTRNAME        255
   81 struct attr {
   82         struct attrhdr  a_hdr;
   83         union {
   84                 struct {
   85                         u_int16_t       a_datalen;
   86                         u_int16_t       reserved1;
   87                         u_int16_t       a_dataoff;
   88                         u_int16_t       a_indexed;
   89                 }               a_S_r;
   90                 struct {
   91                         cn_t            a_vcnstart;
   92                         cn_t            a_vcnend;
   93                         u_int16_t       a_dataoff;
   94                         u_int16_t       a_compressalg;
   95                         u_int32_t       reserved1;
   96                         u_int64_t       a_allocated;
   97                         u_int64_t       a_datalen;
   98                         u_int64_t       a_initialized;
   99                 }               a_S_nr;
  100         }               a_S;
  101 };
  102 #define a_r     a_S.a_S_r
  103 #define a_nr    a_S.a_S_nr
  104 
  105 typedef struct {
  106         u_int64_t       t_create;
  107         u_int64_t       t_write;
  108         u_int64_t       t_mftwrite;
  109         u_int64_t       t_access;
  110 }               ntfs_times_t;
  111 
  112 #define NTFS_FFLAG_RDONLY       0x01LL
  113 #define NTFS_FFLAG_HIDDEN       0x02LL
  114 #define NTFS_FFLAG_SYSTEM       0x04LL
  115 #define NTFS_FFLAG_ARCHIVE      0x20LL
  116 #define NTFS_FFLAG_COMPRESSED   0x0800LL
  117 #define NTFS_FFLAG_DIR          0x10000000LL
  118 
  119 struct attr_name {
  120         u_int32_t       n_pnumber;      /* Parent ntnode */
  121         u_int32_t       reserved;
  122         ntfs_times_t    n_times;
  123         u_int64_t       n_size;
  124         u_int64_t       n_attrsz;
  125         u_int64_t       n_flag;
  126         u_int8_t        n_namelen;
  127         u_int8_t        n_nametype;
  128         u_int16_t       n_name[1];
  129 };
  130 
  131 #define NTFS_IRFLAG_INDXALLOC   0x00000001
  132 struct attr_indexroot {
  133         u_int32_t       ir_unkn1;       /* always 0x30 */
  134         u_int32_t       ir_unkn2;       /* always 0x1 */
  135         u_int32_t       ir_size;/* ??? */
  136         u_int32_t       ir_unkn3;       /* number of cluster */
  137         u_int32_t       ir_unkn4;       /* always 0x10 */
  138         u_int32_t       ir_datalen;     /* sizeof simething */
  139         u_int32_t       ir_allocated;   /* same as above */
  140         u_int16_t       ir_flag;/* ?? always 1 */
  141         u_int16_t       ir_unkn7;
  142 };
  143 
  144 struct attr_attrlist {
  145         u_int32_t       al_type;        /* Attribute type */
  146         u_int16_t       reclen;         /* length of this entry */
  147         u_int8_t        al_namelen;     /* Attribute name len */
  148         u_int8_t        al_nameoff;     /* Name offset from entry start */
  149         u_int64_t       al_vcnstart;    /* VCN number */
  150         u_int32_t       al_inumber;     /* Parent ntnode */
  151         u_int32_t       reserved;
  152         u_int16_t       al_index;       /* Attribute index in MFT record */
  153         u_int16_t       al_name[1];     /* Name */
  154 };
  155 
  156 #define NTFS_INDXMAGIC  (u_int32_t)(0x58444E49)
  157 struct attr_indexalloc {
  158         struct fixuphdr ia_fixup;
  159         u_int64_t       unknown1;
  160         cn_t            ia_bufcn;
  161         u_int16_t       ia_hdrsize;
  162         u_int16_t       unknown2;
  163         u_int32_t       ia_inuse;
  164         u_int32_t       ia_allocated;
  165 };
  166 
  167 #define NTFS_IEFLAG_SUBNODE     0x00000001
  168 #define NTFS_IEFLAG_LAST        0x00000002
  169 
  170 struct attr_indexentry {
  171         u_int32_t       ie_number;
  172         u_int32_t       unknown1;
  173         u_int16_t       reclen;
  174         u_int16_t       ie_size;
  175         u_int32_t       ie_flag;/* 1 - has subnodes, 2 - last */
  176         u_int32_t       ie_fpnumber;
  177         u_int32_t       unknown2;
  178         ntfs_times_t    ie_ftimes;
  179         u_int64_t       ie_fallocated;
  180         u_int64_t       ie_fsize;
  181         u_int64_t       ie_fflag;
  182         u_int8_t        ie_fnamelen;
  183         u_int8_t        ie_fnametype;
  184         wchar           ie_fname[NTFS_MAXFILENAME];
  185         /* cn_t         ie_bufcn;        buffer with subnodes */
  186 };
  187 
  188 #define NTFS_FILEMAGIC  (u_int32_t)(0x454C4946)
  189 #define NTFS_FRFLAG_DIR 0x0002
  190 struct filerec {
  191         struct fixuphdr fr_fixup;
  192         u_int8_t        reserved[8];
  193         u_int16_t       fr_seqnum;      /* Sequence number */
  194         u_int16_t       fr_nlink;
  195         u_int16_t       fr_attroff;     /* offset to attributes */
  196         u_int16_t       fr_flags;       /* 1-nonresident attr, 2-directory */
  197         u_int32_t       fr_size;/* hdr + attributes */
  198         u_int32_t       fr_allocated;   /* allocated length of record */
  199         u_int64_t       fr_mainrec;     /* main record */
  200         u_int16_t       fr_attrnum;     /* maximum attr number + 1 ??? */
  201 };
  202 
  203 #define NTFS_ATTRNAME_MAXLEN    0x40
  204 #define NTFS_ADFLAG_NONRES      0x0080  /* Attrib can be non resident */
  205 #define NTFS_ADFLAG_INDEX       0x0002  /* Attrib can be indexed */
  206 struct attrdef {
  207         wchar           ad_name[NTFS_ATTRNAME_MAXLEN];
  208         u_int32_t       ad_type;
  209         u_int32_t       reserved1[2];
  210         u_int32_t       ad_flag;
  211         u_int64_t       ad_minlen;
  212         u_int64_t       ad_maxlen;      /* -1 for nonlimited */
  213 };
  214 
  215 struct ntvattrdef {
  216         char            ad_name[0x40];
  217         int             ad_namelen;
  218         u_int32_t       ad_type;
  219 };
  220 
  221 #define NTFS_BBID       "NTFS    "
  222 #define NTFS_BBIDLEN    8
  223 struct bootfile {
  224         u_int8_t        reserved1[3];   /* asm jmp near ... */
  225         u_int8_t        bf_sysid[8];    /* 'NTFS    ' */
  226         u_int16_t       bf_bps;         /* bytes per sector */
  227         u_int8_t        bf_spc;         /* sectors per cluster */
  228         u_int8_t        reserved2[7];   /* unused (zeroed) */
  229         u_int8_t        bf_media;       /* media desc. (0xF8) */
  230         u_int8_t        reserved3[2];
  231         u_int16_t       bf_spt;         /* sectors per track */
  232         u_int16_t       bf_heads;       /* number of heads */
  233         u_int8_t        reserver4[12];
  234         u_int64_t       bf_spv;         /* sectors per volume */
  235         cn_t            bf_mftcn;       /* $MFT cluster number */
  236         cn_t            bf_mftmirrcn;   /* $MFTMirr cn */
  237         u_int8_t        bf_mftrecsz;    /* MFT record size (clust) */
  238                                         /* 0xF6 inducates 1/4 */
  239         u_int32_t       bf_ibsz;        /* index buffer size */
  240         u_int32_t       bf_volsn;       /* volume ser. num. */
  241 };
  242 
  243 #pragma pack()
  244 
  245 typedef wchar (ntfs_wget_func_t) __P((const char **, size_t *));
  246 typedef int (ntfs_wput_func_t) __P((char *, size_t, wchar));
  247 typedef int (ntfs_wcmp_func_t) __P((wchar, wchar));
  248 
  249 #define NTFS_SYSNODESNUM        0x0B
  250 struct ntfsmount {
  251         struct mount   *ntm_mountp;     /* filesystem vfs structure */
  252         struct bootfile ntm_bootfile;
  253         dev_t           ntm_dev;        /* device mounted */
  254         struct vnode   *ntm_devvp;      /* block device mounted vnode */
  255         struct vnode   *ntm_sysvn[NTFS_SYSNODESNUM];
  256         u_int32_t       ntm_bpmftrec;
  257         uid_t           ntm_uid;
  258         gid_t           ntm_gid;
  259         mode_t          ntm_mode;
  260         u_long          ntm_flag;
  261         cn_t            ntm_cfree;
  262         struct ntvattrdef *ntm_ad;
  263         int             ntm_adnum;
  264         struct netexport ntm_export;    /* export information */
  265         ntfs_wget_func_t *ntm_wget;     /* decode string to Unicode string */
  266         ntfs_wput_func_t *ntm_wput;     /* encode Unicode string to string */
  267         ntfs_wcmp_func_t *ntm_wcmp;     /* compare to wide characters */
  268 };
  269 
  270 #define ntm_mftcn       ntm_bootfile.bf_mftcn
  271 #define ntm_mftmirrcn   ntm_bootfile.bf_mftmirrcn
  272 #define ntm_mftrecsz    ntm_bootfile.bf_mftrecsz
  273 #define ntm_spc         ntm_bootfile.bf_spc
  274 #define ntm_bps         ntm_bootfile.bf_bps
  275 
  276 #define NTFS_NEXTREC(s, type) ((type)(((caddr_t) s) + (s)->reclen))
  277 
  278 /* Convert mount ptr to ntfsmount ptr. */
  279 #define VFSTONTFS(mp)   ((struct ntfsmount *)((mp)->mnt_data))
  280 #define VTONT(v)        FTONT(VTOF(v))
  281 #define VTOF(v)         ((struct fnode *)((v)->v_data))
  282 #define FTOV(f)         ((f)->f_vp)
  283 #define FTONT(f)        ((f)->f_ip)
  284 #define ntfs_cntobn(cn) (daddr_t)((cn) * (ntmp->ntm_spc))
  285 #define ntfs_cntob(cn)  (off_t)((cn) * (ntmp)->ntm_spc * (ntmp)->ntm_bps)
  286 #define ntfs_btocn(off) (cn_t)((off) / ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
  287 #define ntfs_btocl(off) (cn_t)((off + ntfs_cntob(1) - 1) / ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
  288 #define ntfs_btocnoff(off)      (off_t)((off) % ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
  289 #define ntfs_bntob(bn)  (daddr_t)((bn) * (ntmp)->ntm_bps)
  290 
  291 #define ntfs_bpbl       (daddr_t)((ntmp)->ntm_bps)
  292 
  293 #if __FreeBSD_version >= 300000 || defined(__NetBSD__)
  294 MALLOC_DECLARE(M_NTFSMNT);
  295 MALLOC_DECLARE(M_NTFSNTNODE);
  296 MALLOC_DECLARE(M_NTFSFNODE);
  297 MALLOC_DECLARE(M_NTFSDIR);
  298 MALLOC_DECLARE(M_NTFSNTHASH);
  299 MALLOC_DECLARE(M_NTFSNTVATTR);
  300 MALLOC_DECLARE(M_NTFSRDATA);
  301 MALLOC_DECLARE(M_NTFSDECOMP);
  302 MALLOC_DECLARE(M_NTFSRUN);
  303 #endif
  304 
  305 #ifdef __NetBSD__
  306 typedef int (vop_t) __P((void *));
  307 #define HASHINIT(a, b, c, d)    hashinit((a), HASH_LIST, (b), (c), (d))
  308 #define bqrelse(bp)             brelse(bp)
  309 #if 0
  310 #define VOP__UNLOCK(a, b, c)    VOP_UNLOCK((a), (b))
  311 #define VGET(a, b, c)           vget((a), (b))
  312 #define VN_LOCK(a, b, c)        vn_lock((a), (b))
  313 #endif
  314 #else /* !NetBSD */
  315 #define HASHINIT(a, b, c, d)    hashinit((a), (b), (d))
  316 #define VOP__UNLOCK(a, b, c)    VOP_UNLOCK((a), (b), (c))
  317 #define VGET(a, b, c)           vget((a), (b), (c))
  318 #define VN_LOCK(a, b, c)        vn_lock((a), (b), (c))
  319 
  320 /* PDIRUNLOCK is used by NetBSD to mark if vfs_lookup() unlocked parent dir;
  321  * on FreeBSD, it's not defined and nothing similar exists */
  322 #define PDIRUNLOCK              0
  323 #endif /* NetBSD */
  324 
  325 #if defined(NTFS_DEBUG)
  326 extern int ntfs_debug;
  327 #define DPRINTF(X, Y) do { if(ntfs_debug >= (X)) printf Y; } while(0)
  328 #define dprintf(a) DPRINTF(1, a)
  329 #define ddprintf(a) DPRINTF(2, a)
  330 #else /* NTFS_DEBUG */
  331 #define DPRINTF(X, Y)
  332 #define dprintf(a)
  333 #define ddprintf(a)
  334 #endif
  335 
  336 extern vop_t  **ntfs_vnodeop_p;

Cache object: 5ba1fc6e59d0acd89f935a40fcf9517a


[ 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.