diff --git a/elks/fs/super.c b/elks/fs/super.c index a4d80501e..896e9a403 100644 --- a/elks/fs/super.c +++ b/elks/fs/super.c @@ -46,15 +46,15 @@ extern struct file_system_type msdos_fs_type; static struct file_system_type *file_systems[] = { /* first filesystem is default filesystem for mount w/o -t parm*/ #ifdef CONFIG_ROMFS_FS - &romfs_fs_type, + &romfs_fs_type, #endif #ifdef CONFIG_MINIX_FS - &minix_fs_type, + &minix_fs_type, #endif #ifdef CONFIG_FS_FAT - &msdos_fs_type, + &msdos_fs_type, #endif - NULL + NULL }; static const char *fsname[] = { NULL, "minix", "msdos", "romfs" }; @@ -65,7 +65,7 @@ static struct file_system_type *get_fs_type(int type) if (type == 0) return file_systems[0]; while (file_systems[++ct]) - if (file_systems[ct]->type == type) break; + if (file_systems[ct]->type == type) break; return file_systems[ct]; } #endif @@ -73,7 +73,7 @@ static struct file_system_type *get_fs_type(int type) void wait_on_super(register struct super_block *sb) { while (sb->s_lock) - sleep_on(&sb->s_wait); + sleep_on(&sb->s_wait); } void lock_super(register struct super_block *sb) @@ -95,11 +95,11 @@ void sync_supers(kdev_t dev) debug_sup("sync_supers\n"); do { - if ((!sb->s_dev) || (dev && sb->s_dev != dev)) continue; - wait_on_super(sb); - if (!sb->s_dev || !sb->s_dirt || (dev && (dev != sb->s_dev))) continue; - sop = sb->s_op; - if (sop && sop->write_super) sop->write_super(sb); + if ((!sb->s_dev) || (dev && sb->s_dev != dev)) continue; + wait_on_super(sb); + if (!sb->s_dev || !sb->s_dirt || (dev && (dev != sb->s_dev))) continue; + sop = sb->s_op; + if (sop && sop->write_super) sop->write_super(sb); } while (++sb < super_blocks + NR_SUPER); } @@ -109,14 +109,14 @@ static struct super_block *get_super(kdev_t dev) if (dev) { repeat: - s = super_blocks; - do { - if (s->s_dev == dev) { - wait_on_super(s); - if (s->s_dev == dev) return s; - goto repeat; - } - } while (++s < super_blocks + NR_SUPER); + s = super_blocks; + do { + if (s->s_dev == dev) { + wait_on_super(s); + if (s->s_dev == dev) return s; + goto repeat; + } + } while (++s < super_blocks + NR_SUPER); } return NULL; } @@ -127,14 +127,14 @@ void put_super(kdev_t dev) register struct super_operations *sop; if (dev == ROOT_DEV) - panic("put_super: root\n"); + panic("put_super: root\n"); if (!(sb = get_super(dev))) return; if (sb->s_covered) - printk("put_super: device %D mounted\n", dev); + printk("put_super: device %D mounted\n", dev); else { - sop = sb->s_op; - if (sop && sop->put_super) sop->put_super(sb); + sop = sb->s_op; + if (sop && sop->put_super) sop->put_super(sb); } } @@ -144,7 +144,7 @@ int sys_ustatfs(dev_t dev, struct statfs *ubuf, int flags) struct statfs sbuf; if (dev < NR_SUPER) - dev = super_blocks[(int)dev].s_dev; + dev = super_blocks[(int)dev].s_dev; s = get_super(to_kdev_t(dev)); if (s == NULL) return -EINVAL; @@ -163,7 +163,7 @@ int sys_ustatfs(dev_t dev, struct statfs *ubuf, int flags) } static struct super_block *read_super(kdev_t dev, int t, int flags, - char *data, int silent) + char *data, int silent) { register struct super_block *s; register struct file_system_type *type; @@ -177,26 +177,26 @@ static struct super_block *read_super(kdev_t dev, int t, int flags, #if CONFIG_FULL_VFS if (!(type = get_fs_type(t))) { - printk("VFS: device %D unknown fs type %d\n", dev, t); - return NULL; + printk("VFS: device %D unknown fs type %d\n", dev, t); + return NULL; } #else type = file_systems[0]; #endif for (s = super_blocks; ; s++) { - if (s >= super_blocks + NR_SUPER) - return NULL; - if (s->s_dev == 0) - break; + if (s >= super_blocks + NR_SUPER) + return NULL; + if (s->s_dev == 0) + break; } s->s_dev = dev; s->s_flags = flags; if (!type->read_super(s, data, silent)) { - s->s_dev = 0; - return NULL; + s->s_dev = 0; + return NULL; } s->s_covered = NULL; s->s_dirt = 0; @@ -216,33 +216,33 @@ static int do_umount(kdev_t dev) int retval = -ENOENT; if ((sb = get_super(dev))) { - if (dev == ROOT_DEV) { - /* Special case for "unmounting" root. We just try to remount - * it readonly, and sync() the device. - */ - retval = 0; - if (!(sb->s_flags & MS_RDONLY)) { - debug_sup("UMOUNT remount fsync\n"); - fsync_dev(dev); - retval = do_remount_sb(sb, MS_RDONLY, 0); - debug_sup("UMOUNT remount returns %d\n", retval); - } - } - else if (sb->s_covered) { - if (!sb->s_covered->i_mount) panic("umount: i_mount=NULL\n"); - if (!fs_may_umount(dev, sb->s_mounted)) retval = -EBUSY; - else { - retval = 0; - sb->s_covered->i_mount = NULL; - iput(sb->s_covered); - sb->s_covered = NULL; - iput(sb->s_mounted); - sb->s_mounted = NULL; - sop = sb->s_op; - if (sop && sop->write_super && sb->s_dirt) sop->write_super(sb); - put_super(dev); - } - } + if (dev == ROOT_DEV) { + /* Special case for "unmounting" root. We just try to remount + * it readonly, and sync() the device. + */ + retval = 0; + if (!(sb->s_flags & MS_RDONLY)) { + debug_sup("UMOUNT remount fsync\n"); + fsync_dev(dev); + retval = do_remount_sb(sb, MS_RDONLY, 0); + debug_sup("UMOUNT remount returns %d\n", retval); + } + } + else if (sb->s_covered) { + if (!sb->s_covered->i_mount) panic("umount: i_mount=NULL\n"); + if (!fs_may_umount(dev, sb->s_mounted)) retval = -EBUSY; + else { + retval = 0; + sb->s_covered->i_mount = NULL; + iput(sb->s_covered); + sb->s_covered = NULL; + iput(sb->s_mounted); + sb->s_mounted = NULL; + sop = sb->s_op; + if (sop && sop->write_super && sb->s_dirt) sop->write_super(sb); + put_super(dev); + } + } } return retval; } @@ -268,39 +268,39 @@ int sys_umount(char *name) if (!suser()) return -EPERM; retval = namei(name, &inode, 0, 0); if (retval) { - retval = lnamei(name, &inode); - if (retval) return retval; + retval = lnamei(name, &inode); + if (retval) return retval; } inodep = inode; if (S_ISBLK(inodep->i_mode)) { - if (IS_NODEV(inodep)) { - iput(inodep); - return -EACCES; - } + if (IS_NODEV(inodep)) { + iput(inodep); + return -EACCES; + } } else { - register struct super_block *sb = inodep->i_sb; - if (!sb || inodep != sb->s_mounted) { - iput(inodep); - return -EINVAL; - } - iput(inodep); - inodep = new_inode(NULL, S_IFBLK); - inodep->i_rdev = sb->s_dev; + register struct super_block *sb = inodep->i_sb; + if (!sb || inodep != sb->s_mounted) { + iput(inodep); + return -EINVAL; + } + iput(inodep); + inodep = new_inode(NULL, S_IFBLK); + inodep->i_rdev = sb->s_dev; } dev = inodep->i_rdev; if (MAJOR(dev) >= MAX_BLKDEV) { - iput(inodep); - return -ENXIO; + iput(inodep); + return -ENXIO; } if (!(retval = do_umount(dev)) && dev != ROOT_DEV) { - register struct file_operations *fops; - fops = get_blkfops(MAJOR(dev)); - if (fops && fops->release) fops->release(inodep, NULL); + register struct file_operations *fops; + fops = get_blkfops(MAJOR(dev)); + if (fops && fops->release) fops->release(inodep, NULL); } iput(inodep); if (!retval) { - debug_sup("UMOUNT fsync\n"); - fsync_dev(dev); + debug_sup("UMOUNT fsync\n"); + fsync_dev(dev); } return retval; } @@ -325,27 +325,27 @@ int do_mount(kdev_t dev, char *dir, int type, int flags, char *data) if ((error = namei(dir, &dir_i, IS_DIR, 0))) goto ERROUT; dirp = dir_i; if ((dirp->i_count != 1 || dirp->i_mount) || (!fs_may_mount(dev))) - goto BUSY; + goto BUSY; sb = read_super(dev, type, flags, data, flags & MS_AUTOMOUNT); if (!sb) { - error = -EINVAL; - goto ERROUT1; + error = -EINVAL; + goto ERROUT1; } if (sb->s_covered) { BUSY: - error = -EBUSY; + error = -EBUSY; ERROUT1: - iput(dirp); + iput(dirp); } else { - sb->s_covered = dirp; - dirp->i_mount = sb->s_mounted; - verified_memcpy_fromfs(sb->s_mntonname, dir, MNAMELEN); - error = 0; /* we don't iput(dir_i) - see umount */ + sb->s_covered = dirp; + dirp->i_mount = sb->s_mounted; + verified_memcpy_fromfs(sb->s_mntonname, dir, MNAMELEN); + error = 0; /* we don't iput(dir_i) - see umount */ } ERROUT: debug_sup("MOUNT error %d\n", error); - return error; + return error; } /* @@ -363,13 +363,13 @@ static int do_remount_sb(register struct super_block *sb, int flags, char *data) /* If we are remounting RDONLY, make sure there are no rw files open */ if ((flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY)) - if (!fs_may_remount_ro(sb->s_dev)) return -EBUSY; + if (!fs_may_remount_ro(sb->s_dev)) return -EBUSY; if (sop && sop->remount_fs) { - retval = sop->remount_fs(sb, &flags, data); - if (retval) { - debug_sup("REMOUNT fail\n"); - return retval; - } + retval = sop->remount_fs(sb, &flags, data); + if (retval) { + debug_sup("REMOUNT fail\n"); + return retval; + } } sb->s_flags = (unsigned short int) ((sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK)); debug_sup("REMOUNT ok\n"); @@ -382,9 +382,9 @@ static int do_remount(char *dir, int flags, char *data) int retval; if (!(retval = namei(dir, &dir_i, 0, 0))) { - if (dir_i != dir_i->i_sb->s_mounted) retval = -EINVAL; - else retval = do_remount_sb(dir_i->i_sb, flags, data); - iput(dir_i); + if (dir_i != dir_i->i_sb->s_mounted) retval = -EINVAL; + else retval = do_remount_sb(dir_i->i_sb, flags, data); + iput(dir_i); } return retval; } @@ -404,7 +404,7 @@ int sys_mount(char *dev_name, char *dir_name, int type, int flags) if (!suser()) return -EPERM; if (flags & MS_REMOUNT) - return do_remount(dir_name, flags & ~MS_REMOUNT, NULL); + return do_remount(dir_name, flags & ~MS_REMOUNT, NULL); #ifdef CONFIG_FULL_VFS debug("MOUNT: performing type check\n"); @@ -418,26 +418,26 @@ int sys_mount(char *dev_name, char *dir_name, int type, int flags) filp = NULL; - retval = namei(dev_name, &inode, 0, 0); - if (retval) return retval; - inodep = inode; - debug("MOUNT: made it through namei\n"); - if (!S_ISBLK(inodep->i_mode)) - retval = -ENOTBLK; - else if (IS_NODEV(inodep)) - retval = -EACCES; - else if (MAJOR(inodep->i_rdev) >= MAX_BLKDEV) - retval = -ENXIO; - else - retval = open_filp((mode_t)((flags & MS_RDONLY) ? 1 : 3), inodep, &filp); - if (retval) { - iput(inodep); - return retval; - } + retval = namei(dev_name, &inode, 0, 0); + if (retval) return retval; + inodep = inode; + debug("MOUNT: made it through namei\n"); + if (!S_ISBLK(inodep->i_mode)) + retval = -ENOTBLK; + else if (IS_NODEV(inodep)) + retval = -EACCES; + else if (MAJOR(inodep->i_rdev) >= MAX_BLKDEV) + retval = -ENXIO; + else + retval = open_filp((mode_t)((flags & MS_RDONLY) ? 1 : 3), inodep, &filp); + if (retval) { + iput(inodep); + return retval; + } retval = do_mount(inodep->i_rdev, dir_name, fstype->type, flags, NULL); if (retval && filp) - close_filp(inodep, filp); + close_filp(inodep, filp); iput(inodep); return retval; @@ -458,46 +458,46 @@ void mount_root(void) retry_floppy: retval = open_filp(((root_mountflags & MS_RDONLY) ? 0 : 2), d_inode, &filp); if (retval == -EROFS) { - root_mountflags |= MS_RDONLY; - retval = open_filp(0, d_inode, &filp); + root_mountflags |= MS_RDONLY; + retval = open_filp(0, d_inode, &filp); } if (retval) { - printk("VFS: Unable to open root device %D (%d)\n", ROOT_DEV, retval); - halt(); + printk("VFS: Unable to open root device %D (%d)\n", ROOT_DEV, retval); + halt(); } fs_type = &file_systems[0]; do { - fp = *fs_type; + fp = *fs_type; #ifdef BLOAT_FS - if (!fp->requires_dev) continue; + if (!fp->requires_dev) continue; #endif - sb = read_super(ROOT_DEV, fp->type, root_mountflags, NULL, 1); - if (sb) { - /* NOTE! it is logically used 4 times, not 1 */ - sb->s_mounted->i_count += 3; - sb->s_covered = sb->s_mounted; - memcpy(sb->s_mntonname, "/", 2); -/* sb->s_flags = (unsigned short int) root_mountflags;*/ - current->fs.pwd = current->fs.root = sb->s_mounted; - printk("VFS: Mounted root device %04x (%s filesystem)%s.\n", ROOT_DEV, - fsname[fp->type], (sb->s_flags & MS_RDONLY) ? " readonly" : ""); - iput(d_inode); - filp->f_count = 0; - return; - } + sb = read_super(ROOT_DEV, fp->type, root_mountflags, NULL, 1); + if (sb) { + /* NOTE! it is logically used 4 times, not 1 */ + sb->s_mounted->i_count += 3; + sb->s_covered = sb->s_mounted; + memcpy(sb->s_mntonname, "/", 2); +/* sb->s_flags = (unsigned short int) root_mountflags;*/ + current->fs.pwd = current->fs.root = sb->s_mounted; + printk("VFS: Mounted root device %04x (%s filesystem)%s.\n", ROOT_DEV, + fsname[fp->type], (sb->s_flags & MS_RDONLY) ? " readonly" : ""); + iput(d_inode); + filp->f_count = 0; + return; + } } while (*(++fs_type) && !retval); #ifdef CONFIG_BLK_DEV_BIOS if (ROOT_DEV == 0x0380) { - if (!filp->f_op->release) - printk("Release not defined\n"); - close_filp(d_inode, filp); - printk("VFS: Insert root floppy and press ENTER\n"); - wait_for_keypress(); - goto retry_floppy; + if (!filp->f_op->release) + printk("Release not defined\n"); + close_filp(d_inode, filp); + printk("VFS: Insert root floppy and press ENTER\n"); + wait_for_keypress(); + goto retry_floppy; } #endif diff --git a/elks/include/arch/posix_types.h b/elks/include/arch/posix_types.h index 414a99f56..70772dafc 100644 --- a/elks/include/arch/posix_types.h +++ b/elks/include/arch/posix_types.h @@ -12,32 +12,28 @@ * assume GCC is being used. */ -/*@-namechecks@*/ - -#undef __FD_SET +#undef __FD_SET #ifndef __KERNEL__ #define __FD_SET(fd,fdsetp) (*(fdsetp) |= (__u32)1 << (fd)) #else #define __FD_SET(fd,fdsetp) set_bit(fd, fdsetp) #endif -#undef __FD_CLR +#undef __FD_CLR #ifndef __KERNEL__ #define __FD_CLR(fd,fdsetp) (*(fdsetp) &= ~((__u32)1 << (fd))) #else #define __FD_CLR(fd,fdsetp) clear_bit(fd, fdsetp) #endif -#undef __FD_ISSET +#undef __FD_ISSET #ifndef __KERNEL__ #define __FD_ISSET(fd,fdsetp) ((*(fdsetp) >> (fd)) & 1) #else #define __FD_ISSET(fd,fdsetp) test_bit(fd, fdsetp) #endif -#undef __FD_ZERO -#define __FD_ZERO(fdsetp) (*(fdsetp) = 0UL) - -/*@+namechecks@*/ +#undef __FD_ZERO +#define __FD_ZERO(fdsetp) (*(fdsetp) = 0UL) #endif diff --git a/elks/include/arch/types.h b/elks/include/arch/types.h index e912e064f..408bd29db 100644 --- a/elks/include/arch/types.h +++ b/elks/include/arch/types.h @@ -3,31 +3,29 @@ #ifndef __ARCH_8086_TYPES_H #define __ARCH_8086_TYPES_H -/*@-namechecks@*/ - /* First we define all of the __u and __s types...*/ #define signed -typedef unsigned char __u8, *__pu8; -typedef signed char __s8, *__ps8; -typedef unsigned short int __u16, *__pu16; -typedef signed short int __s16, *__ps16; -typedef unsigned long int __u32, *__pu32; -typedef signed long int __s32, *__ps32; +typedef unsigned char __u8, *__pu8; +typedef signed char __s8, *__ps8; +typedef unsigned short int __u16, *__pu16; +typedef signed short int __s16, *__ps16; +typedef unsigned long int __u32, *__pu32; +typedef signed long int __s32, *__ps32; /* __uint == 16bit here */ -typedef unsigned short int __uint, *__puint; -typedef signed short int __sint, *__psint; +typedef unsigned short int __uint, *__puint; +typedef signed short int __sint, *__psint; /* 8086 types */ - -typedef __u8 byte_t; -typedef __u16 word_t; -typedef __u32 long_t; -typedef __u16 seg_t; -typedef __u32 addr_t; +typedef __u8 byte_t; +typedef __u16 word_t; +typedef __u32 long_t; +typedef __u16 seg_t; +typedef __u16 __pptr; +typedef __u32 addr_t; /* Then we define registers, etc... */ @@ -38,8 +36,8 @@ struct pt_regs { }; struct xregs { - __u16 cs; /* code segment to use in arch_setup_user_stack()*/ - __u16 ksp; /* saved kernel SP used by twsitch()*/ + __u16 cs; /* code segment to use in arch_setup_user_stack()*/ + __u16 ksp; /* saved kernel SP used by twsitch()*/ }; /* ordering of saved registers on user stack after interrupt entry*/ @@ -47,12 +45,8 @@ struct uregs { __u16 bp, ip, cs, f; }; -typedef __u16 __pptr; - -/*@+namechecks@*/ - #ifndef NULL -#define NULL ((void *) 0) +#define NULL ((void *) 0) #endif #endif /* !__ARCH_8086_TYPES_H */ diff --git a/elks/include/linuxmt/kdev_t.h b/elks/include/linuxmt/kdev_t.h index cfae9fd1a..183c5a0b2 100644 --- a/elks/include/linuxmt/kdev_t.h +++ b/elks/include/linuxmt/kdev_t.h @@ -1,37 +1,28 @@ #ifndef __LINUXMT_KDEV_T_H #define __LINUXMT_KDEV_T_H -#define MINORBITS 8 -#define MINORMASK ((1<> MINORBITS)) +#define MINOR(dev) ((unsigned short) ((dev) & MINORMASK)) +#define MKDEV(major,minor) ((unsigned short) (((major) << MINORBITS) | (minor))) +#define NODEV MKDEV(0,0) #ifdef __KERNEL__ +#include -#define MAJOR(dev) ((unsigned short) ((dev) >> MINORBITS)) -#define MINOR(dev) ((unsigned short) ((dev) & MINORMASK)) -#define MKDEV(ma,mi) ((kdev_t) (((ma) << MINORBITS) | (mi))) -#define NODEV MKDEV(0,0) - -#include - -typedef __u16 kdev_t; +typedef __u16 kdev_t; /* As long as device numbers in the outside world have 16 bits only, * we use these conversions. */ -#define kdev_t_to_nr(dev) ((__u16) dev) -#define to_kdev_t(dev) ((kdev_t) dev) - -#else /* __KERNEL__*/ - -/* Some programs want their definitions of MAJOR and MINOR and MKDEV - * from the kernel sources. These must be the externally visible ones. - */ - -#define MAJOR(dev) (((dev) >> MINORBITS)) -#define MINOR(dev) (((dev) & MINORMASK)) -#define MKDEV(major,minor) ((major) << MINORBITS | (minor)) +#define kdev_t_to_nr(dev) ((__u16) dev) +#define to_kdev_t(dev) ((kdev_t) dev) -#endif +#endif /* __KERNEL__*/ -#endif +#endif /* __LINUXMT_KDEV_T_H */ diff --git a/elks/include/linuxmt/posix_types.h b/elks/include/linuxmt/posix_types.h index 9838ed134..556169add 100644 --- a/elks/include/linuxmt/posix_types.h +++ b/elks/include/linuxmt/posix_types.h @@ -20,18 +20,14 @@ * use the ones here. */ -/*@-namechecks@*/ - #undef __NFDBITS -#define __NFDBITS (8 * sizeof(unsigned long)) +#define __NFDBITS (8 * sizeof(unsigned long)) #undef __FD_SETSIZE -#define __FD_SETSIZE 20 +#define __FD_SETSIZE 20 typedef __u32 __kernel_fd_set; -/*@+namechecks@*/ - #include #include diff --git a/elks/include/linuxmt/types.h b/elks/include/linuxmt/types.h index 871385791..9aa098890 100644 --- a/elks/include/linuxmt/types.h +++ b/elks/include/linuxmt/types.h @@ -7,49 +7,49 @@ #include #endif -typedef __s32 loff_t; -typedef __s32 off_t; - -typedef __u32 jiff_t; -typedef __u32 lsize_t; -typedef __u32 speed_t; -typedef __u32 tcflag_t; - -typedef __u16 block_t; -typedef __u32 block32_t; -typedef __u32 sector_t; -typedef __u16 dev_t; -typedef __u16 flag_t; -typedef long cluster_t; - -typedef __u32 u_ino_t; +typedef __s32 loff_t; +typedef __s32 off_t; + +typedef __u32 jiff_t; +typedef __u32 lsize_t; +typedef __u32 speed_t; +typedef __u32 tcflag_t; + +typedef __u16 block_t; +typedef __u32 block32_t; +typedef __u32 sector_t; +typedef __u16 dev_t; +typedef __u16 flag_t; +typedef long cluster_t; + +typedef __u32 u_ino_t; #ifndef __KERNEL__ -typedef u_ino_t ino_t; +typedef u_ino_t ino_t; #else #ifdef CONFIG_32BIT_INODES -typedef __u32 ino_t; +typedef __u32 ino_t; #else -typedef __u16 ino_t; +typedef __u16 ino_t; #endif #endif /* __KERNEL__*/ -typedef __u16 pid_t; -typedef __u16 uid_t; -typedef __u16 gid_t; +typedef __u16 pid_t; +typedef __u16 uid_t; +typedef __u16 gid_t; -typedef __u16 mode_t; -typedef __u16 nlink_t; -typedef __u16 segext_t; -typedef __u16 umode_t; +typedef __u16 mode_t; +typedef __u16 nlink_t; +typedef __u16 segext_t; +typedef __u16 umode_t; -typedef __u8 cc_t; -typedef __u16 sig_t; -typedef __s16 sem_t; +typedef __u8 cc_t; +typedef __u16 sig_t; +typedef __s16 sem_t; -typedef __u32 time_t; -typedef __u32 fd_mask_t; +typedef __u32 time_t; +typedef __u32 fd_mask_t; #include -typedef __kernel_fd_set fd_set; +typedef __kernel_fd_set fd_set; #endif