Print this page
5857 lofiadm should ask passphrase once if the crypto is already set up
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/lofi.h
          +++ new/usr/src/uts/common/sys/lofi.h
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   *
  24   24   * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
       25 + * Copyright (c) 2016 Andrey Sokolov
  25   26   */
  26   27  
  27   28  #ifndef _SYS_LOFI_H
  28   29  #define _SYS_LOFI_H
  29   30  
  30   31  #include <sys/types.h>
  31   32  #include <sys/time.h>
  32   33  #include <sys/taskq.h>
  33   34  #include <sys/vtoc.h>
  34   35  #include <sys/dkio.h>
↓ open down ↓ 121 lines elided ↑ open up ↑
 156  157  #define LOFI_GET_MAXMINOR       (LOFI_IOC_BASE | 0x07)
 157  158  #define LOFI_CHECK_COMPRESSED   (LOFI_IOC_BASE | 0x08)
 158  159  
 159  160  /*
 160  161   * file types that might be usable with lofi, maybe. Only regular
 161  162   * files are documented though.
 162  163   */
 163  164  #define S_ISLOFIABLE(mode) \
 164  165          (S_ISREG(mode) || S_ISBLK(mode) || S_ISCHR(mode))
 165  166  
      167 +/*
      168 + * The basis for CRYOFF is derived from usr/src/uts/common/sys/fs/ufs_fs.h.
      169 + * Crypto metadata, if it exists, is located at the end of the boot block
      170 + * (BBOFF + BBSIZE, which is SBOFF).  The super block and everything after
      171 + * is offset by the size of the crypto metadata which is handled by
      172 + * lsp->ls_crypto_offset.
      173 + */
      174 +#define CRYOFF  ((off_t)8192)
      175 +
      176 +#define LOFI_CRYPTO_MAGIC       { 'C', 'F', 'L', 'O', 'F', 'I' }
      177 +
 166  178  #if defined(_KERNEL)
 167  179  
 168  180  
 169  181  /*
 170  182   * Cache decompressed data segments for the compressed lofi images.
 171  183   *
 172  184   * To avoid that we have to decompress data of a compressed
 173  185   * segment multiple times when accessing parts of the segment's
 174  186   * data we cache the uncompressed data, using a simple linked list.
 175  187   */
↓ open down ↓ 12 lines elided ↑ open up ↑
 188  200  struct compbuf {
 189  201          void            *buf;
 190  202          uint32_t        bufsize;
 191  203          int             inuse;
 192  204  };
 193  205  
 194  206  /*
 195  207   * Need exactly 6 bytes to identify encrypted lofi image
 196  208   */
 197  209  extern const char lofi_crypto_magic[6];
 198      -#define LOFI_CRYPTO_MAGIC       { 'C', 'F', 'L', 'O', 'F', 'I' }
 199  210  #define LOFI_CRYPTO_VERSION     ((uint16_t)0)
 200  211  #define LOFI_CRYPTO_DATA_SECTOR ((uint32_t)16)          /* for version 0 */
 201  212  
 202  213  /*
 203  214   * Crypto metadata for encrypted lofi images
 204  215   * The fields here only satisfy initial implementation requirements.
 205  216   */
 206  217  struct crypto_meta {
 207  218          char            magic[6];               /* LOFI_CRYPTO_MAGIC */
 208  219          uint16_t        version;                /* version of encrypted lofi */
↓ open down ↓ 97 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX