~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to util/lvm.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-09-13 18:02:04 UTC
  • mfrom: (1.17.15 upstream)
  • mto: (17.6.27 experimental)
  • mto: This revision was merged to the branch mainline in revision 145.
  • Revision ID: package-import@ubuntu.com-20120913180204-mojnmocbimlom4im
Tags: upstream-2.00
ImportĀ upstreamĀ versionĀ 2.00

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* lvm.c - LVM support for GRUB utils.  */
2
2
/*
3
3
 *  GRUB  --  GRand Unified Bootloader
4
 
 *  Copyright (C) 2006,2007,2008  Free Software Foundation, Inc.
 
4
 *  Copyright (C) 2006,2007,2008,2011  Free Software Foundation, Inc.
5
5
 *
6
6
 *  GRUB is free software: you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
18
18
 */
19
19
 
20
 
/* We only support LVM on Linux.  */
21
 
#ifdef __linux__
 
20
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
22
21
#include <grub/emu/misc.h>
23
22
#include <grub/util/misc.h>
24
23
#include <grub/util/lvm.h>
26
25
#include <string.h>
27
26
#include <sys/stat.h>
28
27
 
29
 
#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
30
 
 
31
28
int
32
29
grub_util_lvm_isvolume (char *name)
33
30
{
34
 
  char *devname;
 
31
  char *lvmdevname;
35
32
  struct stat st;
36
33
  int err;
37
34
 
38
 
  devname = xmalloc (strlen (name) + sizeof (LVM_DEV_MAPPER_STRING));
39
 
 
40
 
  strcpy (devname, LVM_DEV_MAPPER_STRING);
41
 
  strcpy (devname + sizeof(LVM_DEV_MAPPER_STRING) - 1, name);
42
 
 
43
 
  err = stat (devname, &st);
44
 
  free (devname);
 
35
  lvmdevname = xmalloc (strlen (name) + sizeof (LVM_DEV_MAPPER_STRING));
 
36
 
 
37
  strcpy (lvmdevname, LVM_DEV_MAPPER_STRING);
 
38
  strcpy (lvmdevname + sizeof(LVM_DEV_MAPPER_STRING) - 1, name);
 
39
 
 
40
  err = stat (lvmdevname, &st);
 
41
  free (lvmdevname);
45
42
 
46
43
  if (err)
47
44
    return 0;
49
46
    return 1;
50
47
}
51
48
 
52
 
#endif /* ! __linux__ */
 
49
#endif