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                 err = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
  30                 if (err)
  31                         return err;
  32                 put_user(inode->u.ext2_i.i_flags, (int *) arg);
  33                 return 0;
  34         case EXT2_IOC_SETFLAGS:
  35                 err = verify_area(VERIFY_READ, (int *) arg, sizeof(int));
  36                 if (err)
  37                         return err;
  38                 flags = get_user((int *) arg);
  39                 /*
  40                  * The IMMUTABLE flag can only be changed by the super user
  41                  * when the security level is zero.
  42                  */
  43                 if ((flags & EXT2_IMMUTABLE_FL) ^
  44                     (inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL)) {
  45                         /* This test looks nicer. Thanks to Pauline Middelink */
  46                         if (!fsuser() || securelevel > 0)
  47                                 return -EPERM;
  48                 } else
  49                         if ((current->fsuid != inode->i_uid) && !fsuser())
  50                                 return -EPERM;
  51                 if (IS_RDONLY(inode))
  52                         return -EROFS;
  53                 inode->u.ext2_i.i_flags = flags;
  54                 if (flags & EXT2_APPEND_FL)
  55                         inode->i_flags |= S_APPEND;
  56                 else
  57                         inode->i_flags &= ~S_APPEND;
  58                 if (flags & EXT2_IMMUTABLE_FL)
  59                         inode->i_flags |= S_IMMUTABLE;
  60                 else
  61                         inode->i_flags &= ~S_IMMUTABLE;
  62                 inode->i_ctime = CURRENT_TIME;
  63                 inode->i_dirt = 1;
  64                 return 0;
  65         case EXT2_IOC_GETVERSION:
  66                 err = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
  67                 if (err)
  68                         return err;
  69                 put_user(inode->u.ext2_i.i_version, (int *) arg);
  70                 return 0;
  71         case EXT2_IOC_SETVERSION:
  72                 if ((current->fsuid != inode->i_uid) && !fsuser())
  73                         return -EPERM;
  74                 if (IS_RDONLY(inode))
  75                         return -EROFS;
  76                 err = verify_area(VERIFY_READ, (int *) arg, sizeof(int));
  77                 if (err)
  78                         return err;
  79                 inode->u.ext2_i.i_version = get_user((int *) arg);
  80                 inode->i_ctime = CURRENT_TIME;
  81                 inode->i_dirt = 1;
  82                 return 0;
  83         default:
  84                 return -EINVAL;
  85         }
  86 }

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