Giter Club home page Giter Club logo

Comments (8)

chiache avatar chiache commented on May 28, 2024

Do you mean mounting the host proc file system to /proc in the library OS? I will strongly suggest not to do so. The proc file system is a pseudo file system which should reflect the OS states. The library OS has its own OS states so should only run its own proc file system.

from graphene.

yarnauy avatar yarnauy commented on May 28, 2024

But how to read the proc files of the library OS? There are no proc files in libOS if I don't mount th proc files of host system.

from graphene.

chiache avatar chiache commented on May 28, 2024

There is a simple proc file system in Graphene.

Graphene/LibOS/shim/test/native$ ./pal ls.manifest /proc
1
cpuinfo
meminfo
self

If you need a specific file in proc but Graphene hasn't implement it yet, you can try to mount only that file into graphene. Like this:

fs.mount.bin.type = chroot
fs.mount.bin.path = /proc/stat
fs.mount.bin.uri = file:/proc/stat

from graphene.

yarnauy avatar yarnauy commented on May 28, 2024

I tried this:

fs.mount.stat.type = chroot
fs.mount.stat.path = /proc/stat
fs.mount.stat.uri = file:/proc/stat

and my python code like this:

import sys
import os
#print sys.modules['psutil']

for filename in os.listdir(r'/proc'):
   	print filename

and the output:

meminfo
self
1
cpuinfo

It still cannot find the 'stat'
And I tried to read the /proc/stat directly , like this:

f=open('/proc/stat', 'rb')
values = f.readline()
print values

It should read the info of CPU time but the output is a blank line

So I think the /proc/stat in LibOS is empty. It's confusing.

from graphene.

donporter avatar donporter commented on May 28, 2024

Graphene currently does not implement /proc/stat within the libOS. I am curious why you need it? If there is an application that requires this information, it would not be hard to add (although some fields would either need to be bogus, or would need a host ABI to expose correctly). In general, we have added /proc files "on demand", or when we hit an application that we want to support that requires a given interface.

What you are doing with this manifest entry is creating a passthrough to the host /proc/stat, which might be ok, but it doesn't sound like what you want.

from graphene.

adilahmad17 avatar adilahmad17 commented on May 28, 2024

Hi, sorry to intrude on this but I have a question. You said that

fs.mount.stat.type = chroot
fs.mount.stat.path = /proc/stat
fs.mount.stat.uri = file:/proc/stat

creates a pass-through to the host's /proc/stat file. But that does not seem to be the case when I
try the same. It gives me an empty file. Is that expected behavior?

For clarification, I am trying to do something of the sort:

int fd = open("/proc/stat", O_RDONLY);
  if (fd < 0) {
    printf("File could not be opened\n");
    return -1; 
  }

  printf("File opened successfully\n");

  char buf[1024];
  int ret = read(fd, buf, 10);
  if (ret == 0) {
    printf("Buffer size is zero (0)\n");
    return -1; 
  }

from graphene.

donporter avatar donporter commented on May 28, 2024

I suspect the issue is that /proc/stat reports its size as zero bytes, and graphene is checking this size before trying to read more bytes.

On my system:

$ ls -l /proc/stat -r--r--r-- 1 root root 0 Jun 19 22:17 /proc/stat

If there is a good reason to add /proc/stat, we can put this on the feature list, either for graphene-internal emulation or as a host pass-through.

from graphene.

mkow avatar mkow commented on May 28, 2024

Already fixed on master. Host passthrough of procfs is wrong and unsupported, but we now have a proper emulation for procfs inside Graphene.

from graphene.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.