fs.h (f4480240f700587c15507b7815e75989b16825b2) fs.h (a569425512253992cc64ebf8b6d00a62f986db3e)
1#ifndef _LINUX_FS_H
2#define _LINUX_FS_H
3
4/*
5 * This file has definitions for some important file table
6 * structures etc.
7 */
8

--- 275 unchanged lines hidden (view full) ---

284#include <linux/pid.h>
285#include <linux/mutex.h>
286#include <linux/sysctl.h>
287
288#include <asm/atomic.h>
289#include <asm/semaphore.h>
290#include <asm/byteorder.h>
291
1#ifndef _LINUX_FS_H
2#define _LINUX_FS_H
3
4/*
5 * This file has definitions for some important file table
6 * structures etc.
7 */
8

--- 275 unchanged lines hidden (view full) ---

284#include <linux/pid.h>
285#include <linux/mutex.h>
286#include <linux/sysctl.h>
287
288#include <asm/atomic.h>
289#include <asm/semaphore.h>
290#include <asm/byteorder.h>
291
292struct export_operations;
292struct hd_geometry;
293struct iovec;
294struct nameidata;
295struct kiocb;
296struct pipe_inode_info;
297struct poll_table_struct;
298struct kstatfs;
299struct vm_area_struct;

--- 973 unchanged lines hidden (view full) ---

1273static inline void file_accessed(struct file *file)
1274{
1275 if (!(file->f_flags & O_NOATIME))
1276 touch_atime(file->f_path.mnt, file->f_path.dentry);
1277}
1278
1279int sync_inode(struct inode *inode, struct writeback_control *wbc);
1280
293struct hd_geometry;
294struct iovec;
295struct nameidata;
296struct kiocb;
297struct pipe_inode_info;
298struct poll_table_struct;
299struct kstatfs;
300struct vm_area_struct;

--- 973 unchanged lines hidden (view full) ---

1274static inline void file_accessed(struct file *file)
1275{
1276 if (!(file->f_flags & O_NOATIME))
1277 touch_atime(file->f_path.mnt, file->f_path.dentry);
1278}
1279
1280int sync_inode(struct inode *inode, struct writeback_control *wbc);
1281
1281/**
1282 * struct export_operations - for nfsd to communicate with file systems
1283 * @decode_fh: decode a file handle fragment and return a &struct dentry
1284 * @encode_fh: encode a file handle fragment from a dentry
1285 * @get_name: find the name for a given inode in a given directory
1286 * @get_parent: find the parent of a given directory
1287 * @get_dentry: find a dentry for the inode given a file handle sub-fragment
1288 * @find_exported_dentry:
1289 * set by the exporting module to a standard helper function.
1290 *
1291 * Description:
1292 * The export_operations structure provides a means for nfsd to communicate
1293 * with a particular exported file system - particularly enabling nfsd and
1294 * the filesystem to co-operate when dealing with file handles.
1295 *
1296 * export_operations contains two basic operation for dealing with file
1297 * handles, decode_fh() and encode_fh(), and allows for some other
1298 * operations to be defined which standard helper routines use to get
1299 * specific information from the filesystem.
1300 *
1301 * nfsd encodes information use to determine which filesystem a filehandle
1302 * applies to in the initial part of the file handle. The remainder, termed
1303 * a file handle fragment, is controlled completely by the filesystem. The
1304 * standard helper routines assume that this fragment will contain one or
1305 * two sub-fragments, one which identifies the file, and one which may be
1306 * used to identify the (a) directory containing the file.
1307 *
1308 * In some situations, nfsd needs to get a dentry which is connected into a
1309 * specific part of the file tree. To allow for this, it passes the
1310 * function acceptable() together with a @context which can be used to see
1311 * if the dentry is acceptable. As there can be multiple dentrys for a
1312 * given file, the filesystem should check each one for acceptability before
1313 * looking for the next. As soon as an acceptable one is found, it should
1314 * be returned.
1315 *
1316 * decode_fh:
1317 * @decode_fh is given a &struct super_block (@sb), a file handle fragment
1318 * (@fh, @fh_len) and an acceptability testing function (@acceptable,
1319 * @context). It should return a &struct dentry which refers to the same
1320 * file that the file handle fragment refers to, and which passes the
1321 * acceptability test. If it cannot, it should return a %NULL pointer if
1322 * the file was found but no acceptable &dentries were available, or a
1323 * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or
1324 * %ENOMEM).
1325 *
1326 * encode_fh:
1327 * @encode_fh should store in the file handle fragment @fh (using at most
1328 * @max_len bytes) information that can be used by @decode_fh to recover the
1329 * file refered to by the &struct dentry @de. If the @connectable flag is
1330 * set, the encode_fh() should store sufficient information so that a good
1331 * attempt can be made to find not only the file but also it's place in the
1332 * filesystem. This typically means storing a reference to de->d_parent in
1333 * the filehandle fragment. encode_fh() should return the number of bytes
1334 * stored or a negative error code such as %-ENOSPC
1335 *
1336 * get_name:
1337 * @get_name should find a name for the given @child in the given @parent
1338 * directory. The name should be stored in the @name (with the
1339 * understanding that it is already pointing to a a %NAME_MAX+1 sized
1340 * buffer. get_name() should return %0 on success, a negative error code
1341 * or error. @get_name will be called without @parent->i_mutex held.
1342 *
1343 * get_parent:
1344 * @get_parent should find the parent directory for the given @child which
1345 * is also a directory. In the event that it cannot be found, or storage
1346 * space cannot be allocated, a %ERR_PTR should be returned.
1347 *
1348 * get_dentry:
1349 * Given a &super_block (@sb) and a pointer to a file-system specific inode
1350 * identifier, possibly an inode number, (@inump) get_dentry() should find
1351 * the identified inode and return a dentry for that inode. Any suitable
1352 * dentry can be returned including, if necessary, a new dentry created with
1353 * d_alloc_root. The caller can then find any other extant dentrys by
1354 * following the d_alias links. If a new dentry was created using
1355 * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry
1356 * should be d_rehash()ed.
1357 *
1358 * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code
1359 * can be returned. The @inump will be whatever was passed to
1360 * nfsd_find_fh_dentry() in either the @obj or @parent parameters.
1361 *
1362 * Locking rules:
1363 * get_parent is called with child->d_inode->i_mutex down
1364 * get_name is not (which is possibly inconsistent)
1365 */
1366
1367struct export_operations {
1368 struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,
1369 int (*acceptable)(void *context, struct dentry *de),
1370 void *context);
1371 int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
1372 int connectable);
1373
1374 /* the following are only called from the filesystem itself */
1375 int (*get_name)(struct dentry *parent, char *name,
1376 struct dentry *child);
1377 struct dentry * (*get_parent)(struct dentry *child);
1378 struct dentry * (*get_dentry)(struct super_block *sb, void *inump);
1379
1380 /* This is set by the exporting module to a standard helper */
1381 struct dentry * (*find_exported_dentry)(
1382 struct super_block *sb, void *obj, void *parent,
1383 int (*acceptable)(void *context, struct dentry *de),
1384 void *context);
1385
1386
1387};
1388
1389extern struct dentry *
1390find_exported_dentry(struct super_block *sb, void *obj, void *parent,
1391 int (*acceptable)(void *context, struct dentry *de),
1392 void *context);
1393
1394struct file_system_type {
1395 const char *name;
1396 int fs_flags;
1397 int (*get_sb) (struct file_system_type *, int,
1398 const char *, void *, struct vfsmount *);
1399 void (*kill_sb) (struct super_block *);
1400 struct module *owner;
1401 struct file_system_type * next;

--- 658 unchanged lines hidden ---
1282struct file_system_type {
1283 const char *name;
1284 int fs_flags;
1285 int (*get_sb) (struct file_system_type *, int,
1286 const char *, void *, struct vfsmount *);
1287 void (*kill_sb) (struct super_block *);
1288 struct module *owner;
1289 struct file_system_type * next;

--- 658 unchanged lines hidden ---