root/fs/ext2/ioctl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ext2_ioctl

   1 /*
   2  * linux/fs/ext2/ioctl.c
   3  *
   4  * Copyright (C) 1993, 1994, 1995
   5  * Remy Card (card@masi.ibp.fr)
   6  * Laboratoire MASI - Institut Blaise Pascal
   7  * Universite Pierre et Marie Curie (Paris VI)
   8  */
   9 
  10 #include <asm/segment.h>
  11 
  12 #include <linux/errno.h>
  13 #include <linux/fs.h>
  14 #include <linux/ext2_fs.h>
  15 #include <linux/ioctl.h>
  16 #include <linux/sched.h>
  17 #include <linux/mm.h>
  18 
  19 int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
     /* [previous][next][first][last][top][bottom][index][help] */
  20                 unsigned long arg)
  21 {
  22         int err;
  23         unsigned long flags;
  24 
  25         ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg);
  26 
  27         switch (cmd) {
  28         case EXT2_IOC_GETFLAGS:
  29                 if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
  30                         return err;
  31                 put_fs_long (inode->u.ext2_i.i_flags, (long *) arg);
  32                 return 0;
  33         case EXT2_IOC_SETFLAGS:
  34                 flags = get_fs_long ((long *) arg);
  35                 /*
  36                  * The IMMUTABLE flag can only be changed by the super user
  37                  * when the security level is zero.
  38                  */
  39                 if ((flags & EXT2_IMMUTABLE_FL) ^
  40                     (inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL)) {
  41                         /* This test looks nicer. Thanks to Pauline Middelink */
  42                         if (!fsuser() || securelevel > 0)
  43                                 return -EPERM;
  44                 } else
  45                         if ((current->fsuid != inode->i_uid) && !fsuser())
  46                                 return -EPERM;
  47                 if (IS_RDONLY(inode))
  48                         return -EROFS;
  49                 inode->u.ext2_i.i_flags = flags;
  50                 if (flags & EXT2_APPEND_FL)
  51                         inode->i_flags |= S_APPEND;
  52                 else
  53                         inode->i_flags &= ~S_APPEND;
  54                 if (flags & EXT2_IMMUTABLE_FL)
  55                         inode->i_flags |= S_IMMUTABLE;
  56                 else
  57                         inode->i_flags &= ~S_IMMUTABLE;
  58                 inode->i_ctime = CURRENT_TIME;
  59                 inode->i_dirt = 1;
  60                 return 0;
  61         case EXT2_IOC_GETVERSION:
  62                 if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
  63                         return err;
  64                 put_fs_long (inode->u.ext2_i.i_version, (long *) arg);
  65                 return 0;
  66         case EXT2_IOC_SETVERSION:
  67                 if ((current->fsuid != inode->i_uid) && !fsuser())
  68                         return -EPERM;
  69                 if (IS_RDONLY(inode))
  70                         return -EROFS;
  71                 inode->u.ext2_i.i_version = get_fs_long ((long *) arg);
  72                 inode->i_ctime = CURRENT_TIME;
  73                 inode->i_dirt = 1;
  74                 return 0;
  75         default:
  76                 return -EINVAL;
  77         }
  78 }

/* [previous][next][first][last][top][bottom][index][help] */