file.c (75cd4e098d178433436abce08146a21647bb4585) | file.c (f424f664f0e8949361d268e2e91c7acc8cf63eb2) |
---|---|
1/* 2 * fs/f2fs/file.c 3 * 4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 * http://www.samsung.com/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 6 unchanged lines hidden (view full) --- 15#include <linux/writeback.h> 16#include <linux/blkdev.h> 17#include <linux/falloc.h> 18#include <linux/types.h> 19#include <linux/compat.h> 20#include <linux/uaccess.h> 21#include <linux/mount.h> 22#include <linux/pagevec.h> | 1/* 2 * fs/f2fs/file.c 3 * 4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 * http://www.samsung.com/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 6 unchanged lines hidden (view full) --- 15#include <linux/writeback.h> 16#include <linux/blkdev.h> 17#include <linux/falloc.h> 18#include <linux/types.h> 19#include <linux/compat.h> 20#include <linux/uaccess.h> 21#include <linux/mount.h> 22#include <linux/pagevec.h> |
23#include <linux/random.h> |
|
23 24#include "f2fs.h" 25#include "node.h" 26#include "segment.h" 27#include "xattr.h" 28#include "acl.h" 29#include "trace.h" 30#include <trace/events/f2fs.h> --- 1311 unchanged lines hidden (view full) --- 1342 return ret; 1343 1344 if (copy_to_user((struct fstrim_range __user *)arg, &range, 1345 sizeof(range))) 1346 return -EFAULT; 1347 return 0; 1348} 1349 | 24 25#include "f2fs.h" 26#include "node.h" 27#include "segment.h" 28#include "xattr.h" 29#include "acl.h" 30#include "trace.h" 31#include <trace/events/f2fs.h> --- 1311 unchanged lines hidden (view full) --- 1343 return ret; 1344 1345 if (copy_to_user((struct fstrim_range __user *)arg, &range, 1346 sizeof(range))) 1347 return -EFAULT; 1348 return 0; 1349} 1350 |
1351static bool uuid_is_nonzero(__u8 u[16]) 1352{ 1353 int i; 1354 1355 for (i = 0; i < 16; i++) 1356 if (u[i]) 1357 return true; 1358 return false; 1359} 1360 1361static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) 1362{ 1363#ifdef CONFIG_F2FS_FS_ENCRYPTION 1364 struct f2fs_encryption_policy policy; 1365 struct inode *inode = file_inode(filp); 1366 1367 if (copy_from_user(&policy, (struct f2fs_encryption_policy __user *)arg, 1368 sizeof(policy))) 1369 return -EFAULT; 1370 1371 if (f2fs_has_inline_data(inode)) { 1372 int ret = f2fs_convert_inline_inode(inode); 1373 if (ret) 1374 return ret; 1375 } 1376 1377 return f2fs_process_policy(&policy, inode); 1378#else 1379 return -EOPNOTSUPP; 1380#endif 1381} 1382 1383static int f2fs_ioc_get_encryption_policy(struct file *filp, unsigned long arg) 1384{ 1385#ifdef CONFIG_F2FS_FS_ENCRYPTION 1386 struct f2fs_encryption_policy policy; 1387 struct inode *inode = file_inode(filp); 1388 int err; 1389 1390 err = f2fs_get_policy(inode, &policy); 1391 if (err) 1392 return err; 1393 1394 if (copy_to_user((struct f2fs_encryption_policy __user *)arg, &policy, 1395 sizeof(policy))) 1396 return -EFAULT; 1397 return 0; 1398#else 1399 return -EOPNOTSUPP; 1400#endif 1401} 1402 1403static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg) 1404{ 1405 struct inode *inode = file_inode(filp); 1406 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 1407 int err; 1408 1409 if (!f2fs_sb_has_crypto(inode->i_sb)) 1410 return -EOPNOTSUPP; 1411 1412 if (uuid_is_nonzero(sbi->raw_super->encrypt_pw_salt)) 1413 goto got_it; 1414 1415 err = mnt_want_write_file(filp); 1416 if (err) 1417 return err; 1418 1419 /* update superblock with uuid */ 1420 generate_random_uuid(sbi->raw_super->encrypt_pw_salt); 1421 1422 err = f2fs_commit_super(sbi); 1423 1424 mnt_drop_write_file(filp); 1425 if (err) { 1426 /* undo new data */ 1427 memset(sbi->raw_super->encrypt_pw_salt, 0, 16); 1428 return err; 1429 } 1430got_it: 1431 if (copy_to_user((__u8 __user *)arg, sbi->raw_super->encrypt_pw_salt, 1432 16)) 1433 return -EFAULT; 1434 return 0; 1435} 1436 |
|
1350long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 1351{ 1352 switch (cmd) { 1353 case F2FS_IOC_GETFLAGS: 1354 return f2fs_ioc_getflags(filp, arg); 1355 case F2FS_IOC_SETFLAGS: 1356 return f2fs_ioc_setflags(filp, arg); 1357 case F2FS_IOC_GETVERSION: --- 7 unchanged lines hidden (view full) --- 1365 case F2FS_IOC_RELEASE_VOLATILE_WRITE: 1366 return f2fs_ioc_release_volatile_write(filp); 1367 case F2FS_IOC_ABORT_VOLATILE_WRITE: 1368 return f2fs_ioc_abort_volatile_write(filp); 1369 case F2FS_IOC_SHUTDOWN: 1370 return f2fs_ioc_shutdown(filp, arg); 1371 case FITRIM: 1372 return f2fs_ioc_fitrim(filp, arg); | 1437long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 1438{ 1439 switch (cmd) { 1440 case F2FS_IOC_GETFLAGS: 1441 return f2fs_ioc_getflags(filp, arg); 1442 case F2FS_IOC_SETFLAGS: 1443 return f2fs_ioc_setflags(filp, arg); 1444 case F2FS_IOC_GETVERSION: --- 7 unchanged lines hidden (view full) --- 1452 case F2FS_IOC_RELEASE_VOLATILE_WRITE: 1453 return f2fs_ioc_release_volatile_write(filp); 1454 case F2FS_IOC_ABORT_VOLATILE_WRITE: 1455 return f2fs_ioc_abort_volatile_write(filp); 1456 case F2FS_IOC_SHUTDOWN: 1457 return f2fs_ioc_shutdown(filp, arg); 1458 case FITRIM: 1459 return f2fs_ioc_fitrim(filp, arg); |
1460 case F2FS_IOC_SET_ENCRYPTION_POLICY: 1461 return f2fs_ioc_set_encryption_policy(filp, arg); 1462 case F2FS_IOC_GET_ENCRYPTION_POLICY: 1463 return f2fs_ioc_get_encryption_policy(filp, arg); 1464 case F2FS_IOC_GET_ENCRYPTION_PWSALT: 1465 return f2fs_ioc_get_encryption_pwsalt(filp, arg); |
|
1373 default: 1374 return -ENOTTY; 1375 } 1376} 1377 1378#ifdef CONFIG_COMPAT 1379long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 1380{ --- 30 unchanged lines hidden --- | 1466 default: 1467 return -ENOTTY; 1468 } 1469} 1470 1471#ifdef CONFIG_COMPAT 1472long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 1473{ --- 30 unchanged lines hidden --- |