All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Shuvikov <mr_hyro@yahoo.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: stat for FreeBSD
Date: Mon, 15 Dec 2008 09:24:41 -0800 (PST)	[thread overview]
Message-ID: <163071.88883.qm@web42108.mail.mud.yahoo.com> (raw)
In-Reply-To: <20081214011222.GD25952@thorin>

[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]

I don't have much experience developing under FreeBSD but this call taken from the fdisk source code seems to work (see attachment also):

error = ioctl(fd, DIOCGMEDIASIZE, &size);

Thanks,
Andrey


--- On Sat, 12/13/08, Robert Millan <rmh@aybabtu.com> wrote:

> From: Robert Millan <rmh@aybabtu.com>
> Subject: Re: stat for FreeBSD
> To: "The development of GRUB 2" <grub-devel@gnu.org>
> Date: Saturday, December 13, 2008, 8:12 PM
> On Tue, Dec 09, 2008 at 03:26:28PM -0800, Andrey Shuvikov
> wrote:
> > Hello,
> > 
> > I tried to compile Grub2 under FreeBSD, it compiles
> but doesn't work (grub-setup). The problem seems to be
> in the stat() call, which is used to determine disk size.
> The call returns 0 for st_size, and grub-setup complains for
> "Read out of range". Is it a known issue? Is there
> a way to use Grub2 under FreeBSD?
> 
> Do you know how to obtain the disk size on FreeBSD ?
> 
> -- 
> Robert Millan
> 
>   The DRM opt-in fallacy: "Your data belongs to us. We
> will decide when (and
>   how) you may access your data; but nobody's
> threatening your freedom: we
>   still allow you to remove your data and not access it at
> all."
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel


      

[-- Attachment #2: getsize.c --]
[-- Type: application/octet-stream, Size: 526 bytes --]

#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/disk.h>

int main(int argc, char * argv[]) {
  off_t size;
  int   error;
  int   fd;

  if (argc != 2) {
    printf("Usage: getsize <device>\n");
    return 1;
  }

  fd = open(argv[1], O_RDONLY);
  if (fd == -1) {
    perror("open");
    return -1;
  }

  error = ioctl(fd, DIOCGMEDIASIZE, &size);
  if (error == -1) {
    perror("ioctl");
  } else {
    printf("Size: %lld\n", size);
  }
 
  close(fd);
  return 0;
}

  parent reply	other threads:[~2008-12-15 17:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-09 23:26 stat for FreeBSD Andrey Shuvikov
2008-12-14  1:12 ` Robert Millan
2008-12-14 14:26   ` Javier Martín
2008-12-15 17:24   ` Andrey Shuvikov [this message]
2009-02-07 19:39     ` Robert Millan
2009-03-12 16:24       ` Andrey Shuvikov
  -- strict thread matches above, loose matches on Subject: below --
2009-04-06 15:48 Andrey Shuvikov
2009-04-07  0:35 ` Yoshinori K. Okuji
2009-04-08 14:32 Andrey Shuvikov
2009-04-09 23:31 ` Yoshinori K. Okuji
2009-04-10  3:51 Andrey Shuvikov
2009-04-10  7:34 ` Felix Zielcke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=163071.88883.qm@web42108.mail.mud.yahoo.com \
    --to=mr_hyro@yahoo.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.