~elementary-os/elementaryos/os-patch-grub2-bionic

« back to all changes in this revision

Viewing changes to grub-core/fs/newc.c

  • Committer: RabbitBot
  • Date: 2018-02-05 13:05:56 UTC
  • Revision ID: rabbitbot@elementary.io-20180205130556-qgaormf12qpm3v40
Initial import, version 2.02-2ubuntu4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* cpio.c - cpio and tar filesystem.  */
 
2
/*
 
3
 *  GRUB  --  GRand Unified Bootloader
 
4
 *  Copyright (C) 2007,2008,2009,2013 Free Software Foundation, Inc.
 
5
 *
 
6
 *  This program is free software: you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation, either version 3 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <grub/misc.h>
 
21
 
 
22
#define ALIGN_CPIO(x) (ALIGN_UP ((x), 4))
 
23
#define MAGIC   "070701"
 
24
#define MAGIC2  "070702"
 
25
struct head
 
26
{
 
27
  char magic[6];
 
28
  char ino[8];
 
29
  char mode[8];
 
30
  char uid[8];
 
31
  char gid[8];
 
32
  char nlink[8];
 
33
  char mtime[8];
 
34
  char filesize[8];
 
35
  char devmajor[8];
 
36
  char devminor[8];
 
37
  char rdevmajor[8];
 
38
  char rdevminor[8];
 
39
  char namesize[8];
 
40
  char check[8];
 
41
} GRUB_PACKED;
 
42
 
 
43
static inline unsigned long long
 
44
read_number (const char *str, grub_size_t size)
 
45
{
 
46
  unsigned long long ret = 0;
 
47
  while (size-- && grub_isxdigit (*str))
 
48
    {
 
49
      char dig = *str++;
 
50
      if (dig >= '0' && dig <= '9')
 
51
        dig &= 0xf;
 
52
      else if (dig >= 'a' && dig <= 'f')
 
53
        dig -= 'a' - 10;
 
54
      else
 
55
        dig -= 'A' - 10;
 
56
      ret = (ret << 4) | (dig);
 
57
    }
 
58
  return ret;
 
59
}
 
60
 
 
61
#define FSNAME "newc"
 
62
 
 
63
#include "cpio_common.c"
 
64
 
 
65
GRUB_MOD_INIT (newc)
 
66
{
 
67
  grub_fs_register (&grub_cpio_fs);
 
68
}
 
69
 
 
70
GRUB_MOD_FINI (newc)
 
71
{
 
72
  grub_fs_unregister (&grub_cpio_fs);
 
73
}