All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wedgwood <cw@f00f.org>
To: Bruno Diniz de Paula <diniz@cs.rutgers.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: O_DIRECT foolish question
Date: Wed, 12 Feb 2003 15:38:46 -0800	[thread overview]
Message-ID: <20030212233846.GA13540@f00f.org> (raw)
In-Reply-To: <1045092802.4766.96.camel@urca.rutgers.edu>

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

On Wed, Feb 12, 2003 at 06:33:23PM -0500, Bruno Diniz de Paula wrote:

> But your code doesn't use O_DIRECT:

Sorry, you need to edit it (see my previous email).  A better version
(appended) gives the following results.

cw:3@tapu(cw)$ cp od.c test
cw:3@tapu(cw)$ gcc -Wall od.c
cw:3@tapu(cw)$ ./a.out
read 503 bytes
read 0 bytes

> Let me know whether including O_DIRECT the test worked.

Seems to.  I get 0 the 2nd time about,  presumably this is EOF but
arguably it should return something else.

  --cw

[-- Attachment #2: od.c --]
[-- Type: text/x-csrc, Size: 503 bytes --]


#define _GNU_SOURCE

#include <unistd.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>

int main()
{
    int h;
    int ps;
    char *buf;
    ssize_t n;

    ps = getpagesize();
    if (!(buf = valloc(ps)))
	return 1;
    if ((h = open("test", O_RDONLY|O_DIRECT)) < 0)
	return 1;
    do {
	n = read(h, buf, ps);
	if (n == -1) {
	    perror("read");
	    break;
	}
	printf("read %d bytes\n", n);
    } while(n);

    close(h);

    return 0;
}

  reply	other threads:[~2003-02-12 23:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-12 21:19 O_DIRECT foolish question Bruno Diniz de Paula
2003-02-12 22:03 ` Andrew Morton
2003-02-12 22:29   ` Bruno Diniz de Paula
2003-02-12 22:42     ` Chris Wedgwood
2003-02-12 23:02       ` Bruno Diniz de Paula
2003-02-12 23:22         ` Bruno Diniz de Paula
2003-02-13  1:46           ` Randy.Dunlap
2003-02-12 23:24         ` Chris Wedgwood
2003-02-12 23:33           ` Bruno Diniz de Paula
2003-02-12 23:38             ` Chris Wedgwood [this message]
2003-02-12 23:49               ` Bruno Diniz de Paula
2003-02-12 23:51                 ` Chris Wedgwood
     [not found]                   ` <1045094589.4767.106.camel@urca.rutgers.edu>
     [not found]                     ` <20030213001302.GA13833@f00f.org>
2003-02-13  0:36                       ` Bruno Diniz de Paula
2003-02-13  5:12                         ` Andrew Morton
2003-02-13 15:22                           ` Bruno Diniz de Paula
2003-02-13 17:31                             ` Andrew Morton
2003-02-13 22:45                               ` Bruno Diniz de Paula
2003-02-12 23:33           ` Chris Wedgwood
2003-02-12 22:07 ` Chris Wedgwood

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=20030212233846.GA13540@f00f.org \
    --to=cw@f00f.org \
    --cc=diniz@cs.rutgers.edu \
    --cc=linux-kernel@vger.kernel.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.