uml: arch/um/drivers formatting
Style fixes for the rest of the drivers. arch/um/drivers should be pretty CodingStyle-compliant now. Except for the ubd driver, which will have to be treated separately. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
54ae36f24b
commit
cb8fa61c2b
@ -82,17 +82,21 @@ int generic_console_write(int fd, const char *buf, int n)
|
|||||||
if (err)
|
if (err)
|
||||||
goto error;
|
goto error;
|
||||||
new = save;
|
new = save;
|
||||||
/* The terminal becomes a bit less raw, to handle \n also as
|
/*
|
||||||
|
* The terminal becomes a bit less raw, to handle \n also as
|
||||||
* "Carriage Return", not only as "New Line". Otherwise, the new
|
* "Carriage Return", not only as "New Line". Otherwise, the new
|
||||||
* line won't start at the first column.*/
|
* line won't start at the first column.
|
||||||
|
*/
|
||||||
new.c_oflag |= OPOST;
|
new.c_oflag |= OPOST;
|
||||||
CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &new));
|
CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &new));
|
||||||
if (err)
|
if (err)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
err = generic_write(fd, buf, n, NULL);
|
err = generic_write(fd, buf, n, NULL);
|
||||||
/* Restore raw mode, in any case; we *must* ignore any error apart
|
/*
|
||||||
* EINTR, except for debug.*/
|
* Restore raw mode, in any case; we *must* ignore any error apart
|
||||||
|
* EINTR, except for debug.
|
||||||
|
*/
|
||||||
if (isatty(fd))
|
if (isatty(fd))
|
||||||
CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save));
|
CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save));
|
||||||
return err;
|
return err;
|
||||||
@ -167,13 +171,13 @@ static int winch_thread(void *arg)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ioctl(pty_fd, TIOCSCTTY, 0) < 0){
|
if (ioctl(pty_fd, TIOCSCTTY, 0) < 0) {
|
||||||
printk(UM_KERN_ERR "winch_thread : TIOCSCTTY failed on "
|
printk(UM_KERN_ERR "winch_thread : TIOCSCTTY failed on "
|
||||||
"fd %d err = %d\n", pty_fd, errno);
|
"fd %d err = %d\n", pty_fd, errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tcsetpgrp(pty_fd, os_getpid()) < 0){
|
if (tcsetpgrp(pty_fd, os_getpid()) < 0) {
|
||||||
printk(UM_KERN_ERR "winch_thread : tcsetpgrp failed on "
|
printk(UM_KERN_ERR "winch_thread : tcsetpgrp failed on "
|
||||||
"fd %d err = %d\n", pty_fd, errno);
|
"fd %d err = %d\n", pty_fd, errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
#include <stddef.h>
|
/*
|
||||||
#include <string.h>
|
* Copyright (C) 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
|
||||||
#include <errno.h>
|
* Licensed under the GPL
|
||||||
/* _XOPEN_SOURCE is needed for pread, but we define _GNU_SOURCE, which defines
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* _XOPEN_SOURCE is needed for pread, but we define _GNU_SOURCE, which defines
|
||||||
* that.
|
* that.
|
||||||
*/
|
*/
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
#include <sys/time.h>
|
#include <errno.h>
|
||||||
#include <sys/param.h>
|
#include <string.h>
|
||||||
#include <sys/user.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <asm/types.h>
|
||||||
#include "os.h"
|
|
||||||
|
|
||||||
#include "cow.h"
|
#include "cow.h"
|
||||||
#include "cow_sys.h"
|
#include "cow_sys.h"
|
||||||
|
|
||||||
@ -28,7 +29,8 @@ struct cow_header_v1 {
|
|||||||
__s32 sectorsize;
|
__s32 sectorsize;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
/* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
|
/*
|
||||||
|
* Define PATH_LEN_V3 as the usual value of MAXPATHLEN, just hard-code it in
|
||||||
* case other systems have different values for MAXPATHLEN.
|
* case other systems have different values for MAXPATHLEN.
|
||||||
*
|
*
|
||||||
* The same must hold for V2 - we want file format compatibility, not anything
|
* The same must hold for V2 - we want file format compatibility, not anything
|
||||||
@ -46,7 +48,8 @@ struct cow_header_v2 {
|
|||||||
__s32 sectorsize;
|
__s32 sectorsize;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
/* Changes from V2 -
|
/*
|
||||||
|
* Changes from V2 -
|
||||||
* PATH_LEN_V3 as described above
|
* PATH_LEN_V3 as described above
|
||||||
* Explicitly specify field bit lengths for systems with different
|
* Explicitly specify field bit lengths for systems with different
|
||||||
* lengths for the usual C types. Not sure whether char or
|
* lengths for the usual C types. Not sure whether char or
|
||||||
@ -70,7 +73,8 @@ struct cow_header_v2 {
|
|||||||
* Fixed (finally!) the rounding bug
|
* Fixed (finally!) the rounding bug
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Until Dec2005, __attribute__((packed)) was left out from the below
|
/*
|
||||||
|
* Until Dec2005, __attribute__((packed)) was left out from the below
|
||||||
* definition, leading on 64-bit systems to 4 bytes of padding after mtime, to
|
* definition, leading on 64-bit systems to 4 bytes of padding after mtime, to
|
||||||
* align size to 8-byte alignment. This shifted all fields above (no padding
|
* align size to 8-byte alignment. This shifted all fields above (no padding
|
||||||
* was present on 32-bit, no other padding was added).
|
* was present on 32-bit, no other padding was added).
|
||||||
@ -122,7 +126,7 @@ void cow_sizes(int version, __u64 size, int sectorsize, int align,
|
|||||||
int bitmap_offset, unsigned long *bitmap_len_out,
|
int bitmap_offset, unsigned long *bitmap_len_out,
|
||||||
int *data_offset_out)
|
int *data_offset_out)
|
||||||
{
|
{
|
||||||
if(version < 3){
|
if (version < 3) {
|
||||||
*bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
|
*bitmap_len_out = (size + sectorsize - 1) / (8 * sectorsize);
|
||||||
|
|
||||||
*data_offset_out = bitmap_offset + *bitmap_len_out;
|
*data_offset_out = bitmap_offset + *bitmap_len_out;
|
||||||
@ -144,46 +148,46 @@ static int absolutize(char *to, int size, char *from)
|
|||||||
char save_cwd[256], *slash;
|
char save_cwd[256], *slash;
|
||||||
int remaining;
|
int remaining;
|
||||||
|
|
||||||
if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
|
if (getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
|
||||||
cow_printf("absolutize : unable to get cwd - errno = %d\n",
|
cow_printf("absolutize : unable to get cwd - errno = %d\n",
|
||||||
errno);
|
errno);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
slash = strrchr(from, '/');
|
slash = strrchr(from, '/');
|
||||||
if(slash != NULL){
|
if (slash != NULL) {
|
||||||
*slash = '\0';
|
*slash = '\0';
|
||||||
if(chdir(from)){
|
if (chdir(from)) {
|
||||||
*slash = '/';
|
*slash = '/';
|
||||||
cow_printf("absolutize : Can't cd to '%s' - "
|
cow_printf("absolutize : Can't cd to '%s' - "
|
||||||
"errno = %d\n", from, errno);
|
"errno = %d\n", from, errno);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
*slash = '/';
|
*slash = '/';
|
||||||
if(getcwd(to, size) == NULL){
|
if (getcwd(to, size) == NULL) {
|
||||||
cow_printf("absolutize : unable to get cwd of '%s' - "
|
cow_printf("absolutize : unable to get cwd of '%s' - "
|
||||||
"errno = %d\n", from, errno);
|
"errno = %d\n", from, errno);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
remaining = size - strlen(to);
|
remaining = size - strlen(to);
|
||||||
if(strlen(slash) + 1 > remaining){
|
if (strlen(slash) + 1 > remaining) {
|
||||||
cow_printf("absolutize : unable to fit '%s' into %d "
|
cow_printf("absolutize : unable to fit '%s' into %d "
|
||||||
"chars\n", from, size);
|
"chars\n", from, size);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
strcat(to, slash);
|
strcat(to, slash);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
|
if (strlen(save_cwd) + 1 + strlen(from) + 1 > size) {
|
||||||
cow_printf("absolutize : unable to fit '%s' into %d "
|
cow_printf("absolutize : unable to fit '%s' into %d "
|
||||||
"chars\n", from, size);
|
"chars\n", from, size);
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy(to, save_cwd);
|
strcpy(to, save_cwd);
|
||||||
strcat(to, "/");
|
strcat(to, "/");
|
||||||
strcat(to, from);
|
strcat(to, from);
|
||||||
}
|
}
|
||||||
chdir(save_cwd);
|
chdir(save_cwd);
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_cow_header(char *cow_file, int fd, char *backing_file,
|
int write_cow_header(char *cow_file, int fd, char *backing_file,
|
||||||
@ -194,22 +198,23 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = cow_seek_file(fd, 0);
|
err = cow_seek_file(fd, 0);
|
||||||
if(err < 0){
|
if (err < 0) {
|
||||||
cow_printf("write_cow_header - lseek failed, err = %d\n", -err);
|
cow_printf("write_cow_header - lseek failed, err = %d\n", -err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
header = cow_malloc(sizeof(*header));
|
header = cow_malloc(sizeof(*header));
|
||||||
if(header == NULL){
|
if (header == NULL) {
|
||||||
cow_printf("write_cow_header - failed to allocate COW V3 header\n");
|
cow_printf("write_cow_header - failed to allocate COW V3 "
|
||||||
|
"header\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
header->magic = htonl(COW_MAGIC);
|
header->magic = htonl(COW_MAGIC);
|
||||||
header->version = htonl(COW_VERSION);
|
header->version = htonl(COW_VERSION);
|
||||||
|
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
if(strlen(backing_file) > sizeof(header->backing_file) - 1){
|
if (strlen(backing_file) > sizeof(header->backing_file) - 1) {
|
||||||
/* Below, %zd is for a size_t value */
|
/* Below, %zd is for a size_t value */
|
||||||
cow_printf("Backing file name \"%s\" is too long - names are "
|
cow_printf("Backing file name \"%s\" is too long - names are "
|
||||||
"limited to %zd characters\n", backing_file,
|
"limited to %zd characters\n", backing_file,
|
||||||
@ -217,12 +222,12 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
|
|||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(absolutize(header->backing_file, sizeof(header->backing_file),
|
if (absolutize(header->backing_file, sizeof(header->backing_file),
|
||||||
backing_file))
|
backing_file))
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
err = os_file_modtime(header->backing_file, &modtime);
|
err = os_file_modtime(header->backing_file, &modtime);
|
||||||
if(err < 0){
|
if (err < 0) {
|
||||||
cow_printf("write_cow_header - backing file '%s' mtime "
|
cow_printf("write_cow_header - backing file '%s' mtime "
|
||||||
"request failed, err = %d\n", header->backing_file,
|
"request failed, err = %d\n", header->backing_file,
|
||||||
-err);
|
-err);
|
||||||
@ -230,7 +235,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = cow_file_size(header->backing_file, size);
|
err = cow_file_size(header->backing_file, size);
|
||||||
if(err < 0){
|
if (err < 0) {
|
||||||
cow_printf("write_cow_header - couldn't get size of "
|
cow_printf("write_cow_header - couldn't get size of "
|
||||||
"backing file '%s', err = %d\n",
|
"backing file '%s', err = %d\n",
|
||||||
header->backing_file, -err);
|
header->backing_file, -err);
|
||||||
@ -244,7 +249,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
|
|||||||
header->cow_format = COW_BITMAP;
|
header->cow_format = COW_BITMAP;
|
||||||
|
|
||||||
err = cow_write_file(fd, header, sizeof(*header));
|
err = cow_write_file(fd, header, sizeof(*header));
|
||||||
if(err != sizeof(*header)){
|
if (err != sizeof(*header)) {
|
||||||
cow_printf("write_cow_header - write of header to "
|
cow_printf("write_cow_header - write of header to "
|
||||||
"new COW file '%s' failed, err = %d\n", cow_file,
|
"new COW file '%s' failed, err = %d\n", cow_file,
|
||||||
-err);
|
-err);
|
||||||
@ -254,14 +259,14 @@ int write_cow_header(char *cow_file, int fd, char *backing_file,
|
|||||||
out_free:
|
out_free:
|
||||||
cow_free(header);
|
cow_free(header);
|
||||||
out:
|
out:
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_reader(__u64 offset, char *buf, int len, void *arg)
|
int file_reader(__u64 offset, char *buf, int len, void *arg)
|
||||||
{
|
{
|
||||||
int fd = *((int *) arg);
|
int fd = *((int *) arg);
|
||||||
|
|
||||||
return(pread(fd, buf, len, offset));
|
return pread(fd, buf, len, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX Need to sanity-check the values read from the header */
|
/* XXX Need to sanity-check the values read from the header */
|
||||||
@ -278,31 +283,29 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
|
|||||||
unsigned long version, magic;
|
unsigned long version, magic;
|
||||||
|
|
||||||
header = cow_malloc(sizeof(*header));
|
header = cow_malloc(sizeof(*header));
|
||||||
if(header == NULL){
|
if (header == NULL) {
|
||||||
cow_printf("read_cow_header - Failed to allocate header\n");
|
cow_printf("read_cow_header - Failed to allocate header\n");
|
||||||
return(-ENOMEM);
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
n = (*reader)(0, (char *) header, sizeof(*header), arg);
|
n = (*reader)(0, (char *) header, sizeof(*header), arg);
|
||||||
if(n < offsetof(typeof(header->v1), backing_file)){
|
if (n < offsetof(typeof(header->v1), backing_file)) {
|
||||||
cow_printf("read_cow_header - short header\n");
|
cow_printf("read_cow_header - short header\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
magic = header->v1.magic;
|
magic = header->v1.magic;
|
||||||
if(magic == COW_MAGIC) {
|
if (magic == COW_MAGIC)
|
||||||
version = header->v1.version;
|
version = header->v1.version;
|
||||||
}
|
else if (magic == ntohl(COW_MAGIC))
|
||||||
else if(magic == ntohl(COW_MAGIC)){
|
|
||||||
version = ntohl(header->v1.version);
|
version = ntohl(header->v1.version);
|
||||||
}
|
|
||||||
/* No error printed because the non-COW case comes through here */
|
/* No error printed because the non-COW case comes through here */
|
||||||
else goto out;
|
else goto out;
|
||||||
|
|
||||||
*version_out = version;
|
*version_out = version;
|
||||||
|
|
||||||
if(version == 1){
|
if (version == 1) {
|
||||||
if(n < sizeof(header->v1)){
|
if (n < sizeof(header->v1)) {
|
||||||
cow_printf("read_cow_header - failed to read V1 "
|
cow_printf("read_cow_header - failed to read V1 "
|
||||||
"header\n");
|
"header\n");
|
||||||
goto out;
|
goto out;
|
||||||
@ -314,8 +317,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
|
|||||||
*align_out = *sectorsize_out;
|
*align_out = *sectorsize_out;
|
||||||
file = header->v1.backing_file;
|
file = header->v1.backing_file;
|
||||||
}
|
}
|
||||||
else if(version == 2){
|
else if (version == 2) {
|
||||||
if(n < sizeof(header->v2)){
|
if (n < sizeof(header->v2)) {
|
||||||
cow_printf("read_cow_header - failed to read V2 "
|
cow_printf("read_cow_header - failed to read V2 "
|
||||||
"header\n");
|
"header\n");
|
||||||
goto out;
|
goto out;
|
||||||
@ -328,8 +331,8 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
|
|||||||
file = header->v2.backing_file;
|
file = header->v2.backing_file;
|
||||||
}
|
}
|
||||||
/* This is very subtle - see above at union cow_header definition */
|
/* This is very subtle - see above at union cow_header definition */
|
||||||
else if(version == 3 && (*((int*)header->v3.backing_file) != 0)){
|
else if (version == 3 && (*((int*)header->v3.backing_file) != 0)) {
|
||||||
if(n < sizeof(header->v3)){
|
if (n < sizeof(header->v3)) {
|
||||||
cow_printf("read_cow_header - failed to read V3 "
|
cow_printf("read_cow_header - failed to read V3 "
|
||||||
"header\n");
|
"header\n");
|
||||||
goto out;
|
goto out;
|
||||||
@ -345,17 +348,18 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
|
|||||||
*bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out);
|
*bitmap_offset_out = ROUND_UP(sizeof(header->v3), *align_out);
|
||||||
file = header->v3.backing_file;
|
file = header->v3.backing_file;
|
||||||
}
|
}
|
||||||
else if(version == 3){
|
else if (version == 3) {
|
||||||
cow_printf("read_cow_header - broken V3 file with"
|
cow_printf("read_cow_header - broken V3 file with"
|
||||||
" 64-bit layout - recovering content.\n");
|
" 64-bit layout - recovering content.\n");
|
||||||
|
|
||||||
if(n < sizeof(header->v3_b)){
|
if (n < sizeof(header->v3_b)) {
|
||||||
cow_printf("read_cow_header - failed to read V3 "
|
cow_printf("read_cow_header - failed to read V3 "
|
||||||
"header\n");
|
"header\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this was used until Dec2005 - 64bits are needed to represent
|
/*
|
||||||
|
* this was used until Dec2005 - 64bits are needed to represent
|
||||||
* 2038+. I.e. we can safely do this truncating cast.
|
* 2038+. I.e. we can safely do this truncating cast.
|
||||||
*
|
*
|
||||||
* Additionally, we must use ntohl() instead of ntohll(), since
|
* Additionally, we must use ntohl() instead of ntohll(), since
|
||||||
@ -381,7 +385,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
|
|||||||
}
|
}
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
*backing_file_out = cow_strdup(file);
|
*backing_file_out = cow_strdup(file);
|
||||||
if(*backing_file_out == NULL){
|
if (*backing_file_out == NULL) {
|
||||||
cow_printf("read_cow_header - failed to allocate backing "
|
cow_printf("read_cow_header - failed to allocate backing "
|
||||||
"file\n");
|
"file\n");
|
||||||
goto out;
|
goto out;
|
||||||
@ -389,7 +393,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg,
|
|||||||
err = 0;
|
err = 0;
|
||||||
out:
|
out:
|
||||||
cow_free(header);
|
cow_free(header);
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
|
int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
|
||||||
@ -402,7 +406,7 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
|
|||||||
|
|
||||||
err = write_cow_header(cow_file, fd, backing_file, sectorsize,
|
err = write_cow_header(cow_file, fd, backing_file, sectorsize,
|
||||||
alignment, &size);
|
alignment, &size);
|
||||||
if(err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
*bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment);
|
*bitmap_offset_out = ROUND_UP(sizeof(struct cow_header_v3), alignment);
|
||||||
@ -411,17 +415,18 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
|
|||||||
|
|
||||||
offset = *data_offset_out + size - sizeof(zero);
|
offset = *data_offset_out + size - sizeof(zero);
|
||||||
err = cow_seek_file(fd, offset);
|
err = cow_seek_file(fd, offset);
|
||||||
if(err < 0){
|
if (err < 0) {
|
||||||
cow_printf("cow bitmap lseek failed : err = %d\n", -err);
|
cow_printf("cow bitmap lseek failed : err = %d\n", -err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* does not really matter how much we write it is just to set EOF
|
/*
|
||||||
|
* does not really matter how much we write it is just to set EOF
|
||||||
* this also sets the entire COW bitmap
|
* this also sets the entire COW bitmap
|
||||||
* to zero without having to allocate it
|
* to zero without having to allocate it
|
||||||
*/
|
*/
|
||||||
err = cow_write_file(fd, &zero, sizeof(zero));
|
err = cow_write_file(fd, &zero, sizeof(zero));
|
||||||
if(err != sizeof(zero)){
|
if (err != sizeof(zero)) {
|
||||||
cow_printf("Write of bitmap to new COW file '%s' failed, "
|
cow_printf("Write of bitmap to new COW file '%s' failed, "
|
||||||
"err = %d\n", cow_file, -err);
|
"err = %d\n", cow_file, -err);
|
||||||
if (err >= 0)
|
if (err >= 0)
|
||||||
@ -429,15 +434,7 @@ int init_cow_file(int fd, char *cow_file, char *backing_file, int sectorsize,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* ---------------------------------------------------------------------------
|
|
||||||
* Local variables:
|
|
||||||
* c-file-style: "linux"
|
|
||||||
* End:
|
|
||||||
*/
|
|
||||||
|
@ -3,17 +3,16 @@
|
|||||||
* Licensed under the GPL
|
* Licensed under the GPL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include "chan_user.h"
|
#include "chan_user.h"
|
||||||
|
#include "kern_constants.h"
|
||||||
|
#include "os.h"
|
||||||
#include "um_malloc.h"
|
#include "um_malloc.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "os.h"
|
|
||||||
#include "kern_constants.h"
|
|
||||||
|
|
||||||
struct fd_chan {
|
struct fd_chan {
|
||||||
int fd;
|
int fd;
|
||||||
@ -42,7 +41,7 @@ static void *fd_init(char *str, int device, const struct chan_opts *opts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
|
data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
|
||||||
if(data == NULL)
|
if (data == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*data = ((struct fd_chan) { .fd = n,
|
*data = ((struct fd_chan) { .fd = n,
|
||||||
|
@ -3,14 +3,12 @@
|
|||||||
* Licensed under the GPL
|
* Licensed under the GPL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "linux/module.h"
|
|
||||||
#include "linux/init.h"
|
|
||||||
#include "linux/slab.h"
|
|
||||||
#include "linux/fs.h"
|
#include "linux/fs.h"
|
||||||
|
#include "linux/module.h"
|
||||||
|
#include "linux/slab.h"
|
||||||
#include "linux/sound.h"
|
#include "linux/sound.h"
|
||||||
#include "linux/soundcard.h"
|
#include "linux/soundcard.h"
|
||||||
#include "asm/uaccess.h"
|
#include "asm/uaccess.h"
|
||||||
#include "kern_util.h"
|
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
@ -25,7 +23,8 @@ struct hostmixer_state {
|
|||||||
#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
|
#define HOSTAUDIO_DEV_DSP "/dev/sound/dsp"
|
||||||
#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
|
#define HOSTAUDIO_DEV_MIXER "/dev/sound/mixer"
|
||||||
|
|
||||||
/* Changed either at boot time or module load time. At boot, this is
|
/*
|
||||||
|
* Changed either at boot time or module load time. At boot, this is
|
||||||
* single-threaded; at module load, multiple modules would each have
|
* single-threaded; at module load, multiple modules would each have
|
||||||
* their own copy of these variables.
|
* their own copy of these variables.
|
||||||
*/
|
*/
|
||||||
@ -44,7 +43,7 @@ static char *mixer = HOSTAUDIO_DEV_MIXER;
|
|||||||
static int set_dsp(char *name, int *add)
|
static int set_dsp(char *name, int *add)
|
||||||
{
|
{
|
||||||
dsp = name;
|
dsp = name;
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
|
__uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
|
||||||
@ -52,7 +51,7 @@ __uml_setup("dsp=", set_dsp, "dsp=<dsp device>\n" DSP_HELP);
|
|||||||
static int set_mixer(char *name, int *add)
|
static int set_mixer(char *name, int *add)
|
||||||
{
|
{
|
||||||
mixer = name;
|
mixer = name;
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
|
__uml_setup("mixer=", set_mixer, "mixer=<mixer device>\n" MIXER_HELP);
|
||||||
@ -77,23 +76,23 @@ static ssize_t hostaudio_read(struct file *file, char __user *buffer,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostaudio: read called, count = %d\n", count);
|
printk(KERN_DEBUG "hostaudio: read called, count = %d\n", count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
kbuf = kmalloc(count, GFP_KERNEL);
|
kbuf = kmalloc(count, GFP_KERNEL);
|
||||||
if(kbuf == NULL)
|
if (kbuf == NULL)
|
||||||
return(-ENOMEM);
|
return -ENOMEM;
|
||||||
|
|
||||||
err = os_read_file(state->fd, kbuf, count);
|
err = os_read_file(state->fd, kbuf, count);
|
||||||
if(err < 0)
|
if (err < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if(copy_to_user(buffer, kbuf, err))
|
if (copy_to_user(buffer, kbuf, err))
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
kfree(kbuf);
|
kfree(kbuf);
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
|
static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
|
||||||
@ -104,25 +103,25 @@ static ssize_t hostaudio_write(struct file *file, const char __user *buffer,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostaudio: write called, count = %d\n", count);
|
printk(KERN_DEBUG "hostaudio: write called, count = %d\n", count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
kbuf = kmalloc(count, GFP_KERNEL);
|
kbuf = kmalloc(count, GFP_KERNEL);
|
||||||
if(kbuf == NULL)
|
if (kbuf == NULL)
|
||||||
return(-ENOMEM);
|
return -ENOMEM;
|
||||||
|
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
if(copy_from_user(kbuf, buffer, count))
|
if (copy_from_user(kbuf, buffer, count))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = os_write_file(state->fd, kbuf, count);
|
err = os_write_file(state->fd, kbuf, count);
|
||||||
if(err < 0)
|
if (err < 0)
|
||||||
goto out;
|
goto out;
|
||||||
*ppos += err;
|
*ppos += err;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
kfree(kbuf);
|
kfree(kbuf);
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int hostaudio_poll(struct file *file,
|
static unsigned int hostaudio_poll(struct file *file,
|
||||||
@ -131,10 +130,10 @@ static unsigned int hostaudio_poll(struct file *file,
|
|||||||
unsigned int mask = 0;
|
unsigned int mask = 0;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostaudio: poll called (unimplemented)\n");
|
printk(KERN_DEBUG "hostaudio: poll called (unimplemented)\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return(mask);
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hostaudio_ioctl(struct inode *inode, struct file *file,
|
static int hostaudio_ioctl(struct inode *inode, struct file *file,
|
||||||
@ -145,7 +144,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostaudio: ioctl called, cmd = %u\n", cmd);
|
printk(KERN_DEBUG "hostaudio: ioctl called, cmd = %u\n", cmd);
|
||||||
#endif
|
#endif
|
||||||
switch(cmd){
|
switch(cmd){
|
||||||
case SNDCTL_DSP_SPEED:
|
case SNDCTL_DSP_SPEED:
|
||||||
@ -154,8 +153,8 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
|
|||||||
case SNDCTL_DSP_CHANNELS:
|
case SNDCTL_DSP_CHANNELS:
|
||||||
case SNDCTL_DSP_SUBDIVIDE:
|
case SNDCTL_DSP_SUBDIVIDE:
|
||||||
case SNDCTL_DSP_SETFRAGMENT:
|
case SNDCTL_DSP_SETFRAGMENT:
|
||||||
if(get_user(data, (int __user *) arg))
|
if (get_user(data, (int __user *) arg))
|
||||||
return(-EFAULT);
|
return EFAULT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -170,14 +169,14 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
|
|||||||
case SNDCTL_DSP_CHANNELS:
|
case SNDCTL_DSP_CHANNELS:
|
||||||
case SNDCTL_DSP_SUBDIVIDE:
|
case SNDCTL_DSP_SUBDIVIDE:
|
||||||
case SNDCTL_DSP_SETFRAGMENT:
|
case SNDCTL_DSP_SETFRAGMENT:
|
||||||
if(put_user(data, (int __user *) arg))
|
if (put_user(data, (int __user *) arg))
|
||||||
return(-EFAULT);
|
return -EFAULT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hostaudio_open(struct inode *inode, struct file *file)
|
static int hostaudio_open(struct inode *inode, struct file *file)
|
||||||
@ -187,24 +186,26 @@ static int hostaudio_open(struct inode *inode, struct file *file)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostaudio: open called (host: %s)\n", dsp);
|
printk(KERN_DEBUG "hostaudio: open called (host: %s)\n", dsp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
|
state = kmalloc(sizeof(struct hostaudio_state), GFP_KERNEL);
|
||||||
if(state == NULL)
|
if (state == NULL)
|
||||||
return(-ENOMEM);
|
return -ENOMEM;
|
||||||
|
|
||||||
if(file->f_mode & FMODE_READ) r = 1;
|
if (file->f_mode & FMODE_READ)
|
||||||
if(file->f_mode & FMODE_WRITE) w = 1;
|
r = 1;
|
||||||
|
if (file->f_mode & FMODE_WRITE)
|
||||||
|
w = 1;
|
||||||
|
|
||||||
ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
|
ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
|
||||||
if(ret < 0){
|
if (ret < 0) {
|
||||||
kfree(state);
|
kfree(state);
|
||||||
return(ret);
|
return ret;
|
||||||
}
|
}
|
||||||
state->fd = ret;
|
state->fd = ret;
|
||||||
file->private_data = state;
|
file->private_data = state;
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hostaudio_release(struct inode *inode, struct file *file)
|
static int hostaudio_release(struct inode *inode, struct file *file)
|
||||||
@ -212,12 +213,12 @@ static int hostaudio_release(struct inode *inode, struct file *file)
|
|||||||
struct hostaudio_state *state = file->private_data;
|
struct hostaudio_state *state = file->private_data;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostaudio: release called\n");
|
printk(KERN_DEBUG "hostaudio: release called\n");
|
||||||
#endif
|
#endif
|
||||||
os_close_file(state->fd);
|
os_close_file(state->fd);
|
||||||
kfree(state);
|
kfree(state);
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* /dev/mixer file operations */
|
/* /dev/mixer file operations */
|
||||||
@ -228,10 +229,10 @@ static int hostmixer_ioctl_mixdev(struct inode *inode, struct file *file,
|
|||||||
struct hostmixer_state *state = file->private_data;
|
struct hostmixer_state *state = file->private_data;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostmixer: ioctl called\n");
|
printk(KERN_DEBUG "hostmixer: ioctl called\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return(os_ioctl_generic(state->fd, cmd, arg));
|
return os_ioctl_generic(state->fd, cmd, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
|
static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
|
||||||
@ -241,26 +242,29 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostmixer: open called (host: %s)\n", mixer);
|
printk(KERN_DEBUG "hostmixer: open called (host: %s)\n", mixer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL);
|
state = kmalloc(sizeof(struct hostmixer_state), GFP_KERNEL);
|
||||||
if(state == NULL) return(-ENOMEM);
|
if (state == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
if(file->f_mode & FMODE_READ) r = 1;
|
if (file->f_mode & FMODE_READ)
|
||||||
if(file->f_mode & FMODE_WRITE) w = 1;
|
r = 1;
|
||||||
|
if (file->f_mode & FMODE_WRITE)
|
||||||
|
w = 1;
|
||||||
|
|
||||||
ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
|
ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
|
||||||
|
|
||||||
if(ret < 0){
|
if (ret < 0) {
|
||||||
printk("hostaudio_open_mixdev failed to open '%s', err = %d\n",
|
printk(KERN_ERR "hostaudio_open_mixdev failed to open '%s', "
|
||||||
dsp, -ret);
|
"err = %d\n", dsp, -ret);
|
||||||
kfree(state);
|
kfree(state);
|
||||||
return(ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->private_data = state;
|
file->private_data = state;
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hostmixer_release(struct inode *inode, struct file *file)
|
static int hostmixer_release(struct inode *inode, struct file *file)
|
||||||
@ -268,13 +272,13 @@ static int hostmixer_release(struct inode *inode, struct file *file)
|
|||||||
struct hostmixer_state *state = file->private_data;
|
struct hostmixer_state *state = file->private_data;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printk("hostmixer: release called\n");
|
printk(KERN_DEBUG "hostmixer: release called\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
os_close_file(state->fd);
|
os_close_file(state->fd);
|
||||||
kfree(state);
|
kfree(state);
|
||||||
|
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* kernel module operations */
|
/* kernel module operations */
|
||||||
@ -314,13 +318,13 @@ static int __init hostaudio_init_module(void)
|
|||||||
dsp, mixer);
|
dsp, mixer);
|
||||||
|
|
||||||
module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
|
module_data.dev_audio = register_sound_dsp(&hostaudio_fops, -1);
|
||||||
if(module_data.dev_audio < 0){
|
if (module_data.dev_audio < 0) {
|
||||||
printk(KERN_ERR "hostaudio: couldn't register DSP device!\n");
|
printk(KERN_ERR "hostaudio: couldn't register DSP device!\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1);
|
module_data.dev_mixer = register_sound_mixer(&hostmixer_fops, -1);
|
||||||
if(module_data.dev_mixer < 0){
|
if (module_data.dev_mixer < 0) {
|
||||||
printk(KERN_ERR "hostmixer: couldn't register mixer "
|
printk(KERN_ERR "hostmixer: couldn't register mixer "
|
||||||
"device!\n");
|
"device!\n");
|
||||||
unregister_sound_dsp(module_data.dev_audio);
|
unregister_sound_dsp(module_data.dev_audio);
|
||||||
|
@ -1,25 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
|
* Copyright (C) 2001 Lennert Buytenhek (buytenh@gnu.org)
|
||||||
* Copyright (C) 2001 - 2003 Jeff Dike (jdike@addtoit.com)
|
* Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
||||||
* Licensed under the GPL
|
* Licensed under the GPL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <unistd.h>
|
#include "kern_constants.h"
|
||||||
#include "user.h"
|
|
||||||
#include "sysdep/ptrace.h"
|
|
||||||
#include "mconsole.h"
|
#include "mconsole.h"
|
||||||
#include "os.h"
|
#include "user.h"
|
||||||
|
|
||||||
static struct mconsole_command commands[] = {
|
static struct mconsole_command commands[] = {
|
||||||
/* With uts namespaces, uts information becomes process-specific, so
|
/*
|
||||||
|
* With uts namespaces, uts information becomes process-specific, so
|
||||||
* we need a process context. If we try handling this in interrupt
|
* we need a process context. If we try handling this in interrupt
|
||||||
* context, we may hit an exiting process without a valid uts
|
* context, we may hit an exiting process without a valid uts
|
||||||
* namespace.
|
* namespace.
|
||||||
@ -66,10 +63,10 @@ static struct mconsole_command *mconsole_parse(struct mc_request *req)
|
|||||||
struct mconsole_command *cmd;
|
struct mconsole_command *cmd;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < ARRAY_SIZE(commands); i++){
|
for (i = 0; i < ARRAY_SIZE(commands); i++) {
|
||||||
cmd = &commands[i];
|
cmd = &commands[i];
|
||||||
if(!strncmp(req->request.data, cmd->command,
|
if (!strncmp(req->request.data, cmd->command,
|
||||||
strlen(cmd->command))){
|
strlen(cmd->command))) {
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,7 +91,7 @@ int mconsole_get_request(int fd, struct mc_request *req)
|
|||||||
|
|
||||||
req->originating_fd = fd;
|
req->originating_fd = fd;
|
||||||
|
|
||||||
if(req->request.magic != MCONSOLE_MAGIC){
|
if (req->request.magic != MCONSOLE_MAGIC) {
|
||||||
/* Unversioned request */
|
/* Unversioned request */
|
||||||
len = MIN(sizeof(req->request.data) - 1,
|
len = MIN(sizeof(req->request.data) - 1,
|
||||||
strlen((char *) &req->request));
|
strlen((char *) &req->request));
|
||||||
@ -107,32 +104,33 @@ int mconsole_get_request(int fd, struct mc_request *req)
|
|||||||
|
|
||||||
mconsole_reply_v0(req, "ERR Version 0 mconsole clients are "
|
mconsole_reply_v0(req, "ERR Version 0 mconsole clients are "
|
||||||
"not supported by this driver");
|
"not supported by this driver");
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(req->request.len >= MCONSOLE_MAX_DATA){
|
if (req->request.len >= MCONSOLE_MAX_DATA) {
|
||||||
mconsole_reply(req, "Request too large", 1, 0);
|
mconsole_reply(req, "Request too large", 1, 0);
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
if(req->request.version != MCONSOLE_VERSION){
|
if (req->request.version != MCONSOLE_VERSION) {
|
||||||
mconsole_reply(req, "This driver only supports version "
|
mconsole_reply(req, "This driver only supports version "
|
||||||
STRING(MCONSOLE_VERSION) " clients", 1, 0);
|
STRING(MCONSOLE_VERSION) " clients", 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
req->request.data[req->request.len] = '\0';
|
req->request.data[req->request.len] = '\0';
|
||||||
req->cmd = mconsole_parse(req);
|
req->cmd = mconsole_parse(req);
|
||||||
if(req->cmd == NULL){
|
if (req->cmd == NULL) {
|
||||||
mconsole_reply(req, "Unknown command", 1, 0);
|
mconsole_reply(req, "Unknown command", 1, 0);
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mconsole_reply_len(struct mc_request *req, const char *str, int total,
|
int mconsole_reply_len(struct mc_request *req, const char *str, int total,
|
||||||
int err, int more)
|
int err, int more)
|
||||||
{
|
{
|
||||||
/* XXX This is a stack consumption problem. It'd be nice to
|
/*
|
||||||
|
* XXX This is a stack consumption problem. It'd be nice to
|
||||||
* make it global and serialize access to it, but there are a
|
* make it global and serialize access to it, but there are a
|
||||||
* ton of callers to this function.
|
* ton of callers to this function.
|
||||||
*/
|
*/
|
||||||
@ -147,7 +145,7 @@ int mconsole_reply_len(struct mc_request *req, const char *str, int total,
|
|||||||
|
|
||||||
len = MIN(total, MCONSOLE_MAX_DATA - 1);
|
len = MIN(total, MCONSOLE_MAX_DATA - 1);
|
||||||
|
|
||||||
if(len == total) reply.more = more;
|
if (len == total) reply.more = more;
|
||||||
else reply.more = 1;
|
else reply.more = 1;
|
||||||
|
|
||||||
memcpy(reply.data, str, len);
|
memcpy(reply.data, str, len);
|
||||||
@ -161,9 +159,10 @@ int mconsole_reply_len(struct mc_request *req, const char *str, int total,
|
|||||||
n = sendto(req->originating_fd, &reply, len, 0,
|
n = sendto(req->originating_fd, &reply, len, 0,
|
||||||
(struct sockaddr *) req->origin, req->originlen);
|
(struct sockaddr *) req->origin, req->originlen);
|
||||||
|
|
||||||
if(n < 0) return(-errno);
|
if (n < 0)
|
||||||
} while(total > 0);
|
return -errno;
|
||||||
return(0);
|
} while (total > 0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mconsole_reply(struct mc_request *req, const char *str, int err, int more)
|
int mconsole_reply(struct mc_request *req, const char *str, int err, int more)
|
||||||
@ -187,18 +186,18 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len)
|
|||||||
int n, err = 0;
|
int n, err = 0;
|
||||||
|
|
||||||
lock_notify();
|
lock_notify();
|
||||||
if(notify_sock < 0){
|
if (notify_sock < 0) {
|
||||||
notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0);
|
notify_sock = socket(PF_UNIX, SOCK_DGRAM, 0);
|
||||||
if(notify_sock < 0){
|
if (notify_sock < 0) {
|
||||||
err = -errno;
|
err = -errno;
|
||||||
printk("mconsole_notify - socket failed, errno = %d\n",
|
printk(UM_KERN_ERR "mconsole_notify - socket failed, "
|
||||||
err);
|
"errno = %d\n", errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlock_notify();
|
unlock_notify();
|
||||||
|
|
||||||
if(err)
|
if (err)
|
||||||
return(err);
|
return err;
|
||||||
|
|
||||||
target.sun_family = AF_UNIX;
|
target.sun_family = AF_UNIX;
|
||||||
strcpy(target.sun_path, sock_name);
|
strcpy(target.sun_path, sock_name);
|
||||||
@ -214,20 +213,10 @@ int mconsole_notify(char *sock_name, int type, const void *data, int len)
|
|||||||
len = sizeof(packet) + packet.len - sizeof(packet.data);
|
len = sizeof(packet) + packet.len - sizeof(packet.data);
|
||||||
n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target,
|
n = sendto(notify_sock, &packet, len, 0, (struct sockaddr *) &target,
|
||||||
sizeof(target));
|
sizeof(target));
|
||||||
if(n < 0){
|
if (n < 0) {
|
||||||
err = -errno;
|
err = -errno;
|
||||||
printk("mconsole_notify - sendto failed, errno = %d\n", errno);
|
printk(UM_KERN_ERR "mconsole_notify - sendto failed, "
|
||||||
|
"errno = %d\n", errno);
|
||||||
}
|
}
|
||||||
return(err);
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Overrides for Emacs so that we follow Linus's tabbing style.
|
|
||||||
* Emacs will notice this stuff at the end of the file and automatically
|
|
||||||
* adjust the settings for this buffer only. This must remain at the end
|
|
||||||
* of the file.
|
|
||||||
* ---------------------------------------------------------------------------
|
|
||||||
* Local variables:
|
|
||||||
* c-file-style: "linux"
|
|
||||||
* End:
|
|
||||||
*/
|
|
||||||
|
@ -9,27 +9,29 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/stddef.h>
|
||||||
|
#include <linux/types.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
|
#include <linux/miscdevice.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/fs.h>
|
|
||||||
#include <linux/miscdevice.h>
|
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include "mem_user.h"
|
#include "mem_user.h"
|
||||||
|
|
||||||
/* These are set in mmapper_init, which is called at boot time */
|
/* These are set in mmapper_init, which is called at boot time */
|
||||||
static unsigned long mmapper_size;
|
static unsigned long mmapper_size;
|
||||||
static unsigned long p_buf = 0;
|
static unsigned long p_buf;
|
||||||
static char *v_buf = NULL;
|
static char *v_buf;
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count,
|
||||||
mmapper_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
|
loff_t *ppos)
|
||||||
{
|
{
|
||||||
return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
|
return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t mmapper_write(struct file *file, const char __user *buf,
|
||||||
mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
if (*ppos > mmapper_size)
|
if (*ppos > mmapper_size)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -43,15 +45,13 @@ mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *p
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int mmapper_ioctl(struct inode *inode, struct file *file,
|
||||||
mmapper_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
|
unsigned int cmd, unsigned long arg)
|
||||||
unsigned long arg)
|
|
||||||
{
|
{
|
||||||
return(-ENOIOCTLCMD);
|
return -ENOIOCTLCMD;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int mmapper_mmap(struct file *file, struct vm_area_struct *vma)
|
||||||
mmapper_mmap(struct file *file, struct vm_area_struct * vma)
|
|
||||||
{
|
{
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
int size;
|
int size;
|
||||||
@ -60,9 +60,11 @@ mmapper_mmap(struct file *file, struct vm_area_struct * vma)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
size = vma->vm_end - vma->vm_start;
|
size = vma->vm_end - vma->vm_start;
|
||||||
if(size > mmapper_size) return(-EFAULT);
|
if (size > mmapper_size)
|
||||||
|
return -EFAULT;
|
||||||
|
|
||||||
/* XXX A comment above remap_pfn_range says it should only be
|
/*
|
||||||
|
* XXX A comment above remap_pfn_range says it should only be
|
||||||
* called when the mm semaphore is held
|
* called when the mm semaphore is held
|
||||||
*/
|
*/
|
||||||
if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
|
if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
|
||||||
@ -73,14 +75,12 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int mmapper_open(struct inode *inode, struct file *file)
|
||||||
mmapper_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int mmapper_release(struct inode *inode, struct file *file)
|
||||||
mmapper_release(struct inode *inode, struct file *file)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,9 @@ static const struct file_operations mmapper_fops = {
|
|||||||
.release = mmapper_release,
|
.release = mmapper_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* No locking needed - only used (and modified) by below initcall and exitcall. */
|
/*
|
||||||
|
* No locking needed - only used (and modified) by below initcall and exitcall.
|
||||||
|
*/
|
||||||
static struct miscdevice mmapper_dev = {
|
static struct miscdevice mmapper_dev = {
|
||||||
.minor = MISC_DYNAMIC_MINOR,
|
.minor = MISC_DYNAMIC_MINOR,
|
||||||
.name = "mmapper",
|
.name = "mmapper",
|
||||||
@ -109,13 +111,13 @@ static int __init mmapper_init(void)
|
|||||||
printk(KERN_INFO "Mapper v0.1\n");
|
printk(KERN_INFO "Mapper v0.1\n");
|
||||||
|
|
||||||
v_buf = (char *) find_iomem("mmapper", &mmapper_size);
|
v_buf = (char *) find_iomem("mmapper", &mmapper_size);
|
||||||
if(mmapper_size == 0){
|
if (mmapper_size == 0) {
|
||||||
printk(KERN_ERR "mmapper_init - find_iomem failed\n");
|
printk(KERN_ERR "mmapper_init - find_iomem failed\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = misc_register(&mmapper_dev);
|
err = misc_register(&mmapper_dev);
|
||||||
if(err){
|
if (err) {
|
||||||
printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
|
printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
|
||||||
err);
|
err);
|
||||||
goto out;
|
goto out;
|
||||||
@ -136,9 +138,3 @@ module_exit(mmapper_exit);
|
|||||||
|
|
||||||
MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
|
MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
|
||||||
MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
|
MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
|
||||||
/*
|
|
||||||
* ---------------------------------------------------------------------------
|
|
||||||
* Local variables:
|
|
||||||
* c-file-style: "linux"
|
|
||||||
* End:
|
|
||||||
*/
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "os.h"
|
|
||||||
#include "chan_user.h"
|
#include "chan_user.h"
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
/* This address is used only as a unique identifer */
|
/* This address is used only as a unique identifer */
|
||||||
static int null_chan;
|
static int null_chan;
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include "chan_user.h"
|
#include "chan_user.h"
|
||||||
#include "os.h"
|
|
||||||
#include "user.h"
|
|
||||||
#include "kern_constants.h"
|
#include "kern_constants.h"
|
||||||
|
#include "os.h"
|
||||||
#include "um_malloc.h"
|
#include "um_malloc.h"
|
||||||
|
#include "user.h"
|
||||||
|
|
||||||
struct pty_chan {
|
struct pty_chan {
|
||||||
void (*announce)(char *dev_name, int dev);
|
void (*announce)(char *dev_name, int dev);
|
||||||
@ -101,7 +101,7 @@ static int getmaster(char *line)
|
|||||||
*tp = 't';
|
*tp = 't';
|
||||||
err = access(line, R_OK | W_OK);
|
err = access(line, R_OK | W_OK);
|
||||||
*tp = 'p';
|
*tp = 'p';
|
||||||
if(!err)
|
if (!err)
|
||||||
return master;
|
return master;
|
||||||
close(master);
|
close(master);
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -96,8 +96,10 @@ static int xterm_open(int input, int output, int primary, void *d,
|
|||||||
if (access(argv[4], X_OK) < 0)
|
if (access(argv[4], X_OK) < 0)
|
||||||
argv[4] = "port-helper";
|
argv[4] = "port-helper";
|
||||||
|
|
||||||
/* Check that DISPLAY is set, this doesn't guarantee the xterm
|
/*
|
||||||
* will work but w/o it we can be pretty sure it won't. */
|
* Check that DISPLAY is set, this doesn't guarantee the xterm
|
||||||
|
* will work but w/o it we can be pretty sure it won't.
|
||||||
|
*/
|
||||||
if (getenv("DISPLAY") == NULL) {
|
if (getenv("DISPLAY") == NULL) {
|
||||||
printk(UM_KERN_ERR "xterm_open: $DISPLAY not set.\n");
|
printk(UM_KERN_ERR "xterm_open: $DISPLAY not set.\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user