Skip to content

Commit 45222b9

Browse files
dhowellsLinus Torvalds
authored andcommitted
AFS: implement statfs
Implement the statfs() op for AFS. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0f300ca commit 45222b9

7 files changed

Lines changed: 426 additions & 15 deletions

File tree

‎fs/afs/afs.h‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
#define AFS_MAXCELLNAME 64 /* maximum length of a cell name */
1818
#define AFS_MAXVOLNAME 64 /* maximum length of a volume name */
19+
#define AFSNAMEMAX 256 /* maximum length of a filename plus NUL */
20+
#define AFSPATHMAX 1024 /* maximum length of a pathname plus NUL */
21+
#define AFSOPAQUEMAX 1024 /* maximum length of an opaque field */
1922

2023
typedef unsigned afs_volid_t;
2124
typedef unsigned afs_vnodeid_t;
@@ -143,4 +146,24 @@ struct afs_volsync {
143146
time_t creation; /* volume creation time */
144147
};
145148

149+
/*
150+
* AFS volume status record
151+
*/
152+
struct afs_volume_status {
153+
u32 vid; /* volume ID */
154+
u32 parent_id; /* parent volume ID */
155+
u8 online; /* true if volume currently online and available */
156+
u8 in_service; /* true if volume currently in service */
157+
u8 blessed; /* same as in_service */
158+
u8 needs_salvage; /* true if consistency checking required */
159+
u32 type; /* volume type (afs_voltype_t) */
160+
u32 min_quota; /* minimum space set aside (blocks) */
161+
u32 max_quota; /* maximum space this volume may occupy (blocks) */
162+
u32 blocks_in_use; /* space this volume currently occupies (blocks) */
163+
u32 part_blocks_avail; /* space available in volume's partition */
164+
u32 part_max_blocks; /* size of volume's partition */
165+
};
166+
167+
#define AFS_BLOCK_SIZE 1024
168+
146169
#endif /* AFS_H */

‎fs/afs/afs_fs.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ enum AFS_FS_Operations {
2828
FSMAKEDIR = 141, /* AFS Create a directory */
2929
FSREMOVEDIR = 142, /* AFS Remove a directory */
3030
FSGIVEUPCALLBACKS = 147, /* AFS Discard callback promises */
31-
FSGETVOLUMEINFO = 148, /* AFS Get root volume information */
31+
FSGETVOLUMEINFO = 148, /* AFS Get information about a volume */
32+
FSGETVOLUMESTATUS = 149, /* AFS Get volume status information */
3233
FSGETROOTVOLUME = 151, /* AFS Get root volume name */
3334
FSLOOKUP = 161, /* AFS lookup file in directory */
3435
FSFETCHDATA64 = 65537, /* AFS Fetch file data */

‎fs/afs/dir.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
497497

498498
ASSERTCMP(dentry->d_inode, ==, NULL);
499499

500-
if (dentry->d_name.len > 255) {
500+
if (dentry->d_name.len >= AFSNAMEMAX) {
501501
_leave(" = -ENAMETOOLONG");
502502
return ERR_PTR(-ENAMETOOLONG);
503503
}
@@ -736,7 +736,7 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
736736
dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
737737

738738
ret = -ENAMETOOLONG;
739-
if (dentry->d_name.len > 255)
739+
if (dentry->d_name.len >= AFSNAMEMAX)
740740
goto error;
741741

742742
key = afs_request_key(dvnode->volume->cell);
@@ -801,7 +801,7 @@ static int afs_rmdir(struct inode *dir, struct dentry *dentry)
801801
dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
802802

803803
ret = -ENAMETOOLONG;
804-
if (dentry->d_name.len > 255)
804+
if (dentry->d_name.len >= AFSNAMEMAX)
805805
goto error;
806806

807807
key = afs_request_key(dvnode->volume->cell);
@@ -847,7 +847,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
847847
dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
848848

849849
ret = -ENAMETOOLONG;
850-
if (dentry->d_name.len > 255)
850+
if (dentry->d_name.len >= AFSNAMEMAX)
851851
goto error;
852852

853853
key = afs_request_key(dvnode->volume->cell);
@@ -921,7 +921,7 @@ static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
921921
dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
922922

923923
ret = -ENAMETOOLONG;
924-
if (dentry->d_name.len > 255)
924+
if (dentry->d_name.len >= AFSNAMEMAX)
925925
goto error;
926926

927927
key = afs_request_key(dvnode->volume->cell);
@@ -990,7 +990,7 @@ static int afs_link(struct dentry *from, struct inode *dir,
990990
dentry->d_name.name);
991991

992992
ret = -ENAMETOOLONG;
993-
if (dentry->d_name.len > 255)
993+
if (dentry->d_name.len >= AFSNAMEMAX)
994994
goto error;
995995

996996
key = afs_request_key(dvnode->volume->cell);
@@ -1038,11 +1038,11 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry,
10381038
content);
10391039

10401040
ret = -ENAMETOOLONG;
1041-
if (dentry->d_name.len > 255)
1041+
if (dentry->d_name.len >= AFSNAMEMAX)
10421042
goto error;
10431043

10441044
ret = -EINVAL;
1045-
if (strlen(content) > 1023)
1045+
if (strlen(content) >= AFSPATHMAX)
10461046
goto error;
10471047

10481048
key = afs_request_key(dvnode->volume->cell);
@@ -1112,7 +1112,7 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
11121112
new_dentry->d_name.name);
11131113

11141114
ret = -ENAMETOOLONG;
1115-
if (new_dentry->d_name.len > 255)
1115+
if (new_dentry->d_name.len >= AFSNAMEMAX)
11161116
goto error;
11171117

11181118
key = afs_request_key(orig_dvnode->volume->cell);

0 commit comments

Comments
 (0)