nanovms / nanos

A kernel designed to run one and only one application in a virtualized environment
https://nanos.org
Apache License 2.0
2.58k stars 133 forks source link

uname: add configurability of sysname and release #2008

Closed francescolavra closed 5 months ago

francescolavra commented 6 months ago

With this change, it is possible to configure the kernel to insert arbitrary strings in the sysname and release fields of the struct used in the uname syscall. This allows running user programs that expect these fields to have specific values (e.g. programs that expect the sysname to be "Linux", or programs that parse the release string to infer a Linux kernel version). To configure the sysname and release fields, a "uname" configuration tuple is used: this tuple can contain a "sysname" string and a "release" string, which allow configuring the respective fields; if a given string is not present in the configuration, its default value is used (i.e., "Nanos" for the sysname field, and "5.0-" for the release field). Example snippet of Ops configuration file:

"ManifestPassthrough": {
  "uname": {
    "sysname": "Linux",
    "release": "5.0.5"
  }
}
rinor commented 5 months ago

How would we detect that we are running on nanos if sysname gets changed then, since this https://github.com/nanovms/nanos/issues/1885#issuecomment-1614336887 is not reliable anymore

francescolavra commented 5 months ago

The default behavior is not changing, i.e. if the user doesn't override the sysname, the kernel will continue to output "Nanos". If the user does override the sysname, I would assume they know what they are doing.