1*0ca3913dSOlivier Deprez /* 2*0ca3913dSOlivier Deprez * Copyright (c) 2019, Arm Limited. All rights reserved. 3*0ca3913dSOlivier Deprez * 4*0ca3913dSOlivier Deprez * SPDX-License-Identifier: BSD-3-Clause 5*0ca3913dSOlivier Deprez */ 6*0ca3913dSOlivier Deprez 7*0ca3913dSOlivier Deprez #ifndef DEBUGFS_H 8*0ca3913dSOlivier Deprez #define DEBUGFS_H 9*0ca3913dSOlivier Deprez 10*0ca3913dSOlivier Deprez #define NAMELEN 13 /* Maximum length of a file name */ 11*0ca3913dSOlivier Deprez #define PATHLEN 41 /* Maximum length of a path */ 12*0ca3913dSOlivier Deprez #define STATLEN 41 /* Size of static part of dir format */ 13*0ca3913dSOlivier Deprez #define ROOTLEN (2 + 4) /* Size needed to encode root string */ 14*0ca3913dSOlivier Deprez #define FILNAMLEN (2 + NAMELEN) /* Size needed to encode filename */ 15*0ca3913dSOlivier Deprez #define DIRLEN (STATLEN + FILNAMLEN + 3*ROOTLEN) /* Size of dir entry */ 16*0ca3913dSOlivier Deprez 17*0ca3913dSOlivier Deprez #define KSEEK_SET 0 18*0ca3913dSOlivier Deprez #define KSEEK_CUR 1 19*0ca3913dSOlivier Deprez #define KSEEK_END 2 20*0ca3913dSOlivier Deprez 21*0ca3913dSOlivier Deprez #define NELEM(tab) (sizeof(tab) / sizeof((tab)[0])) 22*0ca3913dSOlivier Deprez 23*0ca3913dSOlivier Deprez typedef unsigned short qid_t; /* FIXME: short type not recommended? */ 24*0ca3913dSOlivier Deprez 25*0ca3913dSOlivier Deprez /******************************************************************************* 26*0ca3913dSOlivier Deprez * This structure contains the necessary information to represent a 9p 27*0ca3913dSOlivier Deprez * directory. 28*0ca3913dSOlivier Deprez ******************************************************************************/ 29*0ca3913dSOlivier Deprez typedef struct { 30*0ca3913dSOlivier Deprez char name[NAMELEN]; 31*0ca3913dSOlivier Deprez long length; 32*0ca3913dSOlivier Deprez unsigned char mode; 33*0ca3913dSOlivier Deprez unsigned char index; 34*0ca3913dSOlivier Deprez unsigned char dev; 35*0ca3913dSOlivier Deprez qid_t qid; 36*0ca3913dSOlivier Deprez } dir_t; 37*0ca3913dSOlivier Deprez 38*0ca3913dSOlivier Deprez /* Permission definitions used as flags */ 39*0ca3913dSOlivier Deprez #define O_READ (1 << 0) 40*0ca3913dSOlivier Deprez #define O_WRITE (1 << 1) 41*0ca3913dSOlivier Deprez #define O_RDWR (1 << 2) 42*0ca3913dSOlivier Deprez #define O_BIND (1 << 3) 43*0ca3913dSOlivier Deprez #define O_DIR (1 << 4) 44*0ca3913dSOlivier Deprez #define O_STAT (1 << 5) 45*0ca3913dSOlivier Deprez 46*0ca3913dSOlivier Deprez /* 9p interface */ 47*0ca3913dSOlivier Deprez int mount(const char *srv, const char *mnt, const char *spec); 48*0ca3913dSOlivier Deprez int create(const char *name, int flags); 49*0ca3913dSOlivier Deprez int open(const char *name, int flags); 50*0ca3913dSOlivier Deprez int close(int fd); 51*0ca3913dSOlivier Deprez int read(int fd, void *buf, int n); 52*0ca3913dSOlivier Deprez int write(int fd, void *buf, int n); 53*0ca3913dSOlivier Deprez int seek(int fd, long off, int whence); 54*0ca3913dSOlivier Deprez int bind(const char *path, const char *where); 55*0ca3913dSOlivier Deprez int stat(const char *path, dir_t *dir); 56*0ca3913dSOlivier Deprez 57*0ca3913dSOlivier Deprez /* DebugFS initialization */ 58*0ca3913dSOlivier Deprez void debugfs_init(void); 59*0ca3913dSOlivier Deprez 60*0ca3913dSOlivier Deprez #endif /* DEBUGFS_H */ 61